public void DoBlindSearch(SpiralScanArgs Args) { StartAlignmentProc(new SpiralScan(Args)); }
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)); } }