Пример #1
0
        public bool Lunch()
        {
            try
            {
                if (!EquipmentBus.ControllerRegister.CheckRely(RelyEquipment))
                {
                    throw new Exception($"依赖设备尚未启动{string.Join("、", RelyEquipment)}");
                }

                UARTDriver           = DriversFactory.GetUARTDriver(ComName);
                UARTDriver.RecEvent += UARTDriver_RecEvent;

                SBus            = DriversFactory.GetSBusDriver(3);
                SBus.SetSignal += SBus_SetSignal;

                EquipmentData.IsEnable = true;
                EquipmentBus.ControllerRegister.Register(Enum.RegisterType.RemoteController, true);
            }
            catch (Exception ex)
            {
                EquipmentData.AddError(Enum.LogType.Error, "启动遥控器失败!", ex);
                Logger.Add(Enum.LogType.Error, "启动遥控器失败!", ex);
                EquipmentData.IsEnable = false;
                return(false);
            }
            return(true);
        }
Пример #2
0
        public bool Lunch()
        {
            try
            {
                if (!EquipmentBus.ControllerRegister.CheckRely(RelyEquipment))
                {
                    throw new Exception($"依赖设备尚未启动{string.Join("、", RelyEquipment)}");
                }

                UART           = DriversFactory.GetUARTDriver(ComName);
                UART.RecEvent += ReceivedEvent;

                EquipmentData.IsEnable = true;
                EquipmentBus.ControllerRegister.Register(Enum.RegisterType.E34_2G4D20D, true);

                Task.Run(() =>
                {
                    while (true)
                    {
                        Thread.Sleep(1);
                        try
                        {
                            lock (SendBytes)
                            {
                                if (SendBytes.Count != 0)
                                {
                                    if (SendBytes[0] != null)
                                    {
                                        UART.WriteBytes(SendBytes[0]);
                                    }
                                    SendBytes.RemoveAt(0);
                                }
                            }
                        }
                        catch { }
                    }
                });
            }
            catch (Exception ex)
            {
                EquipmentData.AddError(Enum.LogType.Error, "启动E34_2G4D20D失败!", ex);
                Logger.Add(Enum.LogType.Error, "启动E34_2G4D20D失败!", ex);
                EquipmentData.IsEnable = false;
                return(false);
            }
            return(true);
        }