예제 #1
0
            /// <summary>
            /// Method that formats the message going to the embedded PTU target. The format of the message
            /// is specific to the type of request made.
            /// </summary>
            /// <param name="targetIsBigEndian">true if the embedded PTU target is a Big Endian machine; false otherwise</param>
            /// <returns>ordered byte array that is to be sent to the embedded PTU target</returns>
            public Byte[] GetByteArray(Boolean targetIsBigEndian)
            {
                DataPacketProlog dpp = new DataPacketProlog();

                if (targetIsBigEndian)
                {
                    this.NewEventLog = Utils.ReverseByteOrder(this.NewEventLog);
                }
                // Even though "ms" is allocated MAX_TX_STREAM_SIZE, the ToArray() returns the size
                // of the array that was populated with data
                MemoryStream ms = new MemoryStream(MAX_TX_STREAM_SIZE);
                BinaryWriter bw = new BinaryWriter(ms);
                bw.Write(this.NewEventLog);
                return dpp.GetByteArray(ms.ToArray(), PACKET_TYPE, RESPONSE_TYPE, targetIsBigEndian);
            }
예제 #2
0
            /// <summary>
            /// Method that formats the message going to the embedded PTU target. The format of the message
            /// is specific to the type of request made.
            /// </summary>
            /// <param name="targetIsBigEndian">true if the embedded PTU target is a Big Endian machine; false otherwise</param>
            /// <returns>ordered byte array that is to be sent to the embedded PTU target</returns>
            public Byte[] GetByteArray(Boolean targetIsBigEndian)
            {
                DataPacketProlog dpp = new DataPacketProlog();

                if (targetIsBigEndian)
                {
                    this.TaskID = Utils.ReverseByteOrder(this.TaskID);
                    this.FaultID = Utils.ReverseByteOrder(this.FaultID);
                    this.EnableFlag = Utils.ReverseByteOrder(this.EnableFlag);
                    this.DatalogFlag = Utils.ReverseByteOrder(this.DatalogFlag);
                }
                MemoryStream ms = new MemoryStream(MAX_TX_STREAM_SIZE);
                BinaryWriter bw = new BinaryWriter(ms);
                bw.Write(this.TaskID);
                bw.Write(this.FaultID);
                bw.Write(this.EnableFlag);
                bw.Write(this.DatalogFlag);
                return dpp.GetByteArray(ms.ToArray(), PACKET_TYPE, RESPONSE_TYPE, targetIsBigEndian);
            }
예제 #3
0
            /// <summary>
            /// Method that formats the message going to the embedded PTU target. The format of the message
            /// is specific to the type of request made.
            /// </summary>
            /// <param name="targetIsBigEndian">true if the embedded PTU target is a Big Endian machine; false otherwise</param>
            /// <returns>ordered byte array that is to be sent to the embedded PTU target</returns>
            public Byte[] GetByteArray(Boolean targetIsBigEndian)
            {
                DataPacketProlog dpp = new DataPacketProlog();

                if (targetIsBigEndian)
                {
                    this.TargetState = Utils.ReverseByteOrder(this.TargetState);
                }

                Byte[] payload = { this.TargetState };

                return dpp.GetByteArray(payload, PACKET_TYPE, RESPONSE_TYPE, targetIsBigEndian);
            }
예제 #4
0
            /// <summary>
            /// Method that formats the message going to the embedded PTU target. The format of the message
            /// is specific to the type of request made.
            /// </summary>
            /// <param name="targetIsBigEndian">true if the embedded PTU target is a Big Endian machine; false otherwise</param>
            /// <returns>ordered byte array that is to be sent to the embedded PTU target</returns>
            public Byte[] GetByteArray(Boolean targetIsBigEndian)
            {
                DataPacketProlog dpp = new DataPacketProlog();

                if (targetIsBigEndian)
                {
                    // Intentionally do nothing since the only item to be converted is a string
                }

                // Convert string to byte array
                Byte[] payload = Encoding.ASCII.GetBytes(this.NewCarId);

                return dpp.GetByteArray(payload, PACKET_TYPE, RESPONSE_TYPE, targetIsBigEndian);
            }
