示例#1
0
 public static void BotEvaluateScript(string str)
 {
     if (webSocketState == 2 && !rebooting)
     {
         bot.EvaluateScript(str);
     }
 }
示例#2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            bot = new Botnana("192.168.7.2");

            onWsErrorCallback = new HandleMessage(OnWsErrorCB);
            bot.SetOnErrorCB(IntPtr.Zero, onWsErrorCallback);

            onMessageCallback = new HandleMessage(HandleMessageCB);
            bot.SetOnMessageCB(IntPtr.Zero, onMessageCallback);

            slavesRespondingCallback = new HandleMessage(SlavesRespondingCB);
            bot.SetTagCB("slaves_responding", 0, IntPtr.Zero, slavesRespondingCallback);

            statusWordCallback = new HandleMessage(StatusWordCB);
            bot.SetTagCB("status_word.1.1", 0, IntPtr.Zero, statusWordCallback);

            realPositionCallback = new HandleMessage(RealPositionCB);
            bot.SetTagCB("real_position.1.1", 0, IntPtr.Zero, realPositionCallback);

            targetPositionCallback = new HandleMessage(TargetPositionCB);
            bot.SetTagCB("target_position.1.1", 0, IntPtr.Zero, targetPositionCallback);

            opModeCallback = new HandleMessage(OpModeCB);
            bot.SetTagCB("operation_mode.1.1", 0, IntPtr.Zero, opModeCallback);

            digitalInputsCallback = new HandleMessage(DigitalInputsCB);
            bot.SetTagCB("digital_inputs.1.1", 0, IntPtr.Zero, digitalInputsCallback);

            profileVelocityCallback = new HandleMessage(ProfileVelocityCB);
            bot.SetTagCB("profile_velocity.1.1", 0, IntPtr.Zero, profileVelocityCallback);

            profileAccelerationCallback = new HandleMessage(ProfileAccelerationCB);
            bot.SetTagCB("profile_acceleration.1.1", 0, IntPtr.Zero, profileAccelerationCallback);

            deployedCallback = new HandleMessage(DeployedCB);
            bot.SetTagCB("deployed", 0, IntPtr.Zero, deployedCallback);

            endOfProgramCallback = new HandleMessage(EndOfProgramCB);
            bot.SetTagCB("end-of-program", 0, IntPtr.Zero, endOfProgramCallback);

            errorCallback = new HandleMessage(ErrorCB);
            bot.SetTagCB("error", 0, IntPtr.Zero, errorCallback);

            bot.Connect();
            Thread.Sleep(1000);

            bot.EvaluateScript(".ec-links");
            bot.EvaluateScript("1 .slave");
            timer1.Interval = 50;
            timer1.Enabled  = true;
        }
 private void textBoxScript_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.ShiftKey)
     {
         preventEvaluate = false;
     }
     else if (e.KeyCode == Keys.Enter && !preventEvaluate)
     {
         botnana.EvaluateScript((sender as TextBox).Text);
         (sender as TextBox).Text = "";
     }
 }
