public static function parserMessage($_message) { if ($_message->getIdentifier() == xPLMessage::xplcmnd) { return false; } $source = $_message->source(); $device = $_message->bodyItem('device'); $type = $_message->bodyItem('type'); $value = $_message->bodyItem('current'); $xPL = xPL::byLogicalId($source, 'xpl'); if (is_object($xPL)) { $list_cmd = $xPL->getCmd(); foreach ($list_cmd as $cmd) { $device_compare = $cmd->getItem('device'); $type_compare = $cmd->getItem('type'); if ($device === $device_compare && $type === $type_compare) { $event_info = array(); $event_info['cmd_id'] = $cmd->getId(); $event_info['value'] = $value; return array($event_info); } } } return array(); }
public static function parserMessage($_message) { if ($_message->getIdentifier() == xPLMessage::xplcmnd) { return false; } $source = $_message->source(); $address = $_message->bodyItem('address'); $unit = $_message->bodyItem('unit'); $command = $_message->bodyItem('command'); $xPL = xPL::byLogicalId($source, 'xpl'); if (is_object($xPL)) { $list_cmd = $xPL->getCmd(); foreach ($list_cmd as $cmd) { $address_compare = $cmd->getItem('address'); $unit_compare = $cmd->getItem('unit'); if ($address === $address_compare && $unit === $unit_compare) { $event_info = array(); $event_info['cmd_id'] = $cmd->getId(); $event_info['value'] = $command; return array($event_info); } } } return array(); }
public static function parserMessage($_message) { if ($_message->getIdentifier() == xPLMessage::xplcmnd) { return false; } $type = $_message->getIdentifier(); // 1,2,3 $shema = $_message->messageSchemeIdentifier(); $source = $_message->source(); $network = $_message->bodyItem('network'); $device = $_message->bodyItem('device'); $channel = $_message->bodyItem('channel'); $state = $_message->bodyItem('state'); $level = $_message->bodyItem('level'); $xPL = xPL::byLogicalId($source, 'xpl'); if (is_object($xPL)) { $list_cmd = $xPL->getCmd(); foreach ($list_cmd as $cmd) { $shema_compare = $cmd->getConfiguration('xPLschema'); $type_compare = $cmd->getConfiguration('xPLtypeCmd'); //'XPL-TRIG' $network_compare = $cmd->getItem('network'); $device_compare = $cmd->getItem('device'); $channel_compare = $cmd->getItem('channel'); if ($shema == $shema_compare && ($type == xPLMessage::xpltrig && $type_compare == 'XPL-TRIG' || $type == xPLMessage::xplstat && $type_compare == 'XPL-STAT') && $network === $network_compare && $device === $device_compare && $channel === $channel_compare) { $event_info = array(); $event_info['cmd_id'] = $cmd->getId(); $event_info['value'] = $state; return array($event_info); } } } return array(); }
public static function deamon() { $xplinstance = XPLInstance::getXPLInstance(); $eventReturn = $xplinstance->doEvents(); if ($eventReturn == 1) { xPL::proccessMessageEvent($xplinstance->getMessage()); } }
private function processHeartBeat($message) { if ($message->messageSchemeIdentifier() == 'hbeat.request') { $this->sendHeartbeat(); return true; } foreach ($this->devices as $key => $device) { if ($device->deviceName() == $message->source()) { if (substr($message->messageSchemeIdentifier(), -3) == 'end') { log::add('xpl', 'info', 'Device removed: ' . $message->source()); unset($this->devices[$key]); xPL::removedDeviceFromxPLNetwork($device->deviceName()); return true; } else { $device->setLastHeartBeat(time()); $device->setHeartBeatInterval($message->bodyItem('interval')); } return true; } } if (substr($message->messageSchemeIdentifier(), -3) != 'app' && substr($message->messageSchemeIdentifier(), -5) != 'basic') { //Not a heartbeat return false; } $device = new xPLDevice($message->source()); $device->setHeartBeatInterval($message->bodyItem('interval')); $device->setLastHeartBeat(time()); if ($message->messageSchemeIdentifier() == 'hbeat.app') { $device->setAddress($message->bodyItem('remote-ip')); $device->setPort($message->bodyItem('port')); } $this->devices[] = $device; xPL::newDeviceFromxPLNetwork($message->source()); return true; }