本文整理汇总了C++中CGXDLMSVariant::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ CGXDLMSVariant::Clear方法的具体用法?C++ CGXDLMSVariant::Clear怎么用?C++ CGXDLMSVariant::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGXDLMSVariant
的用法示例。
在下文中一共展示了CGXDLMSVariant::Clear方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetProfileGenericData
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);
}
示例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: GetValue
int CGXDLMSDemandRegister::GetValue(int index, int selector, CGXDLMSVariant& parameters, 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)
{
value = GetCurrentAvarageValue();
return ERROR_CODES_OK;
}
if (index == 3)
{
value = GetLastAvarageValue();
return ERROR_CODES_OK;
}
if (index == 4)
{
value.Clear();
value.vt = DLMS_DATA_TYPE_STRUCTURE;
value.Arr.push_back(m_Scaler);
value.Arr.push_back(m_Unit);
return ERROR_CODES_OK;
}
if (index == 5)
{
value = GetStatus();
return ERROR_CODES_OK;
}
if (index == 6)
{
value = GetCaptureTime();
return ERROR_CODES_OK;
}
if (index == 7)
{
value = GetStartTimeCurrent();
return ERROR_CODES_OK;
}
if (index == 8)
{
value = GetPeriod();
return ERROR_CODES_OK;
}
if (index == 9)
{
value = GetNumberOfPeriods();
return ERROR_CODES_OK;
}
return ERROR_CODES_INVALID_PARAMETER;
}
示例4: GetValue
int CGXDLMSRegister::GetValue(int index, int selector, CGXDLMSVariant& parameters, CGXDLMSVariant& value)
{
if (index == 1)
{
return GetLogicalName(this, value);
}
if (index == 2)
{
value = m_Value;
return ERROR_CODES_OK;
}
if (index == 3)
{
value.Clear();
value.vt = DLMS_DATA_TYPE_STRUCTURE;
value.Arr.push_back(m_Scaler);
value.Arr.push_back(m_Unit);
return ERROR_CODES_OK;
}
return ERROR_CODES_INVALID_PARAMETER;
}
示例5: GetValue
int CGXDLMSExtendedRegister::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)
{
value = m_Value;
return ERROR_CODES_OK;
}
if (index == 3)
{
value.Clear();
value.vt = DLMS_DATA_TYPE_STRUCTURE;
value.Arr.push_back(m_Scaler);
value.Arr.push_back(m_Unit);
return ERROR_CODES_OK;
}
return ERROR_CODES_INVALID_PARAMETER;
}
示例6: ReadRowsByEntry
int CGXCommunication::ReadRowsByEntry(
CGXDLMSProfileGeneric* pObject,
unsigned int index,
unsigned int count,
CGXDLMSVariant& rows)
{
rows.Clear();
int ret;
std::vector<CGXByteBuffer> data;
CGXReplyData reply;
if ((ret = m_Parser->ReadRowsByEntry(pObject, index, count, data)) != 0 ||
(ret = ReadDataBlock(data, reply)) != 0 ||
(ret = m_Parser->UpdateValue(*pObject, 2, reply.GetValue())) != 0)
{
return ret;
}
//Get rows value as string.
//Note! This is for example. It's faster if you handle read COSEM object directly.
std::vector<std::string> values;
pObject->GetValues(values);
rows = values[2 - 1];
return DLMS_ERROR_CODE_OK;
}
示例7: GetValue
// Returns value of given attribute.
int CGXDLMSActivityCalendar::GetValue(int index, int selector, CGXDLMSVariant& parameters, CGXDLMSVariant& value)
{
CGXByteBuffer data;
if (index == 1)
{
return GetLogicalName(this, value);
}
if (index == 2)
{
value.Add(&m_CalendarNameActive[0], m_CalendarNameActive.size());
return ERROR_CODES_OK;
}
if (index == 3)
{
data.SetUInt8(DLMS_DATA_TYPE_ARRAY);
int cnt = m_SeasonProfileActive.size();
//Add count
GXHelpers::SetObjectCount(cnt, data);
CGXDLMSVariant tmp;
for (std::vector<CGXDLMSSeasonProfile>::iterator it = m_SeasonProfileActive.begin(); it != m_SeasonProfileActive.end(); ++it)
{
data.SetUInt8(DLMS_DATA_TYPE_STRUCTURE);
data.SetUInt8(3);
tmp = it->GetName();
GXHelpers::SetData(data, DLMS_DATA_TYPE_OCTET_STRING, tmp);
tmp = it->GetStart();
GXHelpers::SetData(data, DLMS_DATA_TYPE_OCTET_STRING, tmp);
tmp.Clear();
tmp.Add((*it).GetWeekName());
GXHelpers::SetData(data, DLMS_DATA_TYPE_OCTET_STRING, tmp);
}
value = data;
return ERROR_CODES_OK;
}
if (index == 4)
{
data.SetUInt8(DLMS_DATA_TYPE_ARRAY);
int cnt = m_WeekProfileTableActive.size();
//Add count
GXHelpers::SetObjectCount(cnt, data);
CGXDLMSVariant tmp;
for (std::vector<CGXDLMSWeekProfile>::iterator it = m_WeekProfileTableActive.begin(); it != m_WeekProfileTableActive.end(); ++it)
{
data.SetUInt8(DLMS_DATA_TYPE_ARRAY);
data.SetUInt8(8);
tmp = it->GetName();
GXHelpers::SetData(data, DLMS_DATA_TYPE_OCTET_STRING, tmp);
tmp = it->GetMonday();
GXHelpers::SetData(data, DLMS_DATA_TYPE_UINT8, tmp);
tmp = it->GetTuesday();
GXHelpers::SetData(data, DLMS_DATA_TYPE_UINT8, tmp);
tmp = it->GetWednesday();
GXHelpers::SetData(data, DLMS_DATA_TYPE_UINT8, tmp);
tmp = it->GetThursday();
GXHelpers::SetData(data, DLMS_DATA_TYPE_UINT8, tmp);
tmp = it->GetFriday();
GXHelpers::SetData(data, DLMS_DATA_TYPE_UINT8, tmp);
tmp = it->GetSaturday();
GXHelpers::SetData(data, DLMS_DATA_TYPE_UINT8, tmp);
tmp = it->GetSunday();
GXHelpers::SetData(data, DLMS_DATA_TYPE_UINT8, tmp);
}
value = data;
return ERROR_CODES_OK;
}
if (index == 5)
{
data.SetUInt8(DLMS_DATA_TYPE_ARRAY);
int cnt = m_DayProfileTableActive.size();
//Add count
GXHelpers::SetObjectCount(cnt, data);
for (std::vector<CGXDLMSDayProfile>::iterator it = m_DayProfileTableActive.begin(); it != m_DayProfileTableActive.end(); ++it)
{
data.SetUInt8(DLMS_DATA_TYPE_STRUCTURE);
data.SetUInt8(2);
CGXDLMSVariant tmp = it->GetDayId();
GXHelpers::SetData(data, DLMS_DATA_TYPE_UINT8, tmp);
data.SetUInt8(DLMS_DATA_TYPE_ARRAY);
//Add count
std::vector<CGXDLMSDayProfileAction>& schedules = (*it).GetDaySchedules();
GXHelpers::SetObjectCount(schedules.size(), data);
CGXDLMSVariant time, ln, selector;
for (std::vector<CGXDLMSDayProfileAction>::iterator action = schedules.begin(); action != schedules.end(); ++action)
{
time = action->GetStartTime();
ln = action->GetScriptLogicalName();
selector = action->GetScriptSelector();
GXHelpers::SetData(data, DLMS_DATA_TYPE_OCTET_STRING, time);
GXHelpers::SetData(data, DLMS_DATA_TYPE_OCTET_STRING, ln);
GXHelpers::SetData(data, DLMS_DATA_TYPE_UINT16, selector);
}
}
value = data;
return ERROR_CODES_OK;
}
if (index == 6)
{
value.Add(m_CalendarNamePassive);
return ERROR_CODES_OK;
//.........这里部分代码省略.........