示例#4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            bot = new Botnana("192.168.7.2");

            onWsErrorCallback = new HandleMessage(OnWsErrorCB);
            bot.SetOnErrorCB(IntPtr.Zero, onWsErrorCallback);

            sdoIndexCallback = new HandleMessage(SdoIndexCB);
            bot.SetTagCB("sdo_index.1", 0, IntPtr.Zero, sdoIndexCallback);

            sdoSubindexCallback = new HandleMessage(SdoSubindexCB);
            bot.SetTagCB("sdo_subindex.1", 0, IntPtr.Zero, sdoSubindexCallback);

            sdoErrorCallback = new HandleMessage(SdoErrorCB);
            bot.SetTagCB("sdo_error.1", 0, IntPtr.Zero, sdoErrorCallback);

            sdoBusyCallback = new HandleMessage(SdoBusyCB);
            bot.SetTagCB("sdo_busy.1", 0, IntPtr.Zero, sdoBusyCallback);

            sdoDataCallback = new HandleMessage(SdoDataCB);
            bot.SetTagCB("sdo_data.1", 0, IntPtr.Zero, sdoDataCallback);

            realPositionCallback = new HandleMessage(RealPositionCB);
            bot.SetTagCB("real_position.1.1", 0, IntPtr.Zero, realPositionCallback);

            digitalInputsCallback = new HandleMessage(DigitalInputsCB);
            bot.SetTagCB("digital_inputs.1.1", 0, IntPtr.Zero, digitalInputsCallback);

            opModeCallback = new HandleMessage(OpModeCB);
            bot.SetTagCB("operation_mode.1.1", 0, IntPtr.Zero, opModeCallback);

            statusWordCallback = new HandleMessage(StatusWordCB);
            bot.SetTagCB("status_word.1.1", 0, IntPtr.Zero, statusWordCallback);

            errorCallback = new HandleMessage(ErrorCB);
            bot.SetTagCB("error", 0, IntPtr.Zero, errorCallback);

            homingCallback = new HandleMessage(HomingCB);
            bot.SetTagCB("homing", 0, IntPtr.Zero, homingCallback);

            slavesRespondingCallback = new HandleMessage(SlavesRespondingCB);
            bot.SetTagCB("slaves_responding", 1, IntPtr.Zero, slavesRespondingCallback);
            bot.Connect();
            Thread.Sleep(1000);
            bot.EvaluateScript(".ec-links 0 $60B8 1 sdo-upload-i16 1 .slave");

            timer1.Interval = 50;
            timer1.Enabled  = true;
        }
示例#5
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (slaveLen > 0)
            {
                bot.EvaluateScript("1 .sdo 1 .slave-diff");
                textSDOAddress.Text = sdoIndex.ToString("X4") + ":" + sdoSubindex.ToString("X2");

                textSDOError.Text = sdoErrorStr;
                textSDOBusy.Text  = sdoBusyStr;
                textSDOData.Text  = sdoData.ToString();

                textRealPosition.Text  = realPositionStr;
                textDigitalInputs.Text = digitalInputsStr;
                textOPMode.Text        = opModeStr;
                textStatusWord.Text    = statusWordStr;

                // 如果SDO 已經設定完成
                if (sdoBusyStr == "false")
                {
                    if (hasNewSetting)
                    {
                        // 如果有新的設定值,就設定 0x60B8 暫存器
                        bot.EvaluateScript(newSetting.ToString() + " 0 $60B8 1 sdo-download-i16");
                        hasNewSetting = false;
                    }
                    else if (sdoIndex == 0x60B8)
                    {
                        // 依 60B8 的讀值設定畫面上的 radio 元件
                        if (!isInited)
                        {
                            newSetting              = sdoData;
                            radioTp1Enable.Checked  = (sdoData & 0x1) != 0;
                            radioTp1Cont.Checked    = (sdoData & 0x2) != 0;
                            radioTp1Rising.Checked  = (sdoData & 0x10) != 0;
                            radioTp1Falling.Checked = (sdoData & 0x20) != 0;
                            radioTp2Enable.Checked  = (sdoData & 0x100) != 0;
                            radioTp2Cont.Checked    = (sdoData & 0x200) != 0;
                            radioTp2Rising.Checked  = (sdoData & 0x1000) != 0;
                            radioTp2Falling.Checked = (sdoData & 0x2000) != 0;
                            isInited = true;
                        }
                        // 使用 SDO 取回 0x60B9 (Touch porbe status) 暫存器內容
                        bot.EvaluateScript("0 $60B9 1 sdo-upload-i16");
                    }
                    else if (sdoIndex == 0x60B9)
                    {
                        // 依 60B9 的讀值設定畫面上的 radio 元件
                        radioTp1Enabled.Checked    = (sdoData & 0x1) != 0;
                        radioTp1HasRising.Checked  = (sdoData & 0x2) != 0;
                        radioTp1HasFalling.Checked = (sdoData & 0x4) != 0;
                        radioTp2Enabled.Checked    = (sdoData & 0x100) != 0;
                        radioTp2HasRising.Checked  = (sdoData & 0x200) != 0;
                        radioTp2HasFalling.Checked = (sdoData & 0x400) != 0;

                        // 使用 SDO 取回 0x60BA (Touch probe pos1 pos value) 暫存器內容
                        bot.EvaluateScript("0 $60BA 1 sdo-upload-i32");
                    }
                    else if (sdoIndex == 0x60BA)
                    {
                        // 更新 Touch probe pos1 pos value 的 text 元件
                        textTp1Pos1.Text = sdoData.ToString();
                        // 使用 SDO 取回 0x60BB (Touch probe pos1 neg value) 暫存器內容
                        bot.EvaluateScript("0 $60BB 1 sdo-upload-i32");
                    }
                    else if (sdoIndex == 0x60BB)
                    {
                        // 更新 Touch probe pos1 neg value 的 text 元件
                        textTp1Pos2.Text = sdoData.ToString();
                        // 使用 SDO 取回 0x60BC (Touch probe pos2 pos value) 暫存器內容
                        bot.EvaluateScript("0 $60BC 1 sdo-upload-i32");
                    }
                    else if (sdoIndex == 0x60BC)
                    {
                        // 更新 Touch probe pos2 pos value 的 text 元件
                        textTp2Pos1.Text = sdoData.ToString();
                        // 使用 SDO 取回 0x60BD (Touch probe pos2 neg value) 暫存器內容
                        bot.EvaluateScript("0 $60BD 1 sdo-upload-i32");
                    }
                    else if (sdoIndex == 0x60BD)
                    {
                        // 更新 Touch probe pos2 neg value 的 text 元件
                        textTp2Pos2.Text = sdoData.ToString();
                        // 使用 SDO 取回 0x60B9 (Touch porbe status) 暫存器內容
                        bot.EvaluateScript("0 $60B9 1 sdo-upload-i16");
                    }
                }
            }
        }
