3 require
'BayEOSGatewayClient.php';
8 $config=parse_ini_file(
'/etc/bayeos-socket.ini');
12 for($i=0;$i<count(
$config[
'socket']);$i++){
23 private $datetime_format;
33 $this->datetime_format=$this->
getOption(
'datetime_format');
36 private function connect(){
38 while(! $this->fp = stream_socket_client($this->socket,$error,$errstr,30)){
41 stream_set_blocking($this->fp, 1);
48 $line=stream_get_line($this->fp,1024,
"\n");
57 return $this->parseData($line);
60 private function parseData($line){
62 if($this->datetime_format){
63 $pos=strpos($line,$this->delim);
64 $ts=substr($line,0,
$pos);
66 $line=substr($line,
$pos+1);
67 $ts=floatval(DateTime::createFromFormat($this->datetime_format,$ts,
new DateTimeZone($this->tz))->format(
"U.u"));
70 if($this->dec!=
'.') $line=str_replace($this->dec,
'.',$line);
71 $data=explode($this->delim,trim($line));
75 return array(
'values'=>
$data,
'ts'=>$ts);
88 array(
'data_type'=>0x41,
91 'tz'=>date_default_timezone_get());
getOption($key, $default='')
if(!isset($config['names'])) else $names