Exemple #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            //
            //读取设置文件,准备环境设置
            //
            //用哪个setting
            SettingPair sp1 = new SettingPair();

            //sp1.ImplementClass = new MotorSignalSettings().GetType();
            sp1.ImplementClass = new TractorSignalSettings().GetType();
            sp1.FilePath       = "TractorSignal.config";

            ISettings setting  = new CSetup(sp1).Settings;
            CSettings csetting = setting as CSettings;

            //
            //创建Monitor,Translator,StateManager。
            //准备考试核心引擎
            //
            //用哪个monitor
            //AssemblyInfoPair monInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Share.Signal.Motor.MotorMonitor));
            //AssemblyInfoPair monInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Share.Signal.Car.OldCarMonitor));
            AssemblyInfoPair monInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Share.Signal.Car.TractorMonitor));
            ISignalMonitor   mon     = SignalMonitorFactory.CreateSignalMonitor(monInfo, setting);

            //用哪个translator
            //AssemblyInfoPair transInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Exam.MotorSignalTranslator));
            AssemblyInfoPair transInfo  = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Exam.CarSignalTranslator));
            ITranslator      translator = TranslatorFactory.CreateTranslater(transInfo, mon);

            //用哪个statemanager
            //AssemblyInfoPair stateMgrInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Exam.State.MotorState.MotorStateManager));
            //AssemblyInfoPair stateMgrInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Exam.State.PureLineCarState.CarStateManager));
            AssemblyInfoPair stateMgrInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Exam.State.Tractor.TractorStateManager));
            IStateManager    stateMgr     = StateManagerFactory.CreateStateManager(stateMgrInfo, translator, setting);

            //
            //创建考试启动停止控件
            //实现单会合考试
            ExamCtrlPanel examCtrl = new ExamCtrlPanel();

            examCtrl.Location = new System.Drawing.Point(0, 0);
            this.ctrlPanel.Controls.Add(examCtrl);

            //ExamCtrl控件必须先被add到其父窗口中,然后再进行Initialize
            examCtrl.InitializeExamComponent(setting, mon, translator, stateMgr);

            //创建考试状态显示面板
            //单会合考试级别扩展功能
            ExamStatusDisplayPanel statePane = new ExamStatusDisplayPanel();

            statePane.Location    = new System.Drawing.Point(0, 100);
            statePane.BorderStyle = BorderStyle.Fixed3D;
            statePane.InitializeExamComponent(stateMgr);
            this.ctrlPanel.Controls.Add(statePane);

            //创建信号显示面板
            SignalDisplay signaldisplay = new SignalDisplay(mon);

            signaldisplay.Location = new System.Drawing.Point(0, 20);
            //sd.BorderStyle = BorderStyle.Fixed3D;
            this.ctrlPanel.Controls.Add(signaldisplay);


            //用哪个DisplayPanel
            //BaseModelDisplayPanel modelDisplayPane = new Cn.Youdundianzi.Share.Module.ModelDisplay.Car.CarModelDisplayPanel();
            BaseModelDisplayPanel modelDisplayPane = new Cn.Youdundianzi.Share.Module.ModelDisplay.Car.TractorModelDisplayPanel();

            modelDisplayPane.Location = new System.Drawing.Point(200, 0);
            modelDisplayPane.InitializeExamComponent(csetting, mon, stateMgr);
            this.ctrlPanel.Controls.Add(modelDisplayPane);

            /**
             * //初始化车型列表
             * List<string> cxList = new List<string>(2);
             * cxList.Add("A");
             * cxList.Add("B");
             *
             * //初始化排队列表
             * CandidateQuery candQuery = new CandidateQuery();
             * candQuery.Location = new System.Drawing.Point(550, 20);
             * //sd.BorderStyle = BorderStyle.Fixed3D;
             * this.ctrlPanel.Controls.Add(candQuery);
             *
             * //用哪个Candidate Infomation Panel
             * CandExamCtrl candExamPane = new Cn.Youdundianzi.Share.Module.CandidateInfo.LocalInputPanel();
             * candExamPane.Location = new System.Drawing.Point(0, 150);
             * candExamPane.InitializeCandExamCtrlComponent(examCtrl, csetting, cxList);
             * this.ctrlPanel.Controls.Add(candExamPane);
             *
             * //初始化声音控件(基础声音控件类)
             * SoundCtrl soundCtrl = new SoundCtrl();
             * candExamPane.SoundChange += new MessageDelegate(soundCtrl.PlayText);    //注册candExamCtrl的声音变化事件回调函数
             *
             * //初始化显示牌控件
             * //------------------------------------------------------------------------------
             * string LEDAssemblyFilePath = Application.StartupPath + "\\LEDDisplay.dll";
             *
             * SettingPair spDisplay = new SettingPair();
             * spDisplay.ImplementClass = AssemblyInfoFactory.GetType(LEDAssemblyFilePath, csetting.DisplayPaneConfig.DisplayConfigClass);
             * spDisplay.FilePath = csetting.DisplayPaneConfig.DisplayConfigFilePath;
             *
             * ISettings dissettings = new CSetup(spDisplay).Settings;
             * DisplayConfig dispalySetting = dissettings as DisplayConfig;
             * IDisplaycomm displaycomm = DisplayFactory.CreateDisplay(LEDAssemblyFilePath, csetting.DisplayPaneConfig.DisplayCommClass, dispalySetting);
             * candExamPane.LEDDisplayChange += new MessageDelegate(displaycomm.ShowText); //注册candExamCtrl的显示牌变化事件回调函数
             *
             *
             * //初始化摄像头
             * Camera camera = new Camera(0);
             * camera.Location = new System.Drawing.Point(200, 400);
             * camera.Size = new Size(400, 300);
             * camera.BorderStyle = BorderStyle.Fixed3D;
             * this.ctrlPanel.Controls.Add(camera);
             * candExamPane.CameraChannelChange += new IntegerDelegate(camera.SetChannel); //注册candExamCtrl的摄像头变化事件回调函数
             *
             * //结果显示控件
             * ExamResultPanel resultPanel = new ExamResultPanel();
             * resultPanel.Location = new System.Drawing.Point(0, 400);
             * resultPanel.Size = new Size(210, 110);
             * resultPanel.BorderStyle = BorderStyle.FixedSingle;
             * candExamPane.ExamResultReady += new ExamResultDelegate(resultPanel.SetResultText);
             **/
        }