示例#6
0
        public FormApp()
        {
            InitializeComponent();

            bot = new Botnana("192.168.7.2");

            // 啟動終端機,可幫助除錯,若不使用可不啟動。
            RunConsole();

            // On WebSocket open callback.
            onWSOpen = new HandleMessage((IntPtr dataPtr, string str) =>
            {
                webSocketState = 2;
                rebooting      = false;
                BeginInvoke(new Appdeg(() =>
                {
                    buttonWSState.Text      = "WebSocket ready";
                    buttonWSState.BackColor = Color.FromArgb(0x53, 0xFF, 0x53);
                }));
                // 送出 .user-para 命令,讓為回傳的訊息去觸發 OnUserParameterCallback
                // 若重複執行從 32 開始,因為需要 .device-infos 取得周邊裝置的資訊
                // .user-para 回應的訊息範例如下:
                // user_parameter|0
                bot.EvaluateScript(@"user-para@ 32 min user-para! .user-para");
                Console.WriteLine("WebSocket connected.");
            });
            bot.SetOnOpenCB(IntPtr.Zero, onWSOpen);

            // On WebSocket error callback.
            onWSError = new HandleMessage((IntPtr dataPtr, string str) =>
            {
                webSocketState = 0;
                slavesCount    = 0;
                hasSFC         = false;
                BeginInvoke(new Appdeg(() => {
                    buttonWSState.Text          = "WebSocket not ready";
                    buttonWSState.BackColor     = Color.FromArgb(0xFF, 0x2D, 0x2D);
                    buttonECState.Text          = "EtherCAT not ready(" + slavesCount.ToString() + ")";
                    buttonECState.BackColor     = Color.FromArgb(0xFF, 0x2D, 0x2D);
                    buttonSystemReady.Text      = "System not ready";
                    buttonSystemReady.BackColor = Color.FromArgb(0xFF, 0x2D, 0x2D);
                }));
                formTorque.Reset();
                formFeeder.Reset();
                formRCON.Reset();
                Console.WriteLine("WS error : " + str);
            });
            bot.SetOnErrorCB(IntPtr.Zero, onWSError);

            // On Message callback.
            onMessage = new HandleMessage((IntPtr dataPtr, string str) =>
            {
                Console.WriteLine("OnMessage : " + str);
            });
            bot.SetOnMessageCB(IntPtr.Zero, onMessage);

            // On Error tag callback
            onErrorMessage = new HandleMessage((IntPtr dataPtr, string str) =>
            {
                if (errorsLen < 3)
                {
                    errorsLen += 1;
                    new Thread(() =>
                    {
                        System.Windows.Forms.MessageBox.Show("Error|" + str);
                        errorsLen -= 1;
                    }).Start();
                }
                Console.WriteLine("Error|" + str);
            });
            bot.SetTagCB(@"error", 0, IntPtr.Zero, onErrorMessage);

            // On user_parameter tag callback.
            onUserParameter = new HandleMessage((IntPtr dataPtr, string str) =>
            {
                switch (Int32.Parse(str))
                {
                case 0:
                    Console.WriteLine("OnUserParameterCallback 0");
                    if (webSocketState == 2 && !rebooting)
                    {
                        // 設定 user parameter 為 16,如果此範例重新執行不會再載入以下 SFC
                        bot.EvaluateScript("16 user-para!");
                        // 清除SFC 邏輯,載入 SFC 時會造成 real time cycle overrun,所以要暫時 ignore-overrun
                        bot.EvaluateScript(@"ignore-overrun 0sfc -work marker -work");
                        bot.LoadSFC(@"config.fs");
                        bot.LoadSFC(@"sdo.fs");
                        bot.LoadSFC(@"torque.fs");
                        bot.LoadSFC(@"feeder.fs");
                        bot.LoadSFC(@"rcon.fs");
                        bot.LoadSFC(@"manager.fs");
                        bot.EvaluateScript(@"marker -app .user-para");
                    }
                    break;

                case 16:
                    Console.WriteLine("OnUserParameterCallback 16");
                    // 載入後執行 `reset-overrun`
                    BotEvaluateScript(@"reset-overrun 32 user-para! .user-para");
                    break;

                case 32:
                    Console.WriteLine("OnUserParameterCallback 32");
                    formTorque.Initialize();
                    formFeeder.Initialize();
                    formRCON.Initialize();
                    BotEvaluateScript(@"+coordinator 64 user-para! .user-para");
                    break;

                case 64:
                    Console.WriteLine("OnUserParameterCallback 64");
                    hasSFC = true;
                    break;

                default:
                    break;
                }
            });
            bot.SetTagCB(@"user_parameter", 0, IntPtr.Zero, onUserParameter);

            // On ec_ready tag callback.
            onECReady = new HandleMessage((IntPtr dataPtr, string str) =>
            {
                if (str == "1")
                {
                    BeginInvoke(new Appdeg(() => {
                        buttonECState.Text      = "EtherCAT ready(" + slavesCount.ToString() + ")";
                        buttonECState.BackColor = Color.FromArgb(0x53, 0xFF, 0x53);
                    }));
                }
                else
                {
                    BeginInvoke(new Appdeg(() => {
                        buttonECState.Text      = "EtherCAT not ready(" + slavesCount.ToString() + ")";
                        buttonECState.BackColor = Color.FromArgb(0xFF, 0x2D, 0x2D);
                    }));
                }
            });
            bot.SetTagCB(@"ec_ready", 0, IntPtr.Zero, onECReady);

            // On slaves_responding tag callback.
            onSlavesResponding = new HandleMessage((IntPtr dataPtr, string str) =>
            {
                slavesCount = int.Parse(str);
            });
            bot.SetTagCB(@"slaves_responding", 0, IntPtr.Zero, onSlavesResponding);

            // On system_ready tag callback.
            onSystemReady = new HandleMessage((IntPtr dataPtr, string str) =>
            {
                if (str == "-1")
                {
                    BeginInvoke(new Appdeg(() => {
                        buttonSystemReady.Text      = "System ready";
                        buttonSystemReady.BackColor = Color.FromArgb(0x53, 0xFF, 0x53);
                    }));
                }
                else
                {
                    BeginInvoke(new Appdeg(() => {
                        buttonSystemReady.Text      = "System not ready";
                        buttonSystemReady.BackColor = Color.FromArgb(0xFF, 0x2D, 0x2D);
                    }));
                }
            });
            bot.SetTagCB(@"system_ready", 0, IntPtr.Zero, onSystemReady);

            formTorque = new FormTorque();
            formFeeder = new FormFeeder();
            formRCON   = new FormRCON();
        }
