예제 #1
0
        /// <summary>
        /// コンストラクタ(与えられた入出力情報で初期化)
        /// </summary>
        /// <param name="state">入出力情報</param>
        /// <param name="hiragana">ひらがなフラグ</param>
        public ConfigureLP(stRobotIOStatus state, bool hiragana = false)
            : this(hiragana)
        {
            this.ioStatus = state;
            // 引数でモータとセンサのチェックボックスを初期化
            cbDCM1.Checked  = state.fDCMotor1Used;
            cbDCM2.Checked  = state.fDCMotor2Used;
            cbSVD5.Checked  = state.fSvMotor1Used;
            cbSVD6.Checked  = state.fSvMotor2Used;
            cbSVD9.Checked  = state.fSvMotor3Used;
            cbSVD10.Checked = state.fSvMotor4Used;
            cbSVD11.Checked = state.fSvMotor5Used;
            cbSIn1.Checked  = state.fSns1Used;
            cbSIn2.Checked  = state.fSns2Used;
            cbSIn3.Checked  = state.fSns3Used;
            cbSIn4.Checked  = state.fSns4Used;
            cbSIn5.Checked  = state.fSns5Used;
            cbSIn6.Checked  = state.fSns6Used;
            cbLEDD5.Checked = (state as stRobotIOStatusLP).fLED1Used;
            cbLEDD6.Checked = (state as stRobotIOStatusLP).fLED2Used;
            cbLEDD9.Checked = (state as stRobotIOStatusLP).fLED3Used;
            cbClock.Checked = (state as stRobotIOStatusLP).fClockUsed;

            // コンボボックスの選択を初期化
            cbbSIn1.SelectedItem = si.strOptionParts[state.nSns1Kind];
            cbbSIn2.SelectedItem = si.strOptionParts[state.nSns2Kind];
            cbbSIn3.SelectedItem = si.strOptionParts[state.nSns3Kind];
            cbbSIn4.SelectedItem = si.strOptionParts[state.nSns4Kind];
            cbbSIn5.SelectedItem = si.strOptionParts[state.nSns5Kind];
            cbbSIn6.SelectedItem = si.strOptionParts[state.nSns6Kind];
        }
예제 #2
0
        public CalibrationBase(ServoOffset offsetInfo, stRobotIOStatus io, bool hiragana = false)
            : this()
        {
            this.offsetInfo = offsetInfo;
            this.io         = io;
            if (hiragana)
            {
                this.Load += new EventHandler(CalibrationBase_Load);
            }

            // DCモーター校正メニュー初期化
            byte m1Rate = offsetInfo.getDCCalibInfo().calibM1Rate;
            byte m2Rate = offsetInfo.getDCCalibInfo().calibM2Rate;

            Debug.Write("Pin: " + m1Rate);
            tbM1.Value       = (int)(255 * m1Rate / 100.0);
            lbDCM1Value.Text = tbM1.Value.ToString();
            tbM2.Value       = (int)(255 * m2Rate / 100.0);

            lbDCM2Value.Text = tbM2.Value.ToString();
            // 初期化完了後にイベント登録
            this.tbM1.ValueChanged += new EventHandler(tb_ValueChanged);
            this.tbM2.ValueChanged += new EventHandler(tb_ValueChanged);

            // M1/M2どちらかが未使用の場合は機能をオフにする
            if (!(io.fDCMotor1Used && io.fDCMotor2Used))
            {
                gbDC.Enabled = false;
            }
        }
