public InternalPowerMeter(ConfigurationInternalPowerMeter Config, IrixiM12 ControllerAttached, PDFrontEnd FrontEnd) : base(Config)
        {
            this.Controller      = ControllerAttached;
            this.FrontEnd        = FrontEnd;
            this.BackgroundNoise = Config.BackgroundNoise;

            if (Enum.TryParse <ADCChannels>(Config.AttachedADCChannel, out ADCChannels ch))
            {
                this.AttachedADCChannel = ch;

                // once the analog input value updated in the background task, this event of M12 will be raised to
                // ask the subscriber to udpate the corresponding properties.
                Controller.OnAnalogInputValueUpdated += (s, e) =>
                {
                    if (e.InputChannel == AttachedADCChannel)
                    {
                        // convert voltage to current.
                        double res     = (int)FrontEnd.Range < 0 ? 1000000 : FrontEnd.Config.SamplingRes[(int)FrontEnd.Range - 1];
                        double voltage = e.AnalogValue - BackgroundNoise;
                        if (voltage < 0)
                        {
                            voltage = 0;
                        }
                        this.Power = Math.Round(voltage / res * 1000, 3);
                    }
                };
            }
            else
            {
                this.IsInitialized = false;
                throw new ArgumentException($"unable to parse the ADC Channel {Config.AttachedADCChannel}, please check the config file.");
            }
        }
예제 #2
0
        public CylinderController(ConfigurationCylinder Config, IrixiM12 ControllerAttached) : base(Config)
        {
            this.Controller           = ControllerAttached;
            this.PedalInputPort       = Config.PedalInput;
            this.FiberClampOutputPort = Config.FiberClampOutput;
            this.LensVacuumOutputPort = Config.LensVacuumOutput;
            this.PLCVacuumOutputPort  = Config.PLCVacuumOutput;
            this.PODVacuumOutputPort  = Config.PODVacuumOutput;

            if (ControllerAttached != null)
            {
                ControllerAttached.OnDigitalInputUpdated += (s, e) =>
                {
                    if (e.Status.Integrated[PedalInputPort] == DigitalIOStatus.ON)
                    {
                        DoPedalTriggerd();
                    }
                };
            }
        }
예제 #3
0
        public ContactSensor(ConfigurationContactSensor Config, IrixiM12 ControllerAttached) : base(Config)
        {
            this.Controller = ControllerAttached;

            if (Enum.TryParse <ADCChannels>(Config.AttachedADCChannel, out ADCChannels ch))
            {
                AttachedADCChannel = ch;

                // once the analog input value updated in the background task, this event of M12 will be raised to
                // ask the subscriber to udpate the corresponding properties.
                Controller.OnAnalogInputValueUpdated += (s, e) =>
                {
                    if (e.InputChannel == AttachedADCChannel)
                    {
                        this.Force = Math.Round(e.AnalogValue, 0);
                    }
                };
            }
            else
            {
                this.IsInitialized = false;
                throw new ArgumentException($"unable to parse the ADC Channel {Config.AttachedADCChannel}, please check the config file.");
            }
        }