Example #1
0
        /// <summary>
        /// 启动辊台
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BTNrun_Click(object sender, EventArgs e)
        {
            try
            {
                if (CBdev.SelectedIndex == -1)
                {
                    Notice.Show("请选择设备!", "提示", 3, MessageBoxIcon.Info);
                    return;
                }
                string dev = CBdev.Text;
                ARF    arf = new ARF(dev);
                if (arf.ActionStatus() == ARF.Run)
                {
                    Notice.Show("指令发送失败:设备运行中!", "错误", 3, MessageBoxIcon.Error);
                    return;
                }
                if (arf.DeviceStatus() == ARF.DeviceError)
                {
                    Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error);
                    return;
                }

                // 方式
                byte site1 = ARF.RollerRun1;
                if (CBsite1.SelectedValue.ToString() == "启动2#辊台")
                {
                    site1 = ARF.RollerRun2;
                }
                if (CBsite1.SelectedValue.ToString() == "启动全部辊台")
                {
                    site1 = ARF.RollerRunAll;
                }
                // 方向
                byte site2 = ARF.RunFront;
                if (CBsite2.SelectedValue.ToString() == "反向启动")
                {
                    site2 = ARF.RunObverse;
                }
                // 类型
                byte site3 = ARF.GoodsReceive;
                if (CBsite3.SelectedValue.ToString() == "送货")
                {
                    site3 = ARF.GoodsDeliver;
                }
                // 数量
                byte site4 = ARF.GoodsQty1;
                if (CBsite4.SelectedValue.ToString() == "货物数量2")
                {
                    site4 = ARF.GoodsQty2;
                }

                byte[] order = ARF._RollerControl(arf.ARFNum(), site1, site2, site3, site4);
                if (!DataControl._mSocket.SendToClient(dev, order, out string result))
                {
                    Notice.Show("指令发送失败:" + result.ToString(), "错误", 3, MessageBoxIcon.Error);
                    return;
                }
                Notice.Show("启动辊台 指令发送成功!", "成功", 3, MessageBoxIcon.Success);
                DataControl._mSocket.SwithRefresh(dev, false);
            }
            catch (Exception ex)
            {
                Notice.Show("指令发送失败:" + ex.ToString(), "错误", 3, MessageBoxIcon.Error);
            }
        }
Example #2
0
        /// <summary>
        /// 启动辊台
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BTNrun_Click(object sender, EventArgs e)
        {
            string dev = "";

            byte[] order = null;
            try
            {
                if (CBdev.SelectedIndex == -1)
                {
                    Notice.Show("请选择设备!", "提示", 3, MessageBoxIcon.Info);
                    return;
                }
                dev = CBdev.Text;
                ARF arf = new ARF(dev);
                if (arf.ActionStatus() == ARF.Run)
                {
                    Notice.Show("指令发送失败:设备运行中!", "错误", 3, MessageBoxIcon.Error);
                    return;
                }
                if (arf.DeviceStatus() == ARF.DeviceError)
                {
                    Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error);
                    return;
                }

                // 方式
                byte site1 = ARF.RollerRun1;
                if (CBsite1.SelectedValue.ToString() == "启动2#辊台")
                {
                    site1 = ARF.RollerRun2;
                }
                if (CBsite1.SelectedValue.ToString() == "启动全部辊台")
                {
                    site1 = ARF.RollerRunAll;
                }
                // 方向
                byte site2 = ARF.RunFront;
                if (CBsite2.SelectedValue.ToString() == "反向启动")
                {
                    site2 = ARF.RunObverse;
                }
                // 类型
                byte site3 = ARF.GoodsReceive;
                if (CBsite3.SelectedValue.ToString() == "送货")
                {
                    site3 = ARF.GoodsDeliver;
                }
                // 数量
                byte site4 = ARF.GoodsQty1;
                if (CBsite4.SelectedValue.ToString() == "货物数量2")
                {
                    site4 = ARF.GoodsQty2;
                }

                if (!WindowCommon.ConfirmAction("是否发送滚筒启动指令!!"))
                {
                    return;
                }


                order = ARF._RollerControl(arf.ARFNum(), site1, site2, site3, site4);
                DataControl._mSocket.SwithRefresh(dev, false);
                if (!DataControl._mSocket.SendToClient(dev, order, out string result))
                {
                    DataControl._mSocket.SwithRefresh(dev, true);
                    Notice.Show("指令发送失败:" + result.ToString(), "错误", 3, MessageBoxIcon.Error);
                    // LOG
                    DataControl._mTaskTools.RecordTaskErrLog("BTNrun_Click()", "摆渡车-启动辊台任务[ARF,指令]", dev, DataControl._mStools.BytetToString(order), result.ToString());
                    return;
                }
                Notice.Show("启动辊台 指令发送成功!", "成功", 3, MessageBoxIcon.Success);
            }
            catch (Exception ex)
            {
                Notice.Show("指令发送失败:" + ex.Message, "错误", 3, MessageBoxIcon.Error);
                // LOG
                DataControl._mTaskTools.RecordTaskErrLog("BTNrun_Click()", "摆渡车-启动辊台任务[ARF,指令]", dev, DataControl._mStools.BytetToString(order), ex.Message);
            }
        }