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);
        }
Example #2
0
        public bool Lunch()
        {
            try
            {
                //检查依赖
                if (!EquipmentBus.ControllerRegister.CheckRely(RelyEquipment))
                {
                    throw new Exception($"依赖设备尚未启动{string.Join("、", RelyEquipment)}");
                }

                I2CDevice = I2CDriver.I2CBus.AddDevice(Addr);
                I2CDevice.WriteAddressByte(MODE1, 0x00);
                SetPWMFreq(Freq);
                EquipmentData.IsEnable = true;
                EquipmentBus.ControllerRegister.Register(RegisterType.Pca9685, false);
            }
            catch (Exception ex)
            {
                EquipmentData.AddError(LogType.Error, $"启动地址为{Addr},频率为{Freq}的PCA9685失败!", ex);
                Logger.Add(LogType.Error, $"启动地址为{Addr},频率为{Freq}的PCA9685失败!", ex);
                EquipmentData.IsEnable = false;
                return(false);
            }
            return(true);
        }
Example #3
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);
        }