Ejemplo n.º 1
0
 /// <summary>
 /// Принимает пакет на обработку
 /// </summary>
 /// <param name="packet"></param>
 public void Packet(string packet)
 {
     if (protocol.PageAdress(packet) == 1 && protocol.GetData(packet).Length == 32)
     {
         Invoke(inserter, packet);
         ShowDevice(protocol.GetNumberDevice(packet));
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Пакет на обработку
        /// </summary>
        /// <param name="packet">Поступивший пакет</param>
        public void Packet(string packet)
        {
            bool blocked = false;

            try
            {
                if (packetSyncMutex.WaitOne(defaultTimeWaitOnPacketMutex))
                {
                    blocked = true;
                    if (biosTranslated)
                    {
                        bios.Packet(packet);
                    }
                    else
                    {
                        //throw new Exception();
                        if (proto.PageAdress(packet) != 0)
                        {
                            return;
                        }

                        string data           = proto.GetData(packet);
                        int    offsetInPacket = currentState.SelectedCalibrationTable.OffsetInPacket * 2;

                        if (data.Length > offsetInPacket + 4)
                        {
                            ushort calibrated = ushort.Parse(data.Substring(currentState.SelectedCalibrationTable.OffsetInPacket * 2, 4),
                                                             NumberStyles.AllowHexSpecifier);

                            ushort physic = (ushort)currentState.SelectedCalibrationTable.CalibrationTable.CalculateFromInPacket(calibrated);

                            gr.InsertPoint(new Point(physic, calibrated));
                            onShown(null, null);

                            Invoke(textInserter, textBoxFromDevicePhysic, physic.ToString());
                            Invoke(textInserter, textBoxFromDeviceCalibrated, calibrated.ToString());
                        }
                    }
                    blocked = false;
                    packetSyncMutex.ReleaseMutex();
                }
            }
            finally
            {
                if (blocked)
                {
                    packetSyncMutex.ReleaseMutex();
                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Передает пакет на обработу
 /// </summary>
 /// <param name="packet">Передаваемый пакет</param>
 public void Packet(string packet)
 {
     if (onPacket != null)
     {
         if (proto.IsFromDevice(packet))
         {
             string data = proto.GetData(packet);
             if (data.Length == 0x20)
             {
                 onPacket(packet);
             }
         }
     }
 }
Ejemplo n.º 4
0
        public static void Method1(string Data = null, Action Delegate = null, XElement xml = null, IProtocol protocol = null)
        {
            if (xml != null)
            {
                xml.Add(new XElement("clr"));
            }

            Console.WriteLine(new { Data, Delegate, xml, protocol });

            if (protocol != null)
            {
                var n = protocol.GetData(xml);

                Console.WriteLine(new { n.xml, n.bytes, n.port, n.enumvalue });
            }
        }
Ejemplo n.º 5
0
        private string CalculateResult()
        {
            try
            {
                List <string> Datas = new List <string>();
                for (int check = 0; check <= options.NumberOfDataChecks; check++)
                {
                    switch (ChekerToRWEprom(new Packet(sending, DateTime.Now, null)))
                    {
                    case ResultOperation.Succes:

                        Datas.Add(proto.GetData(data));
                        data = CheckDatas(Datas);
                        if (data != string.Empty)
                        {
                            Datas.Clear();

                            lastOperation = ResultOperation.Succes;
                            return(data);
                        }
                        break;

                    case ResultOperation.Timeout:

                        lastOperation = ResultOperation.Timeout;
                        return(string.Empty);

                    case ResultOperation.MorePopit:

                        lastOperation = ResultOperation.MorePopit;
                        return(string.Empty);
                    }
                }
                lastOperation = ResultOperation.Default;
                return(string.Empty);
            }
            finally
            {
            }
        }
Ejemplo n.º 6
0
        public static void Method1(string Data = null, Action Delegate = null, XElement xml = null, IProtocol protocol = null)
        {
            if (xml != null)
                xml.Add(new XElement("clr"));

            Console.WriteLine(new { Data, Delegate, xml, protocol });

            if (protocol != null)
            {
                var n = protocol.GetData(xml);

                Console.WriteLine(new { n.xml, n.bytes, n.port, n.enumvalue });
            }


        }