示例#7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Process thisProc = Process.GetCurrentProcess();

            thisProc.PriorityClass = ProcessPriorityClass.RealTime;
            mcsPositions           = new double[3];
            pcsPositions           = new double[3];
            pva               = new double[3];
            axisHomed         = new int[3];
            axisRealPositions = new double[3];
            axisHomingV1      = new UInt32[3];
            axisHomingV2      = new UInt32[3];
            axisHomingMethod  = new UInt32[3];

            // 首先要連線到 Botnana Control, 當收到 WS 連線錯誤, 就呼叫 on_error_callback
            bot = new Botnana("192.168.7.2");
            bot.SetOnErrorCB(IntPtr.Zero, onWSError);

            // 當收到 Botnana Control 的訊息, 就呼叫 on_message_callback
            bot.SetOnMessageCB(IntPtr.Zero, onMessage);
            // 定義收到信息中指定的 Tag 時,所要呼叫的 callback 信息
            bot.SetTagCB("MCS.1", 0, IntPtr.Zero, onMcs);
            bot.SetTagCB("PCS.1", 0, IntPtr.Zero, onPcs);
            bot.SetTagCB("pva.1", 0, IntPtr.Zero, onPva);
            bot.SetTagCB("move_length.1", 0, IntPtr.Zero, onMoveLength);
            bot.SetTagCB("path_id.1", 0, IntPtr.Zero, onPathId);
            bot.SetTagCB("servo_on", 0, IntPtr.Zero, onServoOn);
            bot.SetTagCB("motion_state", 0, IntPtr.Zero, onMotionState);
            bot.SetTagCB("axis_corrected_position.1", 0, IntPtr.Zero, onAxisRealPositionX);
            bot.SetTagCB("axis_corrected_position.2", 0, IntPtr.Zero, onAxisRealPositionY);
            bot.SetTagCB("axis_corrected_position.3", 0, IntPtr.Zero, onAxisRealPositionZ);
            bot.SetTagCB("axis_homed.1", 0, IntPtr.Zero, onAxisHomedX);
            bot.SetTagCB("axis_homed.2", 0, IntPtr.Zero, onAxisHomedY);
            bot.SetTagCB("axis_homed.3", 0, IntPtr.Zero, onAxisHomedZ);
            bot.SetTagCB("nc_owner", 0, IntPtr.Zero, onNcOwner);
            bot.SetTagCB("nc_suspended", 0, IntPtr.Zero, onNcSuspended);
            bot.SetTagCB("devices_ok", 0, IntPtr.Zero, onDevicesOk);
            bot.SetTagCB("monitor_failed", 0, IntPtr.Zero, onMonitorFailed);
            bot.SetTagCB("rapid_travels_rate", 0, IntPtr.Zero, onRapidTravelsRate);
            bot.SetTagCB("machining_rate", 0, IntPtr.Zero, onMachiningRate);
            bot.SetTagCB("axis_homing_v1.1", 0, IntPtr.Zero, onAxisHomingV1X);
            bot.SetTagCB("axis_homing_v1.2", 0, IntPtr.Zero, onAxisHomingV1Y);
            bot.SetTagCB("axis_homing_v1.3", 0, IntPtr.Zero, onAxisHomingV1Z);
            bot.SetTagCB("axis_homing_v2.1", 0, IntPtr.Zero, onAxisHomingV2X);
            bot.SetTagCB("axis_homing_v2.2", 0, IntPtr.Zero, onAxisHomingV2Y);
            bot.SetTagCB("axis_homing_v2.3", 0, IntPtr.Zero, onAxisHomingV2Z);
            bot.SetTagCB("axis_homing_method.1", 0, IntPtr.Zero, onAxisHomingMethodX);
            bot.SetTagCB("axis_homing_method.2", 0, IntPtr.Zero, onAxisHomingMethodY);
            bot.SetTagCB("axis_homing_method.3", 0, IntPtr.Zero, onAxisHomingMethodZ);
            bot.SetTagCB("error", 0, IntPtr.Zero, onError);
            bot.SetTagCB("log", 0, IntPtr.Zero, onLog);
            bot.SetTagCB("user_parameter", 0, IntPtr.Zero, onUserParameter);
            bot.SetTagCB("deployed", 0, IntPtr.Zero, onDeployed);

            bot.Connect();
            Thread.Sleep(1000);
            // 要求  Botnana Control 送出 user parameter 訊息
            bot.EvaluateScript(".user-para");

            // 初始化 NC program 內容
            DataGridViewRowCollection rows = ncProgram.Rows;

            rows.Add(new Object[] { "1", "92", "0.0", "0.0", "0.0", "900.0" });
            rows.Add(new Object[] { "2", "01", "10", null, null, "500" });
            rows.Add(new Object[] { "3", "01", "20", null, null, "500" });
            rows.Add(new Object[] { "4", "01", "30", null, null, "500" });
            rows.Add(new Object[] { "5", "01", "40", null, null, "500" });
            rows.Add(new Object[] { "6", "01", "50", null, null, "600" });
            rows.Add(new Object[] { "7", "01", "60", null, null, "700" });
            rows.Add(new Object[] { "8", "01", "70", null, null, "800" });
            rows.Add(new Object[] { "9", "01", "80", null, null, "900" });
            rows.Add(new Object[] { "10", "01", "90", null, null, "1000" });

            // 設置 timer
            timer1.Interval = 50;
            timer1.Enabled  = true;
            timer2.Interval = 500;
            timer2.Enabled  = true;
        }
