test/test_meter_conn_worker/meter_worker_produce_data.cpp
void meter_connector_work_full_data_idle_incomplete_only_second_half(void) {
  // Given
  StreamString meter_stream;
  meter_stream.print(
      // ... "missing" the first half of the complete telegram message
      "1-0:99.97.0(4)(0-0:96.7.19)(180619133556S)(0000000314*s)(180219134256W)(0000000633*s)(180219133039W)(0000007917*s)(160704090617S)(0000004176*s)\r\n"
      "1-0:32.32.0(00000)\r\n"
      "1-0:32.36.0(00000)\r\n"
      "0-0:96.13.1()\r\n"
      "0-0:96.13.0()\r\n"
      "1-0:31.7.0(001*A)\r\n"
      "1-0:21.7.0(00.276*kW)\r\n"
      "1-0:22.7.0(00.000*kW)\r\n"
      "0-1:24.1.0(003)\r\n"
      "0-1:96.1.0(4730303139333430323834343236393136)\r\n"
      "0-1:24.2.1(200727150000S)(06044.581*m3)\r\n"
      "!1627\r\n");

  SmartMeterConnector meter_connector(meter_stream);
  meter_connector.set_active(true);

  // When
  bool result = meter_connector.work();

  // Then
  TEST_ASSERT_FALSE(result);
  TEST_ASSERT_EQUAL(meter_connector.get_status(), SmartMeterConnector::Status::e_worker_idle);

  const P1Data& data = meter_connector.get_data();
  // data is still empty, it only starts gathering after the header line is read
  TEST_ASSERT_EQUAL(P1Data::k_p1_empty, data.get_status());
}
/**
 * Test parsing of an incomplete reading only received second half
 */
Test parsing of an incomplete reading only received second half
Test parsing of an incomplete reading only received second half
void meter_connector_work_full_data_idle_incomplete_only_second_half(void) {
  StreamString meter_stream;
  meter_stream.print(
      "1-0:99.97.0(4)(0-0:96.7.19)(180619133556S)(0000000314*s)(180219134256W)(0000000633*s)(180219133039W)(0000007917*s)(160704090617S)(0000004176*s)\r\n"
      "1-0:32.32.0(00000)\r\n"
      "1-0:32.36.0(00000)\r\n"
      "0-0:96.13.1()\r\n"
      "0-0:96.13.0()\r\n"
      "1-0:31.7.0(001*A)\r\n"
      "1-0:21.7.0(00.276*kW)\r\n"
      "1-0:22.7.0(00.000*kW)\r\n"
      "0-1:24.1.0(003)\r\n"
      "0-1:96.1.0(4730303139333430323834343236393136)\r\n"
      "0-1:24.2.1(200727150000S)(06044.581*m3)\r\n"
      "!1627\r\n");
  SmartMeterConnector meter_connector(meter_stream);
  meter_connector.set_active(true);
  bool result = meter_connector.work();
  TEST_ASSERT_FALSE(result);
  TEST_ASSERT_EQUAL(meter_connector.get_status(), SmartMeterConnector::Status::e_worker_idle);
  const P1Data& data = meter_connector.get_data();
  TEST_ASSERT_EQUAL(P1Data::k_p1_empty, data.get_status());
}
void meter_connector_work_full_data_idle_incomplete_only_second_half ( void ) { StreamString meter_stream ; meter_stream . print ( " \r \n " " \r \n " " \r \n " " \r \n " " \r \n " " \r \n " " \r \n " " \r \n " " \r \n " " \r \n " " \r \n " " \r \n " ) ; SmartMeterConnector meter_connector ( meter_stream ) ; meter_connector . set_active ( true ) ; bool result = meter_connector . work ( ) ; TEST_ASSERT_FALSE ( result ) ; TEST_ASSERT_EQUAL ( meter_connector . get_status ( ) , SmartMeterConnector :: Status :: e_worker_idle ) ; const P1Data & data = meter_connector . get_data ( ) ; TEST_ASSERT_EQUAL ( P1Data :: k_p1_empty , data . get_status ( ) ) ; }
Test parsing of an incomplete reading only received second half
Test parsing of an incomplete reading only received second half
// Given // ... "missing" the first half of the complete telegram message // When // Then // data is still empty, it only starts gathering after the header line is read