예제 #3
0
        public CalibrationLP(ServoOffset svoff, stRobotIOStatus io, TestModeCommunication tcom, bool hiragana = false)
            : base(svoff, io, hiragana)
        {
            InitializeComponent();

            this.tcom = tcom;

            saD5.nudAngle.Value  = svoff.getValue(0);
            saD6.nudAngle.Value  = svoff.getValue(1);
            saD9.nudAngle.Value  = svoff.getValue(2);
            saD10.nudAngle.Value = svoff.getValue(3);
            saD11.nudAngle.Value = svoff.getValue(4);

            saD5.nudAngle.ValueChanged  += new EventHandler(nudAngle_ValueChanged);
            saD6.nudAngle.ValueChanged  += new EventHandler(nudAngle_ValueChanged);
            saD9.nudAngle.ValueChanged  += new EventHandler(nudAngle_ValueChanged);
            saD10.nudAngle.ValueChanged += new EventHandler(nudAngle_ValueChanged);
            saD11.nudAngle.ValueChanged += new EventHandler(nudAngle_ValueChanged);

            saD5.Enabled  = io.fSvMotor1Used;
            saD6.Enabled  = io.fSvMotor2Used;
            saD9.Enabled  = io.fSvMotor3Used;
            saD10.Enabled = io.fSvMotor4Used;
            saD11.Enabled = io.fSvMotor5Used;

            // サーボモーターの初期設定
            if (saD5.Enabled)
            {
                setServoMotor(PinID.D5, svoff.getValue(0));
            }
            if (saD6.Enabled)
            {
                setServoMotor(PinID.D6, svoff.getValue(1));
            }
            if (saD9.Enabled)
            {
                setServoMotor(PinID.D9, svoff.getValue(2));
            }
            if (saD10.Enabled)
            {
                setServoMotor(PinID.D10, svoff.getValue(3));
            }
            if (saD11.Enabled)
            {
                setServoMotor(PinID.D11, svoff.getValue(4));
            }

            // DCモーター速度設定(DCモーター2つが有効な時のみ)
            if (io.fDCMotor1Used && io.fDCMotor2Used)
            {
                setDCMotorPower(0, (byte)tbM1.Value);
                setDCMotorPower(1, (byte)tbM2.Value);
            }
        }
예제 #4
0
        public ConfigureST(stRobotIOStatus state, bool hiragana = false)
            : this(hiragana)
        {
            this.ioStatus = state;
            // 引数でモータとセンサのチェックボックスを初期化
            cbDCM1.Checked  = state.fDCMotor1Used;
            cbDCM2.Checked  = state.fDCMotor2Used;
            cbSVD9.Checked  = state.fSvMotor1Used;
            cbSVD10.Checked = state.fSvMotor2Used;
            cbSVD11.Checked = state.fSvMotor3Used;
            cbSVD12.Checked = state.fSvMotor4Used;
            cbSVD2.Checked  = state.fSvMotor5Used;
            cbSVD4.Checked  = state.fSvMotor6Used;
            cbSVD7.Checked  = state.fSvMotor7Used;
            cbSVD8.Checked  = state.fSvMotor8Used;
            cbSIn1.Checked  = state.fSns1Used;
            cbSIn2.Checked  = state.fSns2Used;
            cbSIn3.Checked  = state.fSns3Used;
            cbSIn4.Checked  = state.fSns4Used;
            cbSIn5.Checked  = state.fSns5Used;
            cbSIn6.Checked  = state.fSns6Used;
            cbSIn7.Checked  = state.fSns7Used;
            cbSIn8.Checked  = state.fSns8Used;

            // TODO: ひらがな対応
            cbbSIn1.SelectedItem = si.strOptionParts[state.nSns1Kind];
            cbbSIn2.SelectedItem = si.strOptionParts[state.nSns2Kind];
            cbbSIn3.SelectedItem = si.strOptionParts[state.nSns3Kind];
            cbbSIn4.SelectedItem = si.strOptionParts[state.nSns4Kind];
            cbbSIn5.SelectedItem = si.strOptionParts[state.nSns5Kind];
            cbbSIn6.SelectedItem = si.strOptionParts[state.nSns6Kind];
            cbbSIn7.SelectedItem = si.strOptionParts[state.nSns7Kind];
            cbbSIn8.SelectedItem = si.strOptionParts[state.nSns8Kind];

            cbBIn1.Checked = state.fBtn1Used;
            cbBIn2.Checked = state.fBtn2Used;
            cbBIn3.Checked = state.fBtn3Used;
            cbBIn4.Checked = state.fBtn4Used;
        }