示例#8
0
 private void OnWSOpenCB(IntPtr ptr, string data)
 {
     bot.EvaluateScript(".user-para");
     wsReady = true;
 }
示例#9
0
 private void OnWsOpenCB(IntPtr dataPtr, string str)
 {
     wsState = 2;
     botnana.EvaluateScript(".user-para");
 }
示例#10
0
 private void UpdateData()
 {
     botnana.EvaluateScript(slaveNumber.ToString() + @" .sdo");
 }
示例#11
0
        private void OnUserParameterCallback(IntPtr dataPtr, string str)
        {
            int para = Int32.Parse(str);

            switch (para)
            {
            case 0:
                // 設定 user parameter 為 0x10
                // 如果此範例重新執行不會在載入以下 SFC
                //EvaluateScript("$10 user-para!");
                // 清除SFC 邏輯,載入 SFC 時會造成 real time cycle overrun,所以要暫時 ignore-overrun
                // 載入後再執行 `reset-overrun`
                bot.EvaluateScript("0sfc ignore-overrun");
                bot.EvaluateScript("-work marker -work");
                bot.LoadSFC(@"SDOUploadList.sfc");
                // 等待 SFC 設置完成
                Thread.Sleep(100);
                // 設定 SDOUploadList.sfc 中的 AIN 與 AOUT 模組的站號
                bot.EvaluateScript(DeltaAinSlavePosStr + " ain-slave-pos! " + DeltaAoutSlavePosStr + " aout-slave-pos! ");
                // send-param-request 是要求 AIN, AOUT 模組送回目前模式設定
                // 回傳的資料範例如下:
                // aout1_mode|3
                // aout2_mode|1
                // aout3_mode|0
                // aout4_mode|0
                // ain_mode|1
                bot.EvaluateScript("reset-overrun send-param-request");
                break;

            default:
                break;
            }
        }
