int CGXDLMSDemandRegister::SetValue(int index, CGXDLMSVariant& value) { if (index == 1) { if (value.vt != DLMS_DATA_TYPE_OCTET_STRING || value.GetSize() != 6) { return ERROR_CODES_INVALID_PARAMETER; } memcpy(m_LN, &value.byteArr[0], 6); return ERROR_CODES_OK; } else if (index == 2) { SetCurrentAvarageValue(value.lVal); } else if (index == 3) { SetLastAvarageValue(value); } else if (index == 4) { m_Scaler = value.Arr[0].bVal; m_Unit = value.Arr[1].bVal; } else if (index == 5) { SetStatus(value.lVal); } else if (index == 6) { CGXDLMSVariant tmp; CGXDLMSClient::ChangeType(value.byteArr, DLMS_DATA_TYPE_DATETIME, tmp); SetCaptureTime(tmp.dateTime); } else if (index == 7) { CGXDLMSVariant tmp; CGXDLMSClient::ChangeType(value.byteArr, DLMS_DATA_TYPE_DATETIME, tmp); SetStartTimeCurrent(tmp.dateTime); } else if (index == 8) { SetPeriod(value.ulVal); } else if (index == 9) { SetNumberOfPeriods(value.lVal); } else { return ERROR_CODES_INVALID_PARAMETER; } return ERROR_CODES_OK; }
///Parse a line void ribi::gtst::ParametersGroupReAssign::Parse(const std::string& s) { if (s.size() > 9 && s.substr(0,9) == "duration=") { const std::string t = s.substr(9,s.size()-9); try { std::stoi(t); } catch (std::exception&) { throw std::runtime_error("group_reassign_duration must be an integer"); } const int time = std::stoi(t); if (time < 0) throw std::runtime_error("group_reassign_duration must be zero or posive"); SetDuration(time); return; } else if (s.size() > 18 && s.substr(0,18) == "number_of_periods=") { const std::string t = s.substr(18,s.size()-18); try { std::stoi(t); } catch (std::exception&) { throw std::runtime_error("group_reassign_number_of_periods must be an integer"); } const int n_periods = std::stoi(t); if (n_periods < 0) throw std::runtime_error("group_reassign_number_of_periods must be zero or posive"); SetNumberOfPeriods(n_periods); return; } else if (s.size() > 28 && s.substr(0,28) == "next_period_payoff_function=") { static_assert(sizeof("next_period_payoff_function=") == 28 + 1,"Assume size 28"); const std::string t = s.substr(28,s.size()-28); FunctionParser f; //Parse the formula f.Parse(t,"p"); if (f.GetParseErrorType()!= FunctionParser::FP_NO_ERROR) { throw std::runtime_error("group_reassign_next_period_payoff_function could not be parsed, use for example \'sqrt(p)+10\'"); } SetNextPeriodPayoffFunction(t); return; } throw std::runtime_error( (std::string("Unparsable parameter file line: group_reassign_") + s).c_str()); }