Esempio n. 1
0
        /// <summary>
        /// Get the self test special message.
        /// </summary>
        /// <param name="Result">The result of the call. A value of: (1) 1 represents success; (2) indicates that the error message defined by the
        /// <paramref name="Reason"/> parameter applies and (3) represents an unknown error.</param>
        /// <param name="Reason">A value of 1 represents success; otherwise, the value is mapped to the <c>ERRID</c> field of the
        /// <c>SELFTESTERRMESS</c> table of the data dictionary in order to determine the error message returned from the VCU.</param>
        /// <returns>Success, if the communication request was successful; otherwise, an error code.</returns>
        public CommunicationError GetSelfTestSpecialMessage(out Int16 Result, out Int16 Reason)
        {
            Result = -1;
            Reason = -1;

            // Initiate transaction with embedded target
            CommunicationError commError = m_PtuTargetCommunication.SendDataRequestToEmbedded(m_CommDevice, ProtocolPTU.PacketType.GET_SELF_TEST_PACKET, m_RxMessage);

            if (commError != CommunicationError.Success)
            {
                return(commError);
            }

            // Extract all of the information from the received data
            Byte valid       = m_RxMessage[8];
            Byte messageMode = m_RxMessage[9];

            if (m_CommDevice.IsTargetBigEndian())
            {
                valid       = Utils.ReverseByteOrder(valid);
                messageMode = Utils.ReverseByteOrder(messageMode);
            }

            if (valid != 1)
            {
                return(CommunicationError.UnknownError);
            }

            if (messageMode != STC_MSG_MODE_SPECIAL)
            {
                return(CommunicationError.BadResponse);
            }

            Result = BitConverter.ToInt16(m_RxMessage, 12);
            Byte bReason = m_RxMessage[15];

            if (m_CommDevice.IsTargetBigEndian())
            {
                Result  = Utils.ReverseByteOrder(Result);
                bReason = Utils.ReverseByteOrder(bReason);
            }

            Reason = bReason;

            return(CommunicationError.Success);
        }
        /// <summary>
        /// Method requests and retrieves from the embedded target the chart variable information based on
        /// the chart index provided. The PTU variable index is retrieved
        /// </summary>
        /// <param name="ChartIndex">The chart variable index (starting at 0) and not to equal or exceed the amount
        /// of chart recorder variables</param>
        /// <param name="VariableIndex">The variable index that is currently part of the chart recorder outputs</param>
        /// <returns>CommunicationError.Success (0) if all is well; otherwise another enumeration which is less than 0</returns>
        public CommunicationError GetChartIndex(Int16 ChartIndex, ref Int16 VariableIndex)
        {
            ProtocolPTU.GetChartIndexReq request = new ProtocolPTU.GetChartIndexReq((Byte)ChartIndex);

            CommunicationError commError = m_PtuTargetCommunication.SendDataRequestToEmbedded(m_CommDevice, request, m_RxMessage);

            if (commError != CommunicationError.Success)
            {
                return(commError);
            }

            // Get the desired variable index from the receive message
            VariableIndex = BitConverter.ToInt16(m_RxMessage, 8);

            // check for endianess
            if (m_CommDevice.IsTargetBigEndian())
            {
                VariableIndex = Utils.ReverseByteOrder(VariableIndex);
            }

            return(CommunicationError.Success);
        }