示例#12
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (slavesCount > 0)
            {
                if (hasSlaveInfo)
                {
                    bot.EvaluateScript("2 .slave-diff 3 .slave-diff");
                }
                else
                {
                    bot.EvaluateScript("2 .slave 3 .slave");
                    hasSlaveInfo = true;
                }
            }

            labMessageCount.Text = messageCount.ToString("X2");
            textSlavesCount.Text = slavesCount.ToString();
            textSlavesState.Text = slavesState.ToString();
            checkDo1.Checked     = (doWord & 0x1) != 0;
            checkDo2.Checked     = (doWord & 0x2) != 0;
            checkDo3.Checked     = (doWord & 0x4) != 0;
            checkDo4.Checked     = (doWord & 0x8) != 0;
            checkDo5.Checked     = (doWord & 0x10) != 0;
            checkDo6.Checked     = (doWord & 0x20) != 0;
            checkDo7.Checked     = (doWord & 0x40) != 0;
            checkDo8.Checked     = (doWord & 0x80) != 0;
            checkDo9.Checked     = (doWord & 0x100) != 0;
            checkDo10.Checked    = (doWord & 0x200) != 0;
            checkDo11.Checked    = (doWord & 0x400) != 0;
            checkDo12.Checked    = (doWord & 0x800) != 0;
            checkDo13.Checked    = (doWord & 0x1000) != 0;
            checkDo14.Checked    = (doWord & 0x2000) != 0;
            checkDo15.Checked    = (doWord & 0x4000) != 0;
            checkDo16.Checked    = (doWord & 0x8000) != 0;

            checkDi1.Checked  = (diWord & 0x1) != 0;
            checkDi2.Checked  = (diWord & 0x2) != 0;
            checkDi3.Checked  = (diWord & 0x4) != 0;
            checkDi4.Checked  = (diWord & 0x8) != 0;
            checkDi5.Checked  = (diWord & 0x10) != 0;
            checkDi6.Checked  = (diWord & 0x20) != 0;
            checkDi7.Checked  = (diWord & 0x40) != 0;
            checkDi8.Checked  = (diWord & 0x80) != 0;
            checkDi9.Checked  = (diWord & 0x100) != 0;
            checkDi10.Checked = (diWord & 0x200) != 0;
            checkDi11.Checked = (diWord & 0x400) != 0;
            checkDi12.Checked = (diWord & 0x800) != 0;
            checkDi13.Checked = (diWord & 0x1000) != 0;
            checkDi14.Checked = (diWord & 0x2000) != 0;
            checkDi15.Checked = (diWord & 0x4000) != 0;
            checkDi16.Checked = (diWord & 0x8000) != 0;
        }
