/*!
 * \brief  功能概述 获取报文中的值
 * \param  参数描述 nStartByte是开始字节,nSize是字节个数
 * \return 返回值描述 返回报文中获取的值
 * \author zzy
 * \date   2015/5/25
 */
unsigned int CIEC104Response::GetUInt( int nStartByte, int nSize ) const
{
    Q_ASSERT(IsValid());
    AdjustIndex(nStartByte);
    Q_ASSERT(nStartByte >= 0);
    Q_ASSERT(nSize > 0);
    Q_ASSERT(nStartByte+nSize <= m_nInfomationSize);

    unsigned int nReturnValue = INVALID_VALUE;
    if (nStartByte>=0 && nStartByte+nSize<=m_nInfomationSize)
    {
        switch (nSize)
        {
        case 1:
            nReturnValue = *(unsigned  char *)(m_pBufferHead + nStartByte);
            break;
        case 2:
            nReturnValue = *(unsigned short int *)(m_pBufferHead + nStartByte);
            break;
        case 4:
            nReturnValue = *(unsigned int *)(m_pBufferHead + nStartByte);
            break;
        case 3://不常见
            nReturnValue = *(unsigned int *)(m_pBufferHead + nStartByte) & 0xFFFFFF;
            break;
        default:
            Q_ASSERT(false);
            break;
        }
    }
    return nReturnValue;
}
/*!
 * \brief  功能概述 获取缓冲区内容
 * \param  参数描述 nStartByte是开始字节
 * \return 返回值描述 返回缓冲区指针
 * \author zzy
 * \date   2015/5/25
 */
BYTE *CIEC104Response::GetBuffer(int nStartByte) const
{
    Q_ASSERT(IsValid());
    AdjustIndex(nStartByte);
    Q_ASSERT(nStartByte >= 0);
    Q_ASSERT(nStartByte < m_nInfomationSize);
    return m_pBufferHead + nStartByte;
}
Beispiel #3
0
void MHListGroup::DeselectItem(int nCell, MHEngine *engine)
{
    if (m_fWrapAround)
    {
        nCell = AdjustIndex(nCell);
    }

    if (nCell < 1 || nCell > m_ItemList.size())
    {
        return;
    }

    Deselect(nCell, engine);
}
Beispiel #4
0
void MHListGroup::GetItemStatus(int nCell, const MHObjectRef &itemDest, MHEngine *engine)
{
    if (m_fWrapAround)
    {
        nCell = AdjustIndex(nCell);
    }

    if (nCell < 1 || nCell > m_ItemList.size())
    {
        return;
    }

    engine->FindObject(itemDest)->SetVariableValue(m_ItemList.at(nCell - 1)->m_fSelected);
}
Beispiel #5
0
void MHListGroup::GetListItem(int nCell, const MHObjectRef &itemDest, MHEngine *engine)
{
    if (m_fWrapAround)
    {
        nCell = AdjustIndex(nCell);
    }

    if (nCell < 1 || nCell > m_ItemList.size())
    {
        return;    // Ignore it if it's out of range and not wrapping
    }

    engine->FindObject(itemDest)->SetVariableValue(m_ItemList.at(nCell - 1)->m_pVisible->m_ObjectReference);
}
Beispiel #6
0
void MHListGroup::SetFirstItem(int nCell, MHEngine *engine)
{
    if (m_fWrapAround)
    {
        nCell = AdjustIndex(nCell);
    }

    if (nCell < 1 || nCell > m_ItemList.size())
    {
        return;
    }

    m_nFirstItem = nCell;
    Update(engine);
}
Beispiel #7
0
void MHListGroup::ToggleItem(int nCell, MHEngine *engine)
{
    if (m_fWrapAround)
    {
        nCell = AdjustIndex(nCell);
    }

    if (nCell < 1 || nCell > m_ItemList.size())
    {
        return;
    }

    if (m_ItemList.at(nCell - 1)->m_fSelected)
    {
        Deselect(nCell, engine);
    }
    else
    {
        Select(nCell, engine);
    }
}