Exemplo n.º 1
0
        public CylinderController(ConfigurationCylinder Config, IrixiEE0017 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)
            {
                // detect the input gpio of the pedal state
                this.Controller.OnInputStateChanged += ((s, e) =>
                {
                    if (e.Channel == this.PedalInputPort && e.State == InputState.Triggered)
                    {
                        DoPedalTriggerd();
                    }
                });

                // the hid report is received, flush the cylinders' state (Output)
                this.Controller.OnHIDReportReceived += ((s, e) =>
                {
                    this.FiberClampState = e.GetOutputState(this.FiberClampOutputPort);
                    this.LensVacuumState = e.GetOutputState(this.LensVacuumOutputPort);
                    this.PlcVacuumState = e.GetOutputState(this.PLCVacuumOutputPort);
                    this.PodVacuumState = e.GetOutputState(this.PODVacuumOutputPort);
                });
            }
        }
Exemplo n.º 2
0
 public bool Init(IOCardCfg ioCfg, ICommunicationPortCfg communicationPortCfg)
 {
     this.ioCfg = ioCfg;
     comport    = CommunicationMgr.Instance.FindPortByPortName(ioCfg.PortName) as Comport;
     if (comport == null)
     {
         return(false);
     }
     else
     {
         _controller = IrixiEE0017.CreateInstance(ioCfg.PortName);
         if (_controller != null)
         {
             _controller.OnOutputStateChanged += _controller_OnOutputStateChanged;
             _controller.OnInputStateChanged  += _controller_OnInputStateChanged;
             if (ioCfg.NeedInit)
             {
                 return(_controller.Init(Int32.Parse(comport.ToString().ToLower().Replace("com", ""))));
             }
             else
             {
                 return(true);
             }
         }
         return(false);
     }
 }
Exemplo n.º 3
0
        public SystemService()
        {
            ThreadPool.SetMinThreads(50, 50);

            // read version from AssemblyInfo.cs
            Version version = Assembly.GetExecutingAssembly().GetName().Version;

            // force to enable the log, otherwise the initial message could not be recored
            LogHelper.LogEnabled = true;

            StringBuilder sb = new StringBuilder();

            sb.Append("\r\n");
            sb.Append("> =================================================================\r\n");
            sb.Append("> =                 4x25G/10x10G Alignment System                 =\r\n");
            sb.Append("> =                    Copyright (C) 2017 Irixi                   =\r\n");
            sb.Append("> =================================================================\r\n");
            LogHelper.WriteLine(sb.ToString());

            this.LastMessage = new MessageItem(MessageType.Normal, "System startup ...");

            this.LastMessage = new MessageItem(MessageType.Normal, "Application Version {0}", version);


            // read the configuration from the file named SystemCfg.json
            // the file is located in \Configuration
            ConfigManager conf_manager = SimpleIoc.Default.GetInstance <ConfigManager>();

            // whether output the log
            LogHelper.LogEnabled = conf_manager.ConfSystemSetting.LogEnabled;

            // initialize the properties
            BusyComponents = new List <IServiceSystem>();

            PhysicalMotionControllerCollection = new Dictionary <Guid, IMotionController>();
            LogicalAxisCollection            = new ObservableCollection <LogicalAxis>();
            LogicalMotionComponentCollection = new ObservableCollection <LogicalMotionComponent>();
            MeasurementInstrumentCollection  = new ObservableCollection <InstrumentBase>();
            ActiveInstrumentCollection       = new ObservableCollection <InstrumentBase>();
            State = SystemState.BUSY;

            SpiralScanArgs  = new SpiralScanArgs();
            AlignmentXDArgs = new AlignmentXDArgs();


            /*
             * enumerate all physical motion controllers defined in the config file,
             * and create the instance of the motion controller class.
             */
            foreach (var conf in conf_manager.ConfSystemSetting.PhysicalMotionControllers)
            {
                IMotionController motion_controller = null;

                switch (conf.Model)
                {
                case MotionControllerModel.LUMINOS_P6A:
                    motion_controller              = new LuminosP6A(conf);
                    motion_controller.OnMoveBegin += PhysicalMotionController_OnMoveBegin;
                    motion_controller.OnMoveEnd   += PhysicalMotionController_OnMoveEnd;
                    break;

                case MotionControllerModel.THORLABS_TDC001:
                    //TODO create the instance of thorlabs TDC001
                    break;

                case MotionControllerModel.IRIXI_EE0017:
                    motion_controller              = new IrixiEE0017(conf);
                    motion_controller.OnMoveBegin += PhysicalMotionController_OnMoveBegin;
                    motion_controller.OnMoveEnd   += PhysicalMotionController_OnMoveEnd;
                    ((IrixiEE0017)motion_controller).OnMessageReported += ((sender, message) =>
                    {
                        Application.Current.Dispatcher.Invoke(() =>
                        {
                            this.LastMessage = new MessageItem(MessageType.Normal, string.Format("{0} {1}", sender, message));
                        });
                    });
                    break;

                default:
                    this.LastMessage = new MessageItem(MessageType.Error, "Unrecognized controller model {0}.", conf.Model);
                    break;
                }

                // Add the controller to the dictionary<Guid, Controller>
                if (motion_controller != null)
                {
                    this.PhysicalMotionControllerCollection.Add(motion_controller.DeviceClass, motion_controller);
                }
            }

            // create the instance of the Logical Motion Components
            foreach (var cfg_motion_comp in conf_manager.ConfSystemSetting.LogicalMotionComponents)
            {
                LogicalMotionComponent comp = new LogicalMotionComponent(cfg_motion_comp.Caption, cfg_motion_comp.Icon);

                int axis_id = 0;
                foreach (var cfg_axis in cfg_motion_comp.LogicalAxisArray)
                {
                    // new logical axis object will be added to the Logical Motion Component
                    LogicalAxis axis = new LogicalAxis(this, cfg_axis, cfg_motion_comp.Caption, axis_id);

                    axis.OnHomeRequsted += LogicalAxis_OnHomeRequsted;
                    axis.OnMoveRequsted += LogicalAxis_OnMoveRequsted;
                    axis.OnStopRequsted += LogicalAxis_OnStopRequsted;

                    // bind the physical axis instance to logical axis object
                    BindPhysicalAxis(axis);

                    comp.LogicalAxisCollection.Add(axis);
                    this.LogicalAxisCollection.Add(axis);

                    axis_id++;
                }

                this.LogicalMotionComponentCollection.Add(comp);
            }

            // create the instance of the cylinder
            try
            {
                IrixiEE0017 ctrl = PhysicalMotionControllerCollection[Guid.Parse(conf_manager.ConfSystemSetting.Cylinder.Port)] as IrixiEE0017;
                CylinderController = new CylinderController(conf_manager.ConfSystemSetting.Cylinder, ctrl);
            }
            catch (Exception e)
            {
                this.LastMessage = new MessageItem(MessageType.Error, "Unable to initialize the cylinder controller, {0}", e.Message);
            }

            // create instance of the keithley 2400
            foreach (var cfg in conf_manager.ConfSystemSetting.Keithley2400s)
            {
                this.MeasurementInstrumentCollection.Add(new Keithley2400(cfg));
            }

            // create instance of the newport 2832C
            foreach (var cfg in conf_manager.ConfSystemSetting.Newport2832Cs)
            {
                this.MeasurementInstrumentCollection.Add(new Newport2832C(cfg));
            }
        }