示例#13
0
 public void OnWSOpenCallback(IntPtr dataPtr, string data)
 {
     wsState = 2;
     // 送出 .user-para 命令,讓為回傳的訊息去觸發 OnUserParameterCallback
     // 若重複執行從 32 開始,因為需要 .devices-info 取得周邊裝置的資訊
     bot.EvaluateScript("user-para@ 32 min user-para! .user-para");
 }
示例#14
0
 private void buttonDisableCoordinator_Click(object sender, EventArgs e)
 {
     bot.EvaluateScript("-coordinator");
 }
示例#15
0
        private void OnUserParameterCallback(IntPtr dataPtr, string str)
        {
            int para = Int32.Parse(str);

            switch (para)
            {
            case 0:
                // 設定 user parameter 為 0x10
                // 如果此範例重新執行不會在載入以下 SFC
                //EvaluateScript("$10 user-para!");
                // 清除SFC 邏輯,載入 SFC 時會造成 real time cycle overrun,所以要暫時 ignore-overrun
                // 載入後再執行 `reset-overrun`
                bot.EvaluateScript("0sfc ignore-overrun");
                bot.EvaluateScript("-work marker -work");

                bot.LoadSFC(@"..\..\positionComparsion.sfc");
                // 等待 SFC 設置完成
                has_updated = true;
                Thread.Sleep(10);
                bot.EvaluateScript("reset-overrun");
                break;

            default:
                break;
            }
        }
