Exemplo n.º 1
0
 private bool AddFrameToMessageArray(CDllFifoMessages MessageFIFO)
 {
     try
     {
         CDllFifoMessages.MessageDll NewMessage = new CDllFifoMessages.MessageDll();
         byte[] Frame1 = null;
         byte[] Frame2 = new byte[m_myFrameData[POS_LENGTH] - 1 + 1];
         Frame1 = m_myFrameData.GetArray;
         Array.Copy(Frame1, POS_DATA, Frame2, 0, m_myFrameData[POS_LENGTH]);
         NewMessage.SourceDevice = System.Convert.ToByte(Frame1[POS_ORIGEN] & 0x7F);
         NewMessage.TargetDevice = System.Convert.ToByte(Frame1[POS_DESTINO] & 0x7F);
         if (m_FrameProtocol == CStationBase.Protocol.Protocol_01)
         {
             NewMessage.FID = (byte)0;
         }
         else if (m_FrameProtocol == CStationBase.Protocol.Protocol_02)
         {
             NewMessage.FID = Frame1[POS_FID];
         }
         NewMessage.Command  = Frame1[POS_CONTROL];
         NewMessage.Datos    = Frame2;
         NewMessage.Response = (Frame1[POS_ORIGEN] & 0x80) > 0;
         NewMessage.RawFrame = new byte[m_myFrameData.GetArray.Length - 1 + 1];
         Array.Copy(m_myFrameData.GetArray, NewMessage.RawFrame, System.Convert.ToInt32(m_myFrameData.GetArray.Length));
         MessageFIFO.PutMessage(NewMessage);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 2
0
 public bool AddFrame(byte[] Data, byte sourceDevice, byte targetDevice, byte FrameControl, CDllFifoMessages FrameFIFO, byte FID = 0)
 {
     if (EncodeFrame(Data, sourceDevice, targetDevice, FrameControl, FID))
     {
         CDllFifoMessages.MessageDll NewFrame = new CDllFifoMessages.MessageDll();
         NewFrame.FID             = FID;
         NewFrame.RawFrame        = GetFrame();
         NewFrame.RawStuffedFrame = GetStuffedFrame();
         FrameFIFO.PutMessage(NewFrame);
         return(true);
     }
     else
     {
         return(false);
     }
 }