예제 #1
0
        private void ControlForm_Load(object sender, EventArgs e)
        {
            br = new Bridge();

            br.Attach += new AttachEventHandler(Br_Attach);
            br.Detach += new DetachEventHandler(Br_Detach);
            br.Error  += new Phidgets.Events.ErrorEventHandler(Br_Error);

            br.BridgeData += new BridgeDataEventHandler(Br_Data);

            OpenCmdLine(br);

            // 構成ファイルから設定取得
            var appPath    = Assembly.GetExecutingAssembly().Location;
            var configPath = Path.GetDirectoryName(appPath);
            var configFile = configPath + "\\app.config";
            var exeFileMap = new ExeConfigurationFileMap {
                ExeConfigFilename = configFile
            };
            var config = ConfigurationManager.OpenMappedExeConfiguration(exeFileMap, ConfigurationUserLevel.None);

            RightIntercept.Text = config.AppSettings.Settings["Calib_R_y"].Value;
            LeftIntercept.Text  = config.AppSettings.Settings["Calib_L_y"].Value;
            RightSlope.Text     = config.AppSettings.Settings["Calib_R_x"].Value;
            LeftSlope.Text      = config.AppSettings.Settings["Calib_L_x"].Value;

            IpAddressBox.Text = config.AppSettings.Settings["PlcIpAdr"].Value;
            PortBox.Text      = config.AppSettings.Settings["PlcPort"].Value;

            //トラバース制御データ一式バックアップ
            TraverseController ctl = new TraverseController();

            ctl.InitTraverseControl(IpAddressBox.Text, Int32.Parse(PortBox.Text));

            // ログ出力設定
            IntLogging();
        }
예제 #2
0
        // トラバース制御
        private bool ControlTraversal()
        {
            var result  = false;
            var ctlId   = 0;
            var trvCtlr = new TraverseController();

            // 制御ロジック
            // 1) 両耳高
            if ((LeftTenStatus.TenAve > LeftTenStatus.TenMax) & (RightTenStatus.TenAve > RightTenStatus.TenMax))
            {
                // オサ幅を狭くする(強)
                ctlId = 1;
            }
            // 2) 左耳高、右耳低
            else if ((LeftTenStatus.TenAve > LeftTenStatus.TenMax) & (RightTenStatus.TenAve < RightTenStatus.TenMin))
            {
                // オサ位置を右へ移動(強)
                ctlId = 2;
            }
            // 3) 左耳高
            else if ((LeftTenStatus.TenAve > LeftTenStatus.TenMax) &
                     (RightTenStatus.TenAve > RightTenStatus.TenMin) & (RightTenStatus.TenAve < RightTenStatus.TenMax))
            {
                // オサ位置を右へ移動(弱)
                // オサ幅を狭める(弱)
                ctlId = 3;
            }
            // 4) 左耳低、右耳高
            else if ((LeftTenStatus.TenAve < LeftTenStatus.TenMin) & (RightTenStatus.TenAve > RightTenStatus.TenMax))
            {
                // オサ位置を左へ移動(強)
                ctlId = 4;
            }
            // 5) 右耳高
            else if ((LeftTenStatus.TenAve < LeftTenStatus.TenMax) & (LeftTenStatus.TenAve > LeftTenStatus.TenMin) &
                     (RightTenStatus.TenAve > RightTenStatus.TenMax))
            {
                // オサ位置を左へ移動(弱)
                // オサ幅を狭める(弱)
                ctlId = 5;
            }
            // 6) 左耳低
            else if ((LeftTenStatus.TenAve < LeftTenStatus.TenMin) &
                     (RightTenStatus.TenAve > RightTenStatus.TenMin) & (RightTenStatus.TenAve < RightTenStatus.TenMax))
            {
                // オサ幅を広げる(弱)
                // オサ位置を左へ移動(弱)
                ctlId = 6;
            }
            // 7) 右耳低
            else if ((LeftTenStatus.TenAve < LeftTenStatus.TenMax) & (LeftTenStatus.TenAve > LeftTenStatus.TenMin) &
                     (RightTenStatus.TenAve < RightTenStatus.TenMin))
            {
                // オサ幅を広げる(弱)
                // オサ位置を右へ移動(弱)
                ctlId = 7;
            }
            // 8) 両耳低傾向
            else if ((LeftTenStatus.TenAve < LeftTenStatus.TenMin) & (RightTenStatus.TenAve < RightTenStatus.TenMin))
            {
                // オサ幅を広げる(強)
                ctlId = 8;
            }
            // 9) 正常範囲
            else
            {
                // 制御なし
                ctlId = 9;
            }

            // 制御開始
            result = trvCtlr.TraverseControl(IpAddressBox.Text, Int32.Parse(PortBox.ToString()), ctlId);

            // リセット
            ControlValueReset();

            return(result);
        }