示例#1
0
        /// <summary>
        /// 单个单值数据项写入按钮被点击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnSingleItemWriteButtonClick(object sender, EventArgs e)
        {
            int    idx = _lstBtSingleWrites.IndexOf(sender as Button);
            object val = null;

            if (!_lstUcSingleItems[idx].GetParamValue(out val))
            {
                JFTipsDelayClose.Show("未能写入数据池\n数据格式错误!", -1);
                return;
            }
            bool isOK = _dataPool.SetItemValue(_lstUcSingleItems[idx].GetParamDesribe().DisplayName, val);

            if (!isOK)
            {
                JFTipsDelayClose.Show("向数据池写入时发生错误!", -1);
                return;
            }
            JFTipsDelayClose.Show("写入成功", 1);
        }
示例#2
0
        /// <summary>
        /// 写入按钮,将所有变量值写入数据池
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btWrite_Click(object sender, EventArgs e)
        {
            StringBuilder sbErrorInfo = new StringBuilder();
            bool          isOK        = true;

            ///先写入所有单值 项
            for (int i = 0; i < _lstUcSingleItems.Count; i++)
            {
                object        val = null;
                UcJFParamEdit pe  = _lstUcSingleItems[i];
                if (!pe.GetParamValue(out val))
                {
                    isOK = false;
                    sbErrorInfo.AppendLine(pe.GetParamDesribe().DisplayName + " 参数格式错误");
                }
                else
                {
                    if (!_dataPool.SetItemValue(pe.GetParamDesribe().DisplayName, val))
                    {
                        isOK = false;
                        sbErrorInfo.AppendLine(pe.GetParamDesribe().DisplayName + " 写入失败");
                    }
                }
            }

            ///再写入所有集合项
            //待添加代码


            if (!isOK)
            {
                JFTipsDelayClose.Show(sbErrorInfo.ToString(), -1);
                return;
            }
            JFTipsDelayClose.Show("写入成功", 1);
        }
        /// <summary>
        /// 向工站发送一条指令(包含 开始/停止/暂停/恢复/结批 和用户自定义指令)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btSendCmd_Click(object sender, EventArgs e)
        {
            int selIndex = cbCmds.SelectedIndex;

            if (selIndex < 0)
            {
                JFTipsDelayClose.Show("请选择需要发送的指令", 2);//MessageBox.Show("请选择需要发送的指令");
                return;
            }
            JFWorkCmdResult cmdRet = JFWorkCmdResult.UnknownError;

            if (AllowedStartStopCmd)
            {
                if (selIndex < 5) //开始/暂停/恢复/结批/停止
                {
                    switch (selIndex)
                    {
                    case 0: cmdRet = _station.Start(); break;

                    case 1: cmdRet = _station.Pause(1000); break;

                    case 2: cmdRet = _station.Resume(1000); break;

                    case 3: cmdRet = _station.EndBatch(1000); break;

                    case 4: cmdRet = _station.Stop(1000); break;
                    }
                }
                else
                {
                    int cmdIndex = selIndex - 5;
                    cmdRet = _station.SendCmd(_station.AllCmds[cmdIndex], 1000);
                }
            }
            else
            {
                if (selIndex < 2) //暂停/恢复
                {
                    switch (selIndex)
                    {
                    case 0: cmdRet = _station.Pause(1000); break;

                    case 1: cmdRet = _station.Resume(1000); break;
                    }
                }
                else
                {
                    int cmdIndex = selIndex - 2;
                    cmdRet = _station.SendCmd(_station.AllCmds[cmdIndex], 1000);
                }
            }
            string errInfo = "";

            switch (cmdRet)
            {
            case JFWorkCmdResult.UnknownError:    // = -1, //发生未定义的错误
                errInfo = "未知错误";
                break;

            case JFWorkCmdResult.Success:    // = 0, //指令执行成功
                errInfo = "指令执行成功";
                break;

            case JFWorkCmdResult.IllegalCmd:    //,//不支持的非法指令
                errInfo = "不支持的非法指令";
                break;

            case JFWorkCmdResult.StatusError:    //, //工作状态(包括用户自定义状态)不支持当前指令 ,(向未运行的线程发送Resume指令)
                errInfo = "当前状态不支持该指令";
                break;

            case JFWorkCmdResult.ActionError:    //, //指令执行失败
                errInfo = "执行失败";
                break;

            case JFWorkCmdResult.Timeout:    //,//线程超时未响应
                errInfo = "指令执行超时";
                break;
            }

            if (cmdRet != JFWorkCmdResult.Success)
            {
                JFTipsDelayClose.Show("指令:" + cbCmds.Text + " 发送失败:" + errInfo, 3);
            }
            else
            {
                ShowTips("指令:" + cbCmds.Text + "发送完成");
            }
        }