예제 #5
0
            /// <summary>
            /// Method that formats the message going to the embedded PTU target. The format of the message
            /// is specific to the type of request made.
            /// </summary>
            /// <param name="targetIsBigEndian">true if the embedded PTU target is a Big Endian machine; false otherwise</param>
            /// <returns>ordered byte array that is to be sent to the embedded PTU target</returns>
            public Byte[] GetByteArray(Boolean targetIsBigEndian)
            {
                DataPacketProlog dpp = new DataPacketProlog();

                if (targetIsBigEndian)
                {
                    this.DictionaryIndex = Utils.ReverseByteOrder(this.DictionaryIndex);
                    this.MaxScale = Utils.ReverseByteOrder(this.MaxScale);
                    this.MinScale = Utils.ReverseByteOrder(this.MinScale);
                }
                MemoryStream ms = new MemoryStream(MAX_TX_STREAM_SIZE);
                BinaryWriter bw = new BinaryWriter(ms);
                bw.Write(this.DictionaryIndex);
                bw.Write(this.MaxScale);
                bw.Write(this.MinScale);
                return dpp.GetByteArray(ms.ToArray(), PACKET_TYPE, RESPONSE_TYPE, targetIsBigEndian);
            }
예제 #6
0
            /// <summary>
            /// Method that formats the message going to the embedded PTU target. The format of the message
            /// is specific to the type of request made.
            /// </summary>
            /// <param name="targetIsBigEndian">true if the embedded PTU target is a Big Endian machine; false otherwise</param>
            /// <returns>ordered byte array that is to be sent to the embedded PTU target</returns>
            public Byte[] GetByteArray(Boolean targetIsBigEndian)
            {
                DataPacketProlog dpp = new DataPacketProlog();

                if (targetIsBigEndian)
                {
                    this.CommandId = Utils.ReverseByteOrder(this.CommandId);
                    this.NumberOfTests = Utils.ReverseByteOrder(this.NumberOfTests);

                    for (UInt16 i = 0; i < this.TestList.Length; i++)
                    {
                        this.TestList[i] = Utils.ReverseByteOrder(this.TestList[i]);
                    }
                }
                MemoryStream ms = new MemoryStream(MAX_TX_STREAM_SIZE);
                BinaryWriter bw = new BinaryWriter(ms);

                bw.Write(this.CommandId);
                bw.Write((Byte)0);
                bw.Write(this.NumberOfTests);

                for (UInt16 i = 0; i < this.TestList.Length; i++)
                {
                    bw.Write(this.TestList[i]);
                }

                return dpp.GetByteArray(ms.ToArray(), PACKET_TYPE, RESPONSE_TYPE, targetIsBigEndian);
            }
예제 #7
0
            /// <summary>
            /// Method that formats the message going to the embedded PTU target. The format of the message
            /// is specific to the type of request made.
            /// </summary>
            /// <param name="targetIsBigEndian">true if the embedded PTU target is a Big Endian machine; false otherwise</param>
            /// <returns>ordered byte array that is to be sent to the embedded PTU target</returns>
            public Byte[] GetByteArray(Boolean targetIsBigEndian)
            {
                DataPacketProlog dpp = new DataPacketProlog();

                if (targetIsBigEndian)
                {
                    this.CommandId = Utils.ReverseByteOrder(this.CommandId);
                    this.Data = Utils.ReverseByteOrder(this.Data);
                }
                MemoryStream ms = new MemoryStream(MAX_TX_STREAM_SIZE);
                BinaryWriter bw = new BinaryWriter(ms);
                bw.Write(this.CommandId);
                bw.Write(this.TruckId);
                bw.Write(this.Data);

                return dpp.GetByteArray(ms.ToArray(), PACKET_TYPE, RESPONSE_TYPE, targetIsBigEndian);
            }
