3 require
'BayEOSGatewayClient.php';
8 $config=parse_ini_file(
'/etc/bayeos-logger-importer.ini');
11 $ref_date= DateTime::createFromFormat(
'Y-m-d H:i:s P',
'2000-01-01 00:00:00 +00:00')->format(
'U');
21 $this->queue=$this->
getOption(
'tmp_dir').
'/'.str_replace(array(
'/',
'\\',
'"',
'\''),
'_',$this->name).
'_queue';
22 if(! is_dir($this->queue)){
23 if(! mkdir($this->queue,0777,TRUE)){
24 die(
"could not create ".$this->queue);
27 exec(
'chmod 1777 '.$this->queue);
31 private function openQueueFile(){
32 if($this->queue_fp)
return 1;
35 $files=glob($this->queue.
'/*');
36 }
while(count($files)==0);
37 $this->queue_file=$files[0];
38 $this->queue_fp=fopen($files[0],
'r');
43 if($this->queue_fp && feof($this->queue_fp)){
44 fclose($this->queue_fp);
46 unlink($this->queue_file);
48 $this->openQueueFile();
52 $bayeosframe=fread($this->queue_fp,$length);
53 return array(
'frame'=>$bayeosframe,
'ts'=>$ts);
58 $this->writer->saveFrame(
$data[
'frame'],
$data[
'ts']);
getOption($key, $default='')
static unpackUINT32($value, $endianness=0)
static unpackUINT8($value)