예제 #5
0
        public CalibrationST(ServoOffset offset, stRobotIOStatus io, ICommandSender com, bool hiragana = false)
            : base(offset, io, hiragana)
        {
            InitializeComponent();

            this.com = com;
            comgen   = new TestModeCommand();

            saD9.nudAngle.Value  = offset.getValue(0);
            saD10.nudAngle.Value = offset.getValue(1);
            saD11.nudAngle.Value = offset.getValue(2);
            saD12.nudAngle.Value = offset.getValue(3);
            saD2.nudAngle.Value  = offset.getValue(4);
            saD4.nudAngle.Value  = offset.getValue(5);
            saD7.nudAngle.Value  = offset.getValue(6);
            saD8.nudAngle.Value  = offset.getValue(7);

            saD9.nudAngle.ValueChanged  += new EventHandler(nudAngle_ValueChanged);
            saD10.nudAngle.ValueChanged += new EventHandler(nudAngle_ValueChanged);
            saD11.nudAngle.ValueChanged += new EventHandler(nudAngle_ValueChanged);
            saD12.nudAngle.ValueChanged += new EventHandler(nudAngle_ValueChanged);
            saD2.nudAngle.ValueChanged  += new EventHandler(nudAngle_ValueChanged);
            saD4.nudAngle.ValueChanged  += new EventHandler(nudAngle_ValueChanged);
            saD7.nudAngle.ValueChanged  += new EventHandler(nudAngle_ValueChanged);
            saD8.nudAngle.ValueChanged  += new EventHandler(nudAngle_ValueChanged);

            saD9.Enabled  = io.fSvMotor1Used;
            saD10.Enabled = io.fSvMotor2Used;
            saD11.Enabled = io.fSvMotor3Used;
            saD12.Enabled = io.fSvMotor4Used;
            saD2.Enabled  = io.fSvMotor5Used;
            saD4.Enabled  = io.fSvMotor6Used;
            saD7.Enabled  = io.fSvMotor7Used;
            saD8.Enabled  = io.fSvMotor8Used;

            com.Disconnected += new EventHandler(com_Disconnected);
        }
예제 #6
0
        // 0: Studuino 1: Studuino mini
        void testConfigure(int boardtype = 0, bool hiragana = false)
        {
            int ionum = (boardtype == 0) ? 18 : 19;

            //stRobotIOStatusLP io = new stRobotIOStatusLP();
            stRobotIOStatus io = (boardtype == 0) ? new stRobotIOStatus() : new stRobotIOStatusLP();

            try
            {
                BinaryReader br        = (boardtype == 0) ? new BinaryReader(File.OpenRead(IOFILE)) : new BinaryReader(File.OpenRead(IOFILEMINI)); // ファイルオープン
                byte[]       scratchIO = new byte[ionum];                                                                                          // I/O設定を保存する配列の確保
                for (int i = 0; i < ionum; i++)
                {
                    // 配列にI/O設定を読み込む
                    scratchIO[i] = br.ReadByte();
                }
                io.setStatusByte(scratchIO);
                br.Close();
            }
            catch (FileNotFoundException)
            {
                io.initRobotIOConfiguration();
            }

            if (boardtype == 0)
            {
                using (ConfigureBase setting = new ConfigureST(io, hiragana))
                {
                    if (setting.ShowDialog() == DialogResult.OK)
                    {
                        File.Delete(IOFILE); // ファイルを削除し、新しくファイルを作成する
                        BinaryWriter bw  = new BinaryWriter(File.OpenWrite(IOFILE));
                        List <byte>  lst = io.getStatusByte();
                        foreach (byte elm in lst)
                        {
                            Debug.WriteLine(elm.ToString());
                            bw.Write(elm);
                        }
                        bw.Close();
                    }
                }
                //using (Configure setting = hiragana ? new Configure(io, 3) : new Configure(io))
                //{
                //    if (setting.ShowDialog() == DialogResult.OK)
                //    {
                //        io = setting.getConfiguration();
                //        File.Delete(IOFILE); // ファイルを削除し、新しくファイルを作成する
                //        BinaryWriter bw = new BinaryWriter(File.OpenWrite(IOFILE));
                //        List<byte> lst = io.getStatusByte();
                //        foreach (byte elm in lst)
                //        {
                //            bw.Write(elm);
                //        }
                //        bw.Close();
                //    }
                //}
            }
            else
            {
                using (ConfigureBase setting = new ConfigureLP(io, hiragana))
                {
                    if (setting.ShowDialog() == DialogResult.OK)
                    {
                        File.Delete(IOFILE); // ファイルを削除し、新しくファイルを作成する
                        BinaryWriter bw  = new BinaryWriter(File.OpenWrite(IOFILE));
                        List <byte>  lst = io.getStatusByte();
                        foreach (byte elm in lst)
                        {
                            Debug.WriteLine(elm.ToString());
                            bw.Write(elm);
                        }
                        bw.Close();
                    }
                }
            }
        }