本文整理汇总了C++中CGXDLMSVariant::ToDouble方法的典型用法代码示例。如果您正苦于以下问题:C++ CGXDLMSVariant::ToDouble方法的具体用法?C++ CGXDLMSVariant::ToDouble怎么用?C++ CGXDLMSVariant::ToDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGXDLMSVariant
的用法示例。
在下文中一共展示了CGXDLMSVariant::ToDouble方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetValue
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;
}
示例2: SetValue
/*
* Set value of given attribute.
*/
int CGXDLMSProfileGeneric::SetValue(int index, CGXDLMSVariant& value)
{
int ret;
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)
{
if (m_CaptureObjects.size() == 0)
{
//Read capture objects first.
return ERROR_CODES_INVALID_PARAMETER;
}
m_Buffer.clear();
if (value.vt != DLMS_DATA_TYPE_NONE)
{
vector<DLMS_DATA_TYPE> types;
DLMS_DATA_TYPE type;
for (std::vector<std::pair<CGXDLMSObject*, CGXDLMSCaptureObject*> >::iterator it = m_CaptureObjects.begin(); it != m_CaptureObjects.end(); ++it)
{
if ((ret = (*it).first->GetUIDataType((*it).second->GetAttributeIndex(), type)) != 0)
{
return ret;
}
types.push_back(type);
}
for (std::vector<CGXDLMSVariant >::iterator row = value.Arr.begin(); row != value.Arr.end(); ++row)
{
if ((*row).Arr.size() != m_CaptureObjects.size())
{
//Number of columns do not match.
return ERROR_CODES_INVALID_PARAMETER;
}
for(unsigned int a = 0; a < (*row).Arr.size(); ++a)
{
CGXDLMSVariant data = (*row).Arr[a];
DLMS_DATA_TYPE type = types[a];
if (type != DLMS_DATA_TYPE_NONE && data.vt == DLMS_DATA_TYPE_OCTET_STRING)
{
unsigned char* pBuff = &data.byteArr[0];
int size = data.byteArr.size();
if ((ret = CGXOBISTemplate::GetData(pBuff, size, type, (*row).Arr[a])) != 0)
{
return ret;
}
}
std::pair<CGXDLMSObject*, CGXDLMSCaptureObject*> item = m_CaptureObjects[a];
if (item.first->GetObjectType() == OBJECT_TYPE_REGISTER && item.second->GetAttributeIndex() == 2)
{
double scaler = ((CGXDLMSRegister*) item.first)->GetScaler();
if (scaler != 1)
{
row[a] = data.ToDouble() * scaler;
}
}
}
m_Buffer.push_back(row->Arr);
}
}
m_EntriesInUse = m_Buffer.size();
}
else if (index == 3)
{
m_CaptureObjects.clear();
m_Buffer.clear();
m_EntriesInUse = 0;
if (value.vt == DLMS_DATA_TYPE_ARRAY)
{
for (std::vector<CGXDLMSVariant >::iterator it = value.Arr.begin(); it != value.Arr.end(); ++it)
{
if ((*it).Arr.size() != 4)
{
//Invalid structure format.
return ERROR_CODES_INVALID_PARAMETER;
}
OBJECT_TYPE type = (OBJECT_TYPE) (*it).Arr[0].ToInteger();
string ln;
CGXOBISTemplate::GetLogicalName(&(*it).Arr[1].byteArr[0], ln);
CGXDLMSObject* pObj = NULL;
if (GetParent() != NULL)
{
pObj = GetParent()->FindByLN(type, ln);
}
if(pObj == NULL)
{
pObj = CGXDLMSObjectFactory::CreateObject(type);
pObj->SetLogicalName(ln);
}
AddCaptureObject(pObj, (*it).Arr[2].ToInteger(), (*it).Arr[3].ToInteger());
}
}
//.........这里部分代码省略.........
示例3: SetValue
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)
{
if (m_Scaler != 0)
{
SetCurrentAvarageValue(CGXDLMSVariant(value.ToDouble() * m_Scaler));
}
else
{
SetCurrentAvarageValue(value);
}
}
else if (index == 3)
{
if (m_Scaler != 0)
{
SetLastAvarageValue(CGXDLMSVariant(value.ToDouble() * GetScaler()));
}
else
{
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;
}