Exemple #2
0
        private void ExamFrm_Load(object sender, EventArgs e)
        {
            if (_pracConfig == null)
            {
                MessageBox.Show("ExamConfig属性未赋值。");
                this.Close();
                return;
            }

            if (IsExam)
            {
                this.Text = "考试窗口";
            }
            else
            {
                this.Text = "练习窗口";
            }

            //
            //读取设置文件,准备环境设置
            //
            //用哪个setting
            SettingPair sp = new SettingPair();

            sp.ImplementClass = AssemblyInfoFactory.GetType(PracticeConfig.Setting.ClsFilePath, PracticeConfig.Setting.ClsName);
            sp.FilePath       = PracticeConfig.Setting.ConfigFilePath;

            ISettings setting  = new CSetup(sp).Settings;
            CSettings csetting = setting as CSettings;

            //
            //创建Monitor,Translator,StateManager。
            //准备考试核心引擎
            //
            //用哪个monitor
            AssemblyInfoPair monInfo = AssemblyInfoFactory.GetAssemblyInfo(PracticeConfig.Monitor.ClsFilePath, PracticeConfig.Monitor.ClsName);

            mon = SignalMonitorFactory.CreateSignalMonitor(monInfo, setting);

            //用哪个translator
            AssemblyInfoPair transInfo = AssemblyInfoFactory.GetAssemblyInfo(PracticeConfig.Translator.ClsFilePath, PracticeConfig.Translator.ClsName);

            translator = TranslatorFactory.CreateTranslater(transInfo, mon);

            //用哪个statemanager
            AssemblyInfoPair stateMgrInfo = AssemblyInfoFactory.GetAssemblyInfo(PracticeConfig.StateManager.ClsFilePath, PracticeConfig.StateManager.ClsName);

            stateMgr = StateManagerFactory.CreateStateManager(stateMgrInfo, translator, setting);

            //
            //创建考试启动停止控件
            //实现单会合考试
            examCtrl.Anchor = AnchorStyles.None;
            examCtrl.Dock   = DockStyle.Fill;
            this.paneExamCtrl.Controls.Add(examCtrl);

            //ExamCtrl控件必须先被add到其父窗口中,然后再进行Initialize
            examCtrl.InitializeExamComponent(setting, mon, translator, stateMgr);

            //初始化声音控件(基础声音控件类)
            SoundCtrl soundCtrl = new SoundCtrl();


            //初始化显示牌控件
            SettingPair spDisplay = new SettingPair();

            spDisplay.ImplementClass = AssemblyInfoFactory.GetType(PracticeConfig.LEDConfig.ClsFilePath, PracticeConfig.LEDConfig.ClsName);
            spDisplay.FilePath       = PracticeConfig.LEDConfig.ConfigFilePath;

            ISettings     dissettings    = new CSetup(spDisplay).Settings;
            DisplayConfig dispalySetting = dissettings as DisplayConfig;

            displaycomm = DisplayFactory.CreateDisplay(PracticeConfig.LED.ClsFilePath, PracticeConfig.LED.ClsName, dispalySetting);

            //初始化摄像头
            Camera camera = new Camera(0);

            camera.Anchor = AnchorStyles.None;
            camera.Dock   = DockStyle.Fill;
            this.groupPanelVideo.Controls.Add(camera);
            this.Move        += new EventHandler(camera.Camera_Move);
            this.FormClosing += new FormClosingEventHandler(camera.Camera_Closing);

            if (IsExam)
            {
                string[] cxs = ExamConfig.LicenseList.Split(new char[] { ';' });
                //初始化车型列表
                List <string> cxList = new List <string>(cxs);

                //用哪个Candidate Infomation Panel
                CandExamCtrl candExamPane;

                if (ExamConfig.HasQueue)
                {
                    //初始化排队列表
                    CandidateQuery candQuery = new CandidateQuery();
                    candQuery.Anchor = AnchorStyles.None;
                    candQuery.Dock   = DockStyle.Fill;
                    this.paneXQueueList.Controls.Add(candQuery);

                    candExamPane = (CandExamCtrl)CreateModule(ExamConfig.ExamCtrl.ClsFilePath, ExamConfig.ExamCtrl.ClsName, new object[] { candQuery });
                }
                else
                {
                    candExamPane = (CandExamCtrl)CreateModule(ExamConfig.ExamCtrl.ClsFilePath, ExamConfig.ExamCtrl.ClsName, new object[] { });
                }

                candExamPane.Dock = DockStyle.Fill;
                candExamPane.InitializeCandExamCtrlComponent(examCtrl, csetting, cxList);
                this.groupPanelCandInfo.Controls.Add(candExamPane);

                //结果显示控件
                ExamResultPanel resultPanel = new ExamResultPanel();
                resultPanel.Anchor            = AnchorStyles.None;
                resultPanel.Dock              = DockStyle.Fill;
                candExamPane.ExamResultReady += new ExamResultDelegate(resultPanel.SetResultText);
                this.paneXResult.Controls.Add(resultPanel);

                candExamPane.SoundChange         += new MessageDelegate(soundCtrl.PlayText);   //注册candExamCtrl的声音变化事件回调函数
                candExamPane.LEDDisplayChange    += new MessageDelegate(displaycomm.ShowText); //注册candExamCtrl的显示牌变化事件回调函数
                candExamPane.CameraChannelChange += new IntegerDelegate(camera.SetChannel);    //注册candExamCtrl的摄像头变化事件回调函数
            }

            //创建考试状态显示面板
            //单会合考试级别扩展功能
            ExamStatusDisplayPanel statePane = new ExamStatusDisplayPanel();

            statePane.Anchor = AnchorStyles.None;
            statePane.InitializeExamComponent(stateMgr);
            this.paneXStatus.Controls.Add(statePane);

            //创建信号显示面板
            SignalDisplay signaldisplay = new SignalDisplay(mon);

            signaldisplay.Anchor = AnchorStyles.None;
            signaldisplay.Dock   = DockStyle.Fill;
            this.paneXSignalDisp.Controls.Add(signaldisplay);

            //用哪个DisplayPanel
            BaseModelDisplayPanel modelDisplayPane = (BaseModelDisplayPanel)CreateModule(PracticeConfig.ModelDisplay.ClsFilePath, PracticeConfig.ModelDisplay.ClsName, new object[] { });

            modelDisplayPane.Anchor = AnchorStyles.None;
            modelDisplayPane.InitializeExamComponent(csetting, mon, stateMgr);
            this.groupPanelModelDisp.Controls.Add(modelDisplayPane);
        }