parse('log4php.xml'); } elseif(is_file('log4php.properties')) { $configurator = new LoggerConfiguratorDefault(); $config = $configurator->parse('log4php.properties'); } else { $config = LoggerConfiguratorDefault::getDefaultConfiguration(); } Logger::configure($config); $sql = new PDO('sqlite:ism7_values.db'); $sql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql->exec('CREATE TABLE IF NOT EXISTS history ( date INT, infonumber INT, value INT );'); $conn = new ISM7_Connection($host, $port); $logonreq = new ISM7_DirectLogonRequest($pass); $logonres = $conn->communicate($logonreq); var_dump($logonres); $confreq = new ISM7_ReadSystemconfigRequest(); $confres = $conn->communicate($confreq); var_dump($confres); $infonumbers = array( array('A;12', '0x8', '370', 'unknown 1'), array('A;13', '0x8', '371', 'unknown 2'), array('A;8', '0x8', '13', 'temp.heater', 10, '°C'), # heater temperature array('A;9', '0x8', '14', 'temp.water', 10, '°C'), # water temperature array('A;10', '0x8', '22', 'temp.return', 10, '°C'), # return temperature array('A;11', '0x8', '367', 'unknown 3'), array('C;14;551;550', '0x8', '551', 'unknown 4'), array('C;14;551;550', '0x8', '550', 'unknown 5'), # heater on times array('A;15', '0x8', '554', 'unknown 6'), # time heater on? array('A;16', '0x8', '10010', 'pressure', 100, 'bar'), # pressure array('A;17', '0x8', '10071', 'unknown 7'), array('A;18', '0x8', '328', 'unknown 8'), array('A;19', '0x8', '10067', 'unknown 9'), array('A;20', '0x8', '10068', 'unknown 10'), array('A;21', '0x8', '2', 'unknown 11'), array('A;22', '0x8', '3', 'temp.water.target', 10, '°C'), array('A;23', '0x35', '10150', 'unknown 12'), array('A;24', '0x35', '10145', 'unknown 13'), array('A;75', '0x35', '10164', 'temp.int', 10, '°C'), # internal temperature array('A;76', '0x35', '10179', 'temp.ext', 10, '°C'), # external temperature (averaged) array('A;77', '0x35', '10165', 'unknown 14'), array('A;78', '0x35', '10100', 'unknown 15'), array('A;79', '0x35', '10155', 'unknown 16'), array('A;80', '0x35', '10156', 'unknown 17'), array('A;81', '0x35', '10119', 'temp.heater2', 10, '°C'), # t kotła? ); $mapping = array(); $inforeq = new ISM7_TelegramBundleRequest(30000, 1, TRUE, 'push'); foreach($infonumbers as $infonumber) { $i = new ISM7_Telegram_InfonumberRead($infonumber[0], hexdec($infonumber[1]), $infonumber[2], 60); $inforeq->append($i); $mapping[$infonumber[2]] = $infonumber; $current[$infonumber[2]] = NULL; } $infores = $conn->communicate($inforeq); var_dump($infores); processResponse($infores); function processResponse($infores) { global $infonumbers, $mapping, $current, $sql; $time = gmmktime(); foreach($infores as $infonumber) { $info = $mapping[$infonumber->infonumber]; $value = $infonumber->value; $current[$infonumber->infonumber] = $value; if(!isset($info[3])) { continue; } if(isset($info[4])) { $value = bcdiv($value, $info[4], 2); } $unit = ''; if(isset($info[5])) { $unit = $info[5]; } echo $info[3]."\t".$value.' '.$unit."\n"; } $sql->beginTransaction(); $query = $sql->prepare('INSERT INTO history (date, infonumber, value) VALUES (?, ?, ?)'); foreach($current as $inumber => $value) { $query->execute(array($time, $inumber, $value)); } $sql->commit(); } while(TRUE) { $infores = $conn->wait(); processResponse($infores); } $conn->close();