示例#16
0
 public void OnWSOpenCallback(IntPtr dataPtr, string data)
 {
     wsState = 2;
     // 送出 .user-para 命令,讓為回傳的訊息去觸發 OnUserParameterCallback
     bot.EvaluateScript(".user-para");
 }
示例#17
0
        private void StrSetParamByParserUInt(string value, string cmd, Action <uint, int> configset, ParseCheck.ParseFunc <string, UInt32> parser)
        {
            UInt32 val;

            if (parser(value, out val))
            {
                botnana.EvaluateScript(value + @" " + axisNumber.ToString() + @" " + cmd);
                configset(axisNumber, (Int32)val);
            }
            botnana.EvaluateScript(axisNumber.ToString() + @" .axiscfg");
            botnana.ConfigAxisGet(axisNumber);
        }
示例#18
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     textSlaveCount.Text = slaveCount.ToString();
     if (slaveCount > 0)
     {
         bot.EvaluateScript("1 .slave-diff");
         textSlaveCount.Text = slaveCount.ToString();
         if (profileVelocityChanging == false)
         {
             textProfileVelocity.Text = profileVelocityStr;
         }
         if (profileAccelerationChanging == false)
         {
             textProfileAcceleration.Text = profileAccelerationStr;
         }
         textRealPosition.Text      = realPositionStr;
         textTargetPosition.Text    = targetPositionStr;
         textOPMode.Text            = opModeStr;
         radioFault.Checked         = driveFault;
         radioTargetReached.Checked = targetReached;
         radioServoOn.Checked       = !quickStopRequest & servoOn;
         radioServoStop.Checked     = quickStopRequest & servoOn;
         radioOrg.Checked           = driveOrg;
         radioPosLimit.Checked      = drivePl;
         radioNegLimit.Checked      = driveNl;
         labCount.Text = messageIndex.ToString("X2");
     }
 }
示例#19
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (slaveNumber != 0 && channelNumber != 0)
     {
         botnana.EvaluateScript(slaveNumber.ToString() + @" .slave-diff");
     }
 }
示例#20
0
 private void OnWSOpenCallback(IntPtr dataPtr, string data)
 {
     wsState = 2;
     // 送出 .user-para 命令,讓為回傳的訊息去觸發 OnUserParameterCallback
     // 若重複執行從 32 開始,因為需要 .device-infos 取得周邊裝置的資訊
     // .user-para 回應的訊息範例如下:
     // user_parameter|0
     bot.EvaluateScript(@"user-para@ 32 min user-para! .user-para");
 }
示例#21
0
        private static void OnUserParameterCB(IntPtr dataPtr, string str)
        {
            int para = Int32.Parse(str);

            switch (para)
            {
            case 0:
                // 設定 user parameter 為 0x10
                // 如果此範例重新執行不會在載入以下 SFC
                bot.EvaluateScript("$10 user-para!");
                // 清除SFC 邏輯,載入 SFC 時會造成 real time cycle overrun,所以要暫時 ignore-overrun
                // 載入後再執行 `reset-overrun`
                bot.EvaluateScript("0sfc ignore-overrun");
                bot.LoadSFC(@"..\..\config.sfc");
                bot.LoadSFC(@"..\..\servo_on_off.sfc");
                bot.LoadSFC(@"..\..\homing.sfc");
                bot.LoadSFC(@"..\..\motion_state.sfc");
                bot.LoadSFC(@"..\..\manager.sfc");
                // 等待 SFC 設置完成
                Thread.Sleep(500);
                bot.EvaluateScript("reset-overrun");
                break;

            default:
                break;
            }
            hasSFC = true;
        }