예제 #8
0
            /// <summary>
            /// Method that formats the message going to the embedded PTU target. The format of the message
            /// is specific to the type of request made.
            /// </summary>
            /// <param name="targetIsBigEndian">true if the embedded PTU target is a Big Endian machine; false otherwise</param>
            /// <returns>ordered byte array that is to be sent to the embedded PTU target</returns>
            public Byte[] GetByteArray(Boolean targetIsBigEndian)
            {
                DataPacketProlog dpp = new DataPacketProlog();

                Byte[] payload = { this.ForceFullUpdate != 0 ? (Byte)1 : (Byte)0 };

                return dpp.GetByteArray(payload, PACKET_TYPE, RESPONSE_TYPE, targetIsBigEndian);
            }
예제 #9
0
            /// <summary>
            /// Method that formats the message going to the embedded PTU target. The format of the message
            /// is specific to the type of request made.
            /// </summary>
            /// <param name="targetIsBigEndian">true if the embedded PTU target is a Big Endian machine; false otherwise</param>
            /// <returns>ordered byte array that is to be sent to the embedded PTU target</returns>
            public Byte[] GetByteArray(Boolean targetIsBigEndian)
            {
                DataPacketProlog dpp = new DataPacketProlog();

                if (targetIsBigEndian)
                {
                    this.Hour = Utils.ReverseByteOrder(this.Hour);
                    this.Minute = Utils.ReverseByteOrder(this.Minute);
                    this.Second = Utils.ReverseByteOrder(this.Second);
                    this.Year = Utils.ReverseByteOrder(this.Year);
                    this.Month = Utils.ReverseByteOrder(this.Month);
                    this.Day = Utils.ReverseByteOrder(this.Day);
                }

                MemoryStream ms = new MemoryStream(MAX_TX_STREAM_SIZE);
                BinaryWriter bw = new BinaryWriter(ms);
                bw.Write(this.Hour);
                bw.Write(this.Minute);
                bw.Write(this.Second);
                if (this.fourDigitYear)
                {
                    // Used to fill a word boundary
                    bw.Write((Byte)0x00);
                    bw.Write(this.Year);
                }
                else
                {
                    Byte bYear = (Byte)this.Year;
                    bw.Write(bYear);
                }
                bw.Write(this.Month);
                bw.Write(this.Day);
                return dpp.GetByteArray(ms.ToArray(), PACKET_TYPE, RESPONSE_TYPE, targetIsBigEndian);
            }
예제 #10
0
            /// <summary>
            /// Method that formats the message going to the embedded PTU target. The format of the message
            /// is specific to the type of request made.
            /// </summary>
            /// <param name="targetIsBigEndian">true if the embedded PTU target is a Big Endian machine; false otherwise</param>
            /// <returns>ordered byte array that is to be sent to the embedded PTU target</returns>
            public Byte[] GetByteArray(Boolean targetIsBigEndian)
            {
                DataPacketProlog dpp = new DataPacketProlog();

                UInt16 numVars = streamInformation.NumberOfVariables;

                if (targetIsBigEndian)
                {
                    streamInformation.NumberOfVariables = Utils.ReverseByteOrder(streamInformation.NumberOfVariables);
                    streamInformation.NumberOfSamples = Utils.ReverseByteOrder(streamInformation.NumberOfSamples);
                    streamInformation.SampleRate = Utils.ReverseByteOrder(streamInformation.SampleRate);

                    for (UInt16 i = 0; i < numVars; i++)
                    {
                        streamInformation.StreamVariableInfo[i].Variable = Utils.ReverseByteOrder(streamInformation.StreamVariableInfo[i].Variable);
                        streamInformation.StreamVariableInfo[i].VariableType = Utils.ReverseByteOrder(streamInformation.StreamVariableInfo[i].VariableType);
                    }
                }

                MemoryStream ms = new MemoryStream(MAX_TX_STREAM_SIZE);
                BinaryWriter bw = new BinaryWriter(ms);
                bw.Write(streamInformation.NumberOfVariables);
                bw.Write(streamInformation.NumberOfSamples);
                bw.Write(streamInformation.SampleRate);
                for (UInt16 i = 0; i < numVars; i++)
                {
                    bw.Write(streamInformation.StreamVariableInfo[i].Variable);
                    bw.Write(streamInformation.StreamVariableInfo[i].VariableType);
                }
                return dpp.GetByteArray(ms.ToArray(), PACKET_TYPE, RESPONSE_TYPE, targetIsBigEndian);
            }