protected static function createConnector() { $logger = LoggerFactory::getTestLogger(); //return new TcpClientConnector($logger, 'tcp', '192.168.101.212', '1040'); //return new TcpClientConnector($logger, 'tcp', 'localhost', '89'); return new TcpClientConnector($logger, 'tcp', '192.168.101.191', '1039'); }
public function test_PrepareDataPair_EmptySnowDepth() { $handler = new SnowDepthAwsDlm13mSensorHandler(LoggerFactory::getTestLogger()); $handler->incoming_sensor_value = '14MMMMMMMM'; $handler->sensor_features_info = array(); $this->assertTrue($handler->_prepareDataPairs()); $expected = array(array('feature_code' => 'snow_depth', 'period' => 1, 'value' => 'MMMMMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMMMMM', 'is_m' => 1), array('feature_code' => 'error_code', 'period' => 1, 'value' => '14', 'metric_id' => null, 'normilized_value' => '14', 'is_m' => 0)); $this->assertEquals(count($expected), count($handler->prepared_pairs)); $this->assertEquals($expected, $handler->prepared_pairs); }
public function test_PrepareDataPair_Empty10minAverage() { $handler = new VisibilityAWSSensorHandler(LoggerFactory::getTestLogger()); $handler->incoming_sensor_value = '16106MMMMMMMMMMMMMM'; $handler->sensor_features_info = array(); $this->assertTrue($handler->_prepareDataPairs()); $expected = array(array('feature_code' => 'visibility_1', 'period' => 1, 'value' => '16106', 'metric_id' => null, 'normilized_value' => '16106', 'is_m' => 0), array('feature_code' => 'visibility_10', 'period' => 10, 'value' => 'MMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMM', 'is_m' => 1)); $this->assertEquals(count($expected), count($handler->prepared_pairs)); $this->assertEquals($expected, $handler->prepared_pairs); }
public function test_PrepareDataPairs_Empty1minAverage_TakeValueFromExtinctionCoeff() { $handler = new VisibilityAwsDlm13mSensorHandler(LoggerFactory::getTestLogger()); $handler->incoming_sensor_value = 'MMMMM16060M001.00-ERR-'; $handler->sensor_features_info = array(); $this->assertTrue($handler->_prepareDataPairs()); $expected = array(array('feature_code' => 'extinction', 'period' => 1, 'value' => '001.00', 'metric_id' => null, 'normilized_value' => '001.00', 'is_m' => 0), array('feature_code' => 'visibility_1', 'period' => 1, 'value' => 3.0, 'metric_id' => null, 'normilized_value' => 3.0, 'is_m' => 1), array('feature_code' => 'visibility_10', 'period' => 10, 'value' => '16060', 'metric_id' => null, 'normilized_value' => '16060', 'is_m' => 0), array('feature_code' => 'status', 'period' => 1, 'value' => 'ERR', 'metric_id' => null, 'normilized_value' => 'ERR', 'is_m' => 0)); $this->assertEquals(count($expected), count($handler->prepared_pairs)); $this->assertEquals($expected, $handler->prepared_pairs); }
public function test_PrepareDataPairs_EmptyValues() { $handler = new CloudHeightAWSSensorHandler(LoggerFactory::getTestLogger()); $handler->incoming_sensor_value = 'MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM'; $handler->sensor_features_info = array(); $this->assertTrue($handler->_prepareDataPairs()); $expected = array(array('feature_code' => 'cloud_height_height_1', 'period' => 1, 'value' => 'MMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMM', 'is_m' => 1), array('feature_code' => 'cloud_height_depth_1', 'period' => 1, 'value' => 'MMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMM', 'is_m' => 1), array('feature_code' => 'cloud_height_height_2', 'period' => 1, 'value' => 'MMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMM', 'is_m' => 1), array('feature_code' => 'cloud_height_depth_2', 'period' => 1, 'value' => 'MMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMM', 'is_m' => 1), array('feature_code' => 'cloud_height_height_3', 'period' => 1, 'value' => 'MMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMM', 'is_m' => 1), array('feature_code' => 'cloud_height_depth_3', 'period' => 1, 'value' => 'MMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMM', 'is_m' => 1), array('feature_code' => 'cloud_vertical_visibility', 'period' => 1, 'value' => 'MMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMM', 'is_m' => 1), array('feature_code' => 'cloud_measuring_range', 'period' => 1, 'value' => 'MMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMM', 'is_m' => 1)); $this->assertEquals(count($expected), count($handler->prepared_pairs)); $this->assertEquals($expected, $handler->prepared_pairs); }
public function test_PrepareDataPairs_WithCloudAmounts_SomeEmptyValues() { $handler = new CloudHeightAwsDlm13mSensorHandler(LoggerFactory::getTestLogger()); $handler->incoming_sensor_value = 's66551234567890543210987632154879601000050000-100350,//////,304350,//////,7-'; $handler->sensor_features_info = array(); $this->assertTrue($handler->_prepareDataPairs()); $expected = array(array('feature_code' => 'status', 'period' => 1, 'value' => '6655', 'metric_id' => null, 'normilized_value' => '6655', 'is_m' => 0), array('feature_code' => 'cloud_height_height_1', 'period' => 1, 'value' => '12345', 'metric_id' => null, 'normilized_value' => '12345', 'is_m' => 0), array('feature_code' => 'cloud_height_depth_1', 'period' => 1, 'value' => '67890', 'metric_id' => null, 'normilized_value' => '67890', 'is_m' => 0), array('feature_code' => 'cloud_height_height_2', 'period' => 1, 'value' => '54321', 'metric_id' => null, 'normilized_value' => '54321', 'is_m' => 0), array('feature_code' => 'cloud_height_depth_2', 'period' => 1, 'value' => '09876', 'metric_id' => null, 'normilized_value' => '09876', 'is_m' => 0), array('feature_code' => 'cloud_height_height_3', 'period' => 1, 'value' => '32154', 'metric_id' => null, 'normilized_value' => '32154', 'is_m' => 0), array('feature_code' => 'cloud_height_depth_3', 'period' => 1, 'value' => '87960', 'metric_id' => null, 'normilized_value' => '87960', 'is_m' => 0), array('feature_code' => 'cloud_vertical_visibility', 'period' => 1, 'value' => '10000', 'metric_id' => null, 'normilized_value' => '10000', 'is_m' => 0), array('feature_code' => 'cloud_measuring_range', 'period' => 1, 'value' => '50000', 'metric_id' => null, 'normilized_value' => '50000', 'is_m' => 0), array('feature_code' => 'cloud_amount_amount_1', 'period' => 30, 'value' => '1', 'metric_id' => null, 'normilized_value' => '1', 'is_m' => 0), array('feature_code' => 'cloud_amount_height_1', 'period' => 30, 'value' => '350', 'metric_id' => null, 'normilized_value' => '350', 'is_m' => 0), array('feature_code' => 'cloud_amount_amount_2', 'period' => 30, 'value' => '', 'metric_id' => null, 'normilized_value' => '', 'is_m' => 1), array('feature_code' => 'cloud_amount_height_2', 'period' => 30, 'value' => '', 'metric_id' => null, 'normilized_value' => '', 'is_m' => 1), array('feature_code' => 'cloud_amount_amount_3', 'period' => 30, 'value' => '3', 'metric_id' => null, 'normilized_value' => '3', 'is_m' => 0), array('feature_code' => 'cloud_amount_height_3', 'period' => 30, 'value' => '04350', 'metric_id' => null, 'normilized_value' => '04350', 'is_m' => 0), array('feature_code' => 'cloud_amount_amount_4', 'period' => 30, 'value' => '', 'metric_id' => null, 'normilized_value' => '', 'is_m' => 1), array('feature_code' => 'cloud_amount_height_4', 'period' => 30, 'value' => '', 'metric_id' => null, 'normilized_value' => '', 'is_m' => 1), array('feature_code' => 'cloud_amount_amount_total', 'period' => 30, 'value' => '7', 'metric_id' => null, 'normilized_value' => '7', 'is_m' => 0)); $this->assertEquals(count($expected), count($handler->prepared_pairs)); $this->assertEquals($expected, $handler->prepared_pairs); }
public function testConnect_ErrorOnRead_NoErrors() { $logger = LoggerFactory::getTestLogger(); $logger->log(__METHOD__); $serial = new Stub(array('functions' => array('deviceSet' => array('return' => true), 'deviceOpen' => array('return' => true), 'readPort' => array('return' => "String1\r\nString2\r\nString3\r\n")), 'attributes' => array('_dHandle' => STDOUT))); $connector = new GsmModemSerialConnector($logger, $serial); $connector->setParams(array('port' => 'COM#')); $output = null; $result = $connector->readData($output); $expected = array('String1', 'String2', 'String3'); $this->assertTrue($result); $this->assertEquals($expected, $output); $errors = $connector->errors(); $this->assertEquals(0, count($errors)); }
public function test_ParseSensorPairs_RgMessage_WithUnknownValuesOld() { $message = '@DSYD01111105200800WS1301350200MMMMRN1001000000000000BV1120SR1001057001057003SD10010000000TP10050HU1000TP20301TP30106WD13360360360PR117500SL1MMMMMMMMMMMM4683A14B$'; $message = substr($message, 19, -9); $processMessage = new ProcessMessageWrapper(LoggerFactory::getTestLogger(), null); $result = $processMessage->parseSensorsValuesOldPublic($message); $expected = array(array('WS1', '301350200MMMM'), array('RN1', '001000000000000'), array('BV1', '120'), array('SR1', '001057001057003'), array('SD1', '0010000000'), array('TP1', '0050'), array('HU1', '000'), array('TP2', '0301'), array('TP3', '0106'), array('WD1', '3360360360'), array('PR1', '17500'), array('SL1', 'MMMMMMMMMMMM')); $this->assertEquals(count($expected), count($result)); $this->assertEquals($expected, $result); }
public function test_WriteAdditiveData() { $report = new MetarWeatherReportWrapper(LoggerFactory::getTestLogger()); $report->setSection(0); $report->setSubSection(0); $report->writeAdditiveDataPublic(); $parts = null; $this->assertEquals($parts, $report->report_parts); $explanations = null; $this->assertEquals($explanations, $report->explanations); }
public function testConnect_ErrorOnRead() { $logger = LoggerFactory::getTestLogger(); $logger->log(__METHOD__); $serial = new Stub(array('functions' => array('deviceSet' => array('return' => true), 'deviceOpen' => array('return' => true), 'readString' => array('return' => false)), 'attributes' => array('_dHandle' => STDOUT))); $connector = new DataLoggerSerialConnector($logger, $serial); $connector->setParams(array('port' => 'COM#')); $output = null; $result = $connector->readData($output); $this->assertFalse($result); $this->assertNull($output); $errors = $connector->errors(); $this->assertEquals(1, count($errors)); $this->assertEquals('Error during read message', $errors[0]); }
public function test_Run_AWS1Station_NoErrors() { $listenerLog = $this->createBlankMessage(); $listenerLog->message = '@DAWS01000101001900WS13000000000000RN1001007000009500BV1120SR1001000000000000SD10010000000TP10060HU1000TP20431TP30391WD13001001001PR116150693D2856$'; $listenerLog->station_id = 1; $listenerLog->save(); $processMessage = new ProcessMessage(LoggerFactory::getTestLogger(), $listenerLog); $processMessage->run(); $this->assertEquals(0, count($processMessage->warnings)); $this->assertEquals(0, count($processMessage->errors)); }