// Returns value of given attribute.
int CGXDLMSAutoAnswer::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 = GetMode();
		return ERROR_CODES_OK;
    }    
    if (index == 3)
    {
        int cnt = m_ListeningWindow.size();
		vector<unsigned char> data;
        data.push_back(DLMS_DATA_TYPE_ARRAY);
        //Add count            
        CGXOBISTemplate::SetObjectCount(cnt, data);
		for (std::vector<std::pair< CGXDateTime, CGXDateTime> >::iterator it = 
			m_ListeningWindow.begin(); it != m_ListeningWindow.end(); ++it)
        {
            data.push_back(DLMS_DATA_TYPE_STRUCTURE);
            data.push_back(2); //Count
            CGXOBISTemplate::SetData(data, DLMS_DATA_TYPE_OCTET_STRING, (*it).first); //start_time
            CGXOBISTemplate::SetData(data, DLMS_DATA_TYPE_OCTET_STRING, (*it).second); //end_time
        }
        value = data;                
		return ERROR_CODES_OK;
    }
    if (index == 4)
    {
        value = GetStatus();
		return ERROR_CODES_OK;
    }
    if (index == 5)
    {
        value = GetNumberOfCalls();
		return ERROR_CODES_OK;
    }
    if (index == 6)
    {
        vector<unsigned char> data;
		data.push_back(DLMS_DATA_TYPE_STRUCTURE);
        CGXOBISTemplate::SetObjectCount(2, data);
		int ret;
        if ((ret = CGXOBISTemplate::SetData(data, DLMS_DATA_TYPE_UINT8, m_NumberOfRingsInListeningWindow)) != ERROR_CODES_OK ||
			(ret = CGXOBISTemplate::SetData(data, DLMS_DATA_TYPE_UINT8, m_NumberOfRingsOutListeningWindow)) != ERROR_CODES_OK)
		{
			return ret;
		}
        value = data;
		return ERROR_CODES_OK;  
    }
    return ERROR_CODES_INVALID_PARAMETER;
}
Пример #2
0
// Returns value of given attribute.
int CGXDLMSAutoAnswer::GetValue(int index, int selector, CGXDLMSVariant& parameters, CGXDLMSVariant& value)
{
    if (index == 1)
    {
        return GetLogicalName(this, value);
    }
    if (index == 2)
    {
        value = GetMode();
        return ERROR_CODES_OK;
    }
    if (index == 3)
    {
        int ret;
        int cnt = m_ListeningWindow.size();
        CGXByteBuffer data;
        data.SetUInt8(DLMS_DATA_TYPE_ARRAY);
        //Add count
        GXHelpers::SetObjectCount(cnt, data);
        CGXDLMSVariant f, s;
        for (std::vector<std::pair<CGXDateTime, CGXDateTime> >::iterator it =
                    m_ListeningWindow.begin(); it != m_ListeningWindow.end(); ++it)
        {
            data.SetUInt8(DLMS_DATA_TYPE_STRUCTURE);
            data.SetUInt8(2); //Count
            f = it->first;
            s = it->second;
            if ((ret = GXHelpers::SetData(data, DLMS_DATA_TYPE_OCTET_STRING, f)) != 0 || //start_time
                    (ret = GXHelpers::SetData(data, DLMS_DATA_TYPE_OCTET_STRING, s)) != 0) //end_time
            {
                return ret;
            }
        }
        value = data;
        return ERROR_CODES_OK;
    }
    if (index == 4)
    {
        value = GetStatus();
        return ERROR_CODES_OK;
    }
    if (index == 5)
    {
        value = GetNumberOfCalls();
        return ERROR_CODES_OK;
    }
    if (index == 6)
    {
        CGXByteBuffer data;
        data.SetUInt8(DLMS_DATA_TYPE_STRUCTURE);
        GXHelpers::SetObjectCount(2, data);
        CGXDLMSVariant in = m_NumberOfRingsInListeningWindow;
        CGXDLMSVariant out = m_NumberOfRingsOutListeningWindow;
        int ret;
        if ((ret = GXHelpers::SetData(data, DLMS_DATA_TYPE_UINT8, in)) != ERROR_CODES_OK ||
                (ret = GXHelpers::SetData(data, DLMS_DATA_TYPE_UINT8, out)) != ERROR_CODES_OK)
        {
            return ret;
        }
        value = data;
        return ERROR_CODES_OK;
    }
    return ERROR_CODES_INVALID_PARAMETER;
}
Пример #3
0
// Returns value of given attribute.
int CGXDLMSAutoAnswer::GetValue(CGXDLMSSettings& settings, CGXDLMSValueEventArg& e)
{
    if (e.GetIndex() == 1)
    {
        int ret;
        CGXDLMSVariant tmp;
        if ((ret = GetLogicalName(this, tmp)) != 0)
        {
            return ret;
        }
        e.SetValue(tmp);
        return DLMS_ERROR_CODE_OK;
    }
    if (e.GetIndex() == 2)
    {
        e.SetValue(GetMode());
        return DLMS_ERROR_CODE_OK;
    }
    if (e.GetIndex() == 3)
    {
        e.SetByteArray(true);
        int ret;
        unsigned long cnt = (unsigned long)m_ListeningWindow.size();
        CGXByteBuffer data;
        data.SetUInt8(DLMS_DATA_TYPE_ARRAY);
        //Add count
        GXHelpers::SetObjectCount(cnt, data);
        CGXDLMSVariant f, s;
        for (std::vector<std::pair<CGXDateTime, CGXDateTime> >::iterator it =
            m_ListeningWindow.begin(); it != m_ListeningWindow.end(); ++it)
        {
            data.SetUInt8(DLMS_DATA_TYPE_STRUCTURE);
            data.SetUInt8(2); //Count
            f = it->first;
            s = it->second;
            if ((ret = GXHelpers::SetData(data, DLMS_DATA_TYPE_OCTET_STRING, f)) != 0 || //start_time
                (ret = GXHelpers::SetData(data, DLMS_DATA_TYPE_OCTET_STRING, s)) != 0) //end_time
            {
                return ret;
            }
        }
        e.SetValue(data);
        return DLMS_ERROR_CODE_OK;
    }
    if (e.GetIndex() == 4)
    {
        e.SetValue(GetStatus());
        return DLMS_ERROR_CODE_OK;
    }
    if (e.GetIndex() == 5)
    {
        e.SetValue(GetNumberOfCalls());
        return DLMS_ERROR_CODE_OK;
    }
    if (e.GetIndex() == 6)
    {
        e.SetByteArray(true);
        CGXByteBuffer data;
        data.SetUInt8(DLMS_DATA_TYPE_STRUCTURE);
        GXHelpers::SetObjectCount(2, data);
        CGXDLMSVariant in = m_NumberOfRingsInListeningWindow;
        CGXDLMSVariant out = m_NumberOfRingsOutListeningWindow;
        int ret;
        if ((ret = GXHelpers::SetData(data, DLMS_DATA_TYPE_UINT8, in)) != DLMS_ERROR_CODE_OK ||
            (ret = GXHelpers::SetData(data, DLMS_DATA_TYPE_UINT8, out)) != DLMS_ERROR_CODE_OK)
        {
            return ret;
        }
        e.SetValue(data);
        return DLMS_ERROR_CODE_OK;
    }
    return DLMS_ERROR_CODE_INVALID_PARAMETER;
}