本文整理汇总了C++中CGXDLMSVariant类的典型用法代码示例。如果您正苦于以下问题:C++ CGXDLMSVariant类的具体用法?C++ CGXDLMSVariant怎么用?C++ CGXDLMSVariant使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CGXDLMSVariant类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetValue
// Set value of given attribute.
int CGXDLMSMBusSlavePortSetup::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);
}
else if (index == 2)
{
m_DefaultBaud = (BAUDRATE) value.ToInteger();
}
else if (index == 3)
{
m_AvailableBaud = (BAUDRATE) value.ToInteger();
}
else if (index == 4)
{
m_AddressState = (ADDRESS_STATE) value.ToInteger();
}
else if (index == 5)
{
m_BusAddress = value.ToInteger();
}
else
{
return ERROR_CODES_INVALID_PARAMETER;
}
return ERROR_CODES_OK;
}
示例2: AddRegisterMonitor
/*
* Add Register Monitor object.
*/
void AddRegisterMonitor(CGXDLMSObjectCollection& items, CGXDLMSRegister* pRegister)
{
CGXDLMSRegisterMonitor* pRm = new CGXDLMSRegisterMonitor("0.0.16.1.0.255");
CGXDLMSVariant threshold;
vector<CGXDLMSVariant> thresholds;
threshold.Add("Gurux1", 6);
thresholds.push_back(threshold);
threshold.Clear();
threshold.Add("Gurux2", 6);
thresholds.push_back(threshold);
pRm->SetThresholds(thresholds);
CGXDLMSMonitoredValue mv;
mv.Update(pRegister, 2);
pRm->SetMonitoredValue(mv);
CGXDLMSActionSet * action = new CGXDLMSActionSet();
string ln;
pRm->GetLogicalName(ln);
action->GetActionDown().SetLogicalName(ln);
action->GetActionDown().SetScriptSelector(1);
pRm->GetLogicalName(ln);
action->GetActionUp().SetLogicalName(ln);
action->GetActionUp().SetScriptSelector(1);
pRm->GetActions().push_back(action);
items.push_back(pRm);
}
示例3: GetData
int CGXDLMSProfileGeneric::GetProfileGenericData(int selector, CGXDLMSVariant& parameters, CGXByteBuffer& reply)
{
//If all data is read.
if (selector == 0 || parameters.vt == DLMS_DATA_TYPE_NONE)
{
return GetData(GetBuffer(), reply);
}
std::vector< std::vector<CGXDLMSVariant> >& table = GetBuffer();
std::vector< std::vector<CGXDLMSVariant> > items;
if (selector == 1) //Read by range
{
int ret;
CGXDLMSVariant value;
if ((ret = CGXDLMSClient::ChangeType(parameters.Arr[1], DLMS_DATA_TYPE_DATETIME, value)) != 0)
{
return ret;
}
struct tm tmp = value.dateTime.GetValue();
time_t start = mktime(&tmp);
value.Clear();
if ((ret = CGXDLMSClient::ChangeType(parameters.Arr[2], DLMS_DATA_TYPE_DATETIME, value)) != 0)
{
return ret;
}
tmp = value.dateTime.GetValue();
time_t end = mktime(&tmp);
value.Clear();
for (std::vector< std::vector<CGXDLMSVariant> >::iterator row = table.begin(); row != table.end(); ++row)
{
tmp = (*row)[0].dateTime.GetValue();
time_t tm = mktime(&tmp);
if (tm >= start && tm <= end)
{
items.push_back(*row);
}
}
}
else if (selector == 2) //Read by entry.
{
int start = parameters.Arr[0].ToInteger();
int count = parameters.Arr[1].ToInteger();
for (int pos = 0; pos < count; ++pos)
{
if ((unsigned int) (pos + start) == table.size())
{
break;
}
items.push_back(table[start + pos]);
}
}
else
{
return DLMS_ERROR_CODE_INVALID_PARAMETER;
}
return GetData(items, reply);
}
示例4: memcpy
// Set value of given attribute.
int CGXDLMSGPRSSetup::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)
{
if (value.vt == DLMS_DATA_TYPE_STRING)
{
m_APN = value.ToString();
}
else
{
CGXDLMSVariant tmp;
int ret;
if ((ret = CGXDLMSClient::ChangeType(value.byteArr, DLMS_DATA_TYPE_STRING, tmp)) != 0)
{
return ret;
}
m_APN = tmp.strVal;
}
value = m_APN;
}
else if (index == 3)
{
m_PINCode = value.uiVal;
}
else if (index == 4)
{
m_DefaultQualityOfService.SetPrecedence(value.Arr[0].Arr[0].iVal);
m_DefaultQualityOfService.SetDelay(value.Arr[0].Arr[1].iVal);
m_DefaultQualityOfService.SetReliability(value.Arr[0].Arr[2].iVal);
m_DefaultQualityOfService.SetPeakThroughput(value.Arr[0].Arr[3].iVal);
m_DefaultQualityOfService.SetMeanThroughput(value.Arr[0].Arr[4].iVal);
m_RequestedQualityOfService.SetPrecedence(value.Arr[1].Arr[0].iVal);
m_RequestedQualityOfService.SetDelay(value.Arr[1].Arr[1].iVal);
m_RequestedQualityOfService.SetReliability(value.Arr[1].Arr[2].iVal);
m_RequestedQualityOfService.SetPeakThroughput(value.Arr[1].Arr[3].iVal);
m_RequestedQualityOfService.SetMeanThroughput(value.Arr[1].Arr[4].iVal);
}
else
{
return ERROR_CODES_INVALID_PARAMETER;
}
return ERROR_CODES_OK;
}
示例5: AddLogicalDeviceName
///////////////////////////////////////////////////////////////////////
//Add Logical Device Name. 123456 is meter serial number.
///////////////////////////////////////////////////////////////////////
// COSEM Logical Device Name is defined as an octet-string of 16 octets.
// The first three octets uniquely identify the manufacturer of the device and it corresponds
// to the manufacturer's identification in IEC 62056-21.
// The following 13 octets are assigned by the manufacturer.
//The manufacturer is responsible for guaranteeing the uniqueness of these octets.
CGXDLMSData* AddLogicalDeviceName(CGXDLMSObjectCollection& items, unsigned long sn)
{
char buff[17];
#if defined(_WIN32) || defined(_WIN64)//Windows
sprintf_s(buff, "GRX%.13d", sn);
#else
sprintf(buff, "GRX%.13d", sn);
#endif
CGXDLMSVariant id;
id.Add((const char*)buff, 16);
CGXDLMSData* ldn = new CGXDLMSData("0.0.42.0.0.255");
ldn->SetValue(id);
items.push_back(ldn);
return ldn;
}
示例6: AddElectricityID1
/*
* Add Electricity ID 1.
*/
void AddElectricityID1(CGXDLMSObjectCollection& items, unsigned long sn)
{
char buff[17];
#if defined(_WIN32) || defined(_WIN64)//Windows
sprintf_s(buff, "GRX%.13d", sn);
#else
sprintf(buff, "GRX%.13d", sn);
#endif
CGXDLMSVariant id;
id.Add((const char*)buff, 16);
CGXDLMSData* d = new CGXDLMSData("1.1.0.0.0.255");
d->SetValue(id);
d->GetAttributes().push_back(CGXDLMSAttribute(2, DLMS_DATA_TYPE_STRING));
items.push_back(d);
}
示例7: memcpy
// Set value of given attribute.
int CGXDLMSMessageHandler::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);
}
else if (index == 2)
{
m_ListeningWindow.clear();
if (value.vt == DLMS_DATA_TYPE_ARRAY)
{
for(vector<CGXDLMSVariant>::iterator it = value.Arr.begin(); it != value.Arr.end(); ++it)
{
CGXDLMSVariant tmp;
CGXDLMSClient::ChangeType(it->Arr[0].byteArr, DLMS_DATA_TYPE_DATETIME, tmp);
CGXDateTime start = tmp.dateTime;
CGXDLMSClient::ChangeType(it->Arr[1].byteArr, DLMS_DATA_TYPE_DATETIME, tmp);
CGXDateTime end = tmp.dateTime;
m_ListeningWindow.push_back(std::pair<CGXDateTime, CGXDateTime>(start, end));
}
}
}
else if (index == 3)
{
m_AllowedSenders.clear();
if (value.vt == DLMS_DATA_TYPE_ARRAY)
{
for(vector<CGXDLMSVariant>::iterator it = value.Arr.begin(); it != value.Arr.end(); ++it)
{
m_AllowedSenders.push_back((char*) &it->byteArr[0]);
}
}
}
else if (index == 4)
{
m_SendersAndActions.clear();
if (value.vt == DLMS_DATA_TYPE_ARRAY)
{
for(vector<CGXDLMSVariant>::iterator it = value.Arr.begin(); it != value.Arr.end(); ++it)
{
string id((char*) &it->Arr[0].byteArr[0]);
//Object[] tmp2 = (Object[]) tmp[1];
/*TODO:
KeyValuePair<int, GXDLMSScriptAction> executed_script = new KeyValuePair<int, GXDLMSScriptAction>(Convert.ToInt32(tmp2[1], tmp2[2]));
m_SendersAndActions.Add(new KeyValuePair<string, KeyValuePair<int, GXDLMSScriptAction>>(id, tmp[1] as GXDateTime));
* */
}
}
}
else
{
return ERROR_CODES_INVALID_PARAMETER;
}
return ERROR_CODES_OK;
}
示例8: memcpy
// Set value of given attribute.
int CGXDLMSSpecialDaysTable::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);
}
else if (index == 2)
{
m_Entries.clear();
if (value.vt == DLMS_DATA_TYPE_ARRAY)
{
CGXDLMSVariant tmp;
for (vector<CGXDLMSVariant>::iterator item = value.Arr.begin(); item != value.Arr.end(); ++item)
{
CGXDLMSSpecialDay it;
it.SetIndex((*item).Arr[0].ToInteger());
CGXDLMSClient::ChangeType((*item).Arr[1].byteArr, DLMS_DATA_TYPE_DATE, tmp);
it.SetDate(tmp.dateTime);
it.SetDayId((*item).Arr[2].ToInteger());
m_Entries.push_back(it);
}
}
}
else
{
return ERROR_CODES_INVALID_PARAMETER;
}
return ERROR_CODES_OK;
}
示例9: SetLogicalName
int CGXDLMSRegister::SetValue(CGXDLMSSettings* settings, int index, CGXDLMSVariant& value)
{
if (index == 1)
{
return SetLogicalName(this, value);
}
else if (index == 2)
{
if (m_Scaler != 0)
{
double val = GetScaler();
val *= value.ToDouble();
CGXDLMSVariant tmp(val);
SetValue(tmp);
}
else
{
SetValue(value);
}
}
else if (index == 3 && value.vt == DLMS_DATA_TYPE_STRUCTURE)
{
m_Scaler = value.Arr[0].ToInteger();
m_Unit = value.Arr[1].ToInteger();
}
else
{
return ERROR_CODES_INVALID_PARAMETER;
}
return ERROR_CODES_OK;
}
示例10: SetLogicalName
int CGXDLMSObject::SetLogicalName(CGXDLMSObject * target, CGXDLMSVariant& value)
{
if (value.vt != DLMS_DATA_TYPE_OCTET_STRING || value.GetSize() != 6)
{
return ERROR_CODES_INVALID_PARAMETER;
}
memcpy(target->m_LN, value.byteArr, 6);
return ERROR_CODES_OK;
}
示例11: SetValue
// Set value of given attribute.
int CGXDLMSHdlcSetup::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);
}
else if (index == 2)
{
m_CommunicationSpeed = (BAUDRATE) value.ToInteger();
}
else if (index == 3)
{
m_WindowSizeTransmit = value.ToInteger();
}
else if (index == 4)
{
m_WindowSizeReceive = value.ToInteger();
}
else if (index == 5)
{
m_MaximumInfoLengthTransmit = value.ToInteger();
}
else if (index == 6)
{
m_MaximumInfoLengthReceive = value.ToInteger();
}
else if (index == 7)
{
m_InterCharachterTimeout = value.ToInteger();
}
else if (index == 8)
{
m_InactivityTimeout = value.ToInteger();
}
else if (index == 9)
{
m_DeviceAddress = value.ToInteger();
}
else
{
return ERROR_CODES_INVALID_PARAMETER;
}
return ERROR_CODES_OK;
}
示例12: GetValue
// Returns value of given attribute.
int CGXDLMSActionSchedule::GetValue(int index, unsigned char* parameters, int length, CGXDLMSVariant& value)
{
if (index == 1)
{
GXHelpers::AddRange(value.byteArr, m_LN, 6);
value.vt = DLMS_DATA_TYPE_OCTET_STRING;
return ERROR_CODES_OK;
}
if (index == 2)
{
vector<unsigned char> stream;
stream.push_back(DLMS_DATA_TYPE_STRUCTURE);
stream.push_back(2);
CGXDLMSVariant tmp;
tmp.Add(GetExecutedScriptLogicalName());
CGXOBISTemplate::SetData(stream, DLMS_DATA_TYPE_OCTET_STRING, tmp);
CGXOBISTemplate::SetData(stream, DLMS_DATA_TYPE_UINT16, GetExecutedScriptSelector());
value = stream;
return ERROR_CODES_OK;
}
if (index == 3)
{
value = GetType();
return ERROR_CODES_OK;
}
if (index == 4)
{
vector<unsigned char> stream;
stream.push_back(DLMS_DATA_TYPE_ARRAY);
CGXOBISTemplate::SetObjectCount(GetExecutionTime().size(), stream);
for (vector<CGXDateTime>::iterator it = m_ExecutionTime.begin(); it != m_ExecutionTime.end(); ++it)
{
stream.push_back(DLMS_DATA_TYPE_STRUCTURE);
stream.push_back(2); //Count
CGXOBISTemplate::SetData(stream, DLMS_DATA_TYPE_TIME, *it); //Time
CGXOBISTemplate::SetData(stream, DLMS_DATA_TYPE_DATE, *it); //Date
}
value = stream;
return ERROR_CODES_OK;
}
return ERROR_CODES_INVALID_PARAMETER;
}
示例13: SetValue
// Set value of given attribute.
int CGXDLMSMBusMasterPortSetup::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);
}
else if (index == 2)
{
m_CommSpeed = (BAUDRATE) value.ToInteger();
}
else
{
return ERROR_CODES_INVALID_PARAMETER;
}
return ERROR_CODES_OK;
}
示例14: memcpy
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;
}
示例15: memcpy
int CGXDLMSAssociationShortName::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)
{
m_ObjectList.clear();
if (value.vt == DLMS_DATA_TYPE_ARRAY)
{
for(vector<CGXDLMSVariant>::iterator item = value.Arr.begin(); item != value.Arr.end(); ++item)
{
int sn = item->Arr[0].ToInteger();
CGXDLMSObject* pObj = GetParent()->FindBySN(sn);
if (pObj == NULL)
{
OBJECT_TYPE type = (OBJECT_TYPE) item->Arr[1].ToInteger();
int version = item->Arr[2].ToInteger();
string ln;
CGXOBISTemplate::GetLogicalName(&(*item).Arr[3].byteArr[0], ln);
pObj = CGXDLMSObjectFactory::CreateObject(type);
pObj->SetLogicalName(ln);
pObj->SetShortName(sn);
pObj->SetVersion(version);
}
m_ObjectList.push_back(pObj);
}
}
}
else if (index == 3)
{
if (value.vt == DLMS_DATA_TYPE_NONE)
{
for(vector<CGXDLMSObject*>::iterator it = m_ObjectList.begin(); it != m_ObjectList.end(); ++it)
{
for(int pos = 1; pos != (*it)->GetAttributeCount(); ++pos)
{
(*it)->SetAccess(pos, ACCESSMODE_NONE);
}
}
}
else
{
UpdateAccessRights(value);
}
}
return ERROR_CODES_INVALID_PARAMETER;
}