/// <summary> /// 轴,iO安全检查 /// </summary> /// <returns></returns> public bool IoSafeCheck(StationModule sm) { try { int count = _Config.axisArray.Count; int i = 0; int CountIo = _Config.arrWorkStation.Count; if (sm == null) { return(true); } while (i < count) { AxisConfig ac = _Config.axisArray[i]; if (ac.AxisNum >= 0 && NewCtrlCardV0.SR_GetAxisStatus(ac) == 1) { if (!AxisSafeManage.IoAxisIsSafe(sm, ac, 0, 0)) { if (Global.WorkVar.tag_isFangDaiJieChu) { return(true); } return(false); } } i++; } return(true); } catch { return(true); } }
public bool Save() { try { PointAggregate.strName = textBox_Name.Text; StationModule sm = StationManage.FindStation(PointAggregate.strStationName); int eucf = 1000; for (int i = 0; i < PointAggregate.arrPoint.Length; i++) { NumericUpDown PonitSpeed = tag_list[i * 2]; NumericUpDown PonitValue = tag_list[i * 2 + 1]; if (sm != null) { eucf = (int)sm.arrAxis[i].Eucf; } else { eucf = (int)1000;; } PointAggregate.arrPoint[i].dblPonitSpeed = Convert.ToDouble(PonitSpeed.Value) * eucf; PointAggregate.arrPoint[i].dblPonitValue = Convert.ToDouble(PonitValue.Value); } } catch (System.Exception ex) { LogOutControl.OutLog(ex.Message, 0); Console.Write(ex.ToString()); return(false); } return(true); }
/// <summary> /// IO dao ru /// </summary> /// <param name="strIo"></param> public static void InIoImport(string strIo) { try { string[] str2 = System.Text.RegularExpressions.Regex.Split(strIo, "\r\n"); string[] title = System.Text.RegularExpressions.Regex.Split(str2[0], ","); for (int i = 0; i < title.Length; i++) { StationModule stationOld = FindStation(title[i]); for (int j = 1; j < str2.Length; j++) { string[] IO = System.Text.RegularExpressions.Regex.Split(str2[j], ","); if (stationOld != null) { if (i < IO.Length && FindInputIo(IO[i]) == null && IO[i] != "") { stationOld.arrInputIo.Add(new IOParameter(IO[i])); stationOld.intUseInputIoCount++; } } } } } catch (Exception ex) { MessageBoxLog.Show(ex.Message); } }
/// <summary> /// IO dao ru /// </summary> /// <param name="strIo"></param> public static void OutIoCardImport(string strIo) { try { string[] str2 = System.Text.RegularExpressions.Regex.Split(strIo, "\r\n"); string[] title = System.Text.RegularExpressions.Regex.Split(str2[0], ","); StationModule stationOld = FindStation(title[0]); if (stationOld == null && title[0] != "") { stationOld = new StationModule(); _Config.arrWorkStation.Add(stationOld); _Config.arrWorkStation[_Config.arrWorkStation.Count - 1].strStationName = title[0]; _Config.intUseStationCount++; } for (int j = 1; j < str2.Length; j++) { string[] IO = System.Text.RegularExpressions.Regex.Split(str2[j], ","); if (FindOutputIo(IO[0]) == null && IO[0] != "") { IOParameter newIo = new IOParameter(IO[0]); newIo.CardNum = short.Parse(IO[1]); newIo.IOBit = short.Parse(IO[2]); stationOld.arrOutputIo.Add(newIo); stationOld.intUseOutputIoCount++; } } } catch (Exception ex) { MessageBoxLog.Show(ex.Message); } }
/// <summary> /// 查找轴 返回null 函数异常 /// </summary> /// <param name="stationName"></param> /// <param name="axisName"></param> /// <returns></returns> public static AxisConfig FindAxis(string stationName, string axisName) { if (string.IsNullOrEmpty(axisName)) { return(null); } if (string.IsNullOrEmpty(axisName)) { return(null); } StationModule stationM = FindStation(stationName); if (stationM == null) { return(null); } foreach (AxisConfig axisC in stationM.arrAxis) { if (axisC.AxisName == axisName) { return(axisC); } } return(null); }
public static void StepImport(string strIo) { try { string[] str2 = System.Text.RegularExpressions.Regex.Split(strIo, "\r\n"); string[] title = System.Text.RegularExpressions.Regex.Split(str2[0], ","); for (int i = 0; i < title.Length; i++) { StationModule stationOld = FindStation(title[i]); if (stationOld == null && title[i] != "") { _Config.arrWorkStation.Add(new StationModule()); _Config.arrWorkStation[_Config.arrWorkStation.Count - 1].strStationName = title[i]; _Config.intUseStationCount++; } for (int n = 1; n < str2.Length; n++) { string[] IO = System.Text.RegularExpressions.Regex.Split(str2[n], ","); if (stationOld != null) { if (i < IO.Length && FindPoint(stationOld, IO[i]) == null && IO[i] != "") { stationOld.arrPoint.Add(new PointAggregate(stationOld.strStationName, IO[i])); stationOld.intUsePointCount++; } } } } } catch (Exception ex) { MessageBoxLog.Show(ex.Message); } }
/// <summary> /// 构造初始化函数 /// </summary> /// <param name="classname"></param> /// <returns></returns> public string InitCreateN3() { string content0 = "\tpublic short Init()\r\n\t{\r\n"; StationModule sm = StationManage.FindStation(tag_stationName); int endStep = sm.intUsePointCount - 1; string stepN = null; for (int i = 0; i < endStep + 1; i++) { string content1 = "\t\tPointAggregate _Step" + i + " = pointMotion.FindPoint(tag_stationName, \"" + sm.arrPoint[i].strName + "\"," + i + ");\r\n"; string content2 = "\t\tif (_Step" + i + " == null)\r\n"; string content3 = "\t\t{\r\n"; string content4 = "\t\t\treturn -1;\r\n\t\t}\r\n"; string content5 = null; if (i > 0 && i < endStep) { content5 = "\t\t_Step" + i + " .tag_BeginFun = Step1 ;\r\n"; } else { content5 = "\t\t_Step" + i + " .tag_BeginFun = Step" + i + " ;\r\n"; } stepN = stepN + content1 + content2 + content3 + content4 + content5; } string content11 = "\t\treturn 0;\r\n\t}\r\n"; return(annotateCreate("init", "初始化函数,初始化流程嵌入的代码,返回0 表示成功") + content0 + stepN + content11); }
private void comboBox_FlowName_SelectedIndexChanged(object sender, EventArgs e) { // 获取节点信息 // push 到 terrview上 // Tree view 可拖拽 // 节点选中 获得参数 tag_StationModule = StationManage.FindStation(comboBox_FlowName.Text); if (tag_StationModule != null) { node.Nodes.Clear(); node.Remove(); treeView_FlowStruct.Nodes.Clear(); node.Text = comboBox_FlowName.Text; } for (int i = 0; i < tag_StationModule.arrPoint.Count; i++) { // 工位名称 chlid = new TreeNode(); chlid.Text = tag_StationModule.arrPoint[i].strName; // 绑定选中事件 node.Nodes.Add(chlid); } treeView_FlowStruct.Nodes.Add(node); }
/// <summary> /// 判断当前轴运动是否是本点的安全区 安全返回TRUE /// </summary> /// <returns></returns> public static bool IoAxisIsSafe(StationModule sm, AxisConfig _ac, double offset, double pos) { bool ret = true; if (sm.arrPoint.Count == 0) { return(true); } foreach (PointAggregate pa in sm.arrPoint) { if (isIOAxisHavePoint(_ac, pa, pos)) { if (pa.tag_AxisSafeManage.PointIsSafe(pa)) { if (IOIsSafe(pa)) { ret = true; // break; } else { ret = false; break; } } } } if (ret == false) { LogOutControl.OutLog(_ac.AxisName + "运动不安全", 0); } return(ret); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { //IOinput组件加载到界面 int m = 0; plIOmessage.Controls.Clear(); StationModule sm = StationManage.FindStation(comboBox_IO.Text); for (int i = 0; i < sm.intUseInputIoCount && i < sm.arrInputIo.Count; i++) { IOInputStatusControl ioinput = new IOInputStatusControl(sm.arrInputIo[i]); { ioinput.Location = new Point(5, 24 + 28 * i); plIOmessage.Controls.Add(ioinput); } arrInputIo = sm.arrInputIo[i]; m = i + 1; } int n = 0; //IOoutput组件加载到界面 for (int i = 0; i < sm.intUseOutputIoCount && i < sm.arrOutputIo.Count; i++) { IOOutputStatusControl iooutput = new IOOutputStatusControl(sm.arrOutputIo[i], OutIOStationSelect); iooutput.Location = new Point(200, 24 + 40 * i); plIOmessage.Controls.Add(iooutput); arrOutputIo = sm.arrOutputIo[i]; n = i + 1; } NewCtrlCardIO.tag_IO_refresh = 10; }
private void checkBox2_CheckedChanged(object sender, EventArgs e) { tag_manual.tag_Induction = checkBox2.Checked; StationModule sm = StationManage.FindStation(tag_workBase.tag_stationName); sm.tag_Enable = tag_manual.tag_Induction; }
private void 添加两个点位ToolStripMenuItem_Click(object sender, EventArgs e) { if (Global.CConst.UserLevel != Global.CConst.USER_SUPERADMIN) { MessageBoxLog.Show("无权限"); return; } string strStationName = "NewStation"; if (tag_work.Config.arrWorkStation.Count > 0) { foreach (StationModule ms in tag_work.Config.arrWorkStation) { if (ms.strStationName != "" && ms.strStationName == strStationName) { { MessageBoxLog.Show("已有工位配置"); return; } } } } StationModule sm = new StationModule(); tag_work.Config.arrWorkStation.Add(sm); tag_work.Config.arrWorkStation[tag_work.Config.arrWorkStation.Count - 1].strStationName = strStationName; PointAggregate pa = new PointAggregate(strStationName, "工位开始"); sm.arrPoint.Add(pa); sm.intUsePointCount++; int pointCount = 0; int i = 0; try { pointCount = int.Parse(texB_Count.Text); } catch (Exception mss) { LogOutControl.OutLog(mss.Message, 0); } while (i < pointCount && i < 100) { i++; pa = new PointAggregate(strStationName, "步骤" + i); sm.intUsePointCount++; sm.arrPoint.Add(pa); } pa = new PointAggregate(strStationName, "工位结束"); sm.intUsePointCount++; sm.arrPoint.Add(pa); tag_work.Config.intUseStationCount++; tag_work.Config.Save(); FrmStationMange_Load(null, null); }
private void button4_Click(object sender, EventArgs e) { CBStnChioce.Text = worker._Config.tag_safeStationModule.strStationName; tag_StationModule = worker._Config.tag_safeStationModule; if (tag_StationModule.intUsePointCount == 0) { tag_StationModule.intUsePointCount = 1; } RefreshStation(); }
//PointAggregate pagt = new PointAggregate(); public PointDebugSetUI(Work worker, StationModule station) { _Worker = worker; _StationM = station; intAxisControlCount = _StationM.arrAxis.Count; intInputControlCount = _StationM.arrInputIo.Count; intOutputControlCount = _StationM.arrOutputIo.Count; intPointControlCount = _StationM.arrPoint.Count; InitializeComponent(); }
/// <summary> /// /// </summary> /// <param name="OldStation"></param> /// <param name="newStation"></param> public static void StationCopy(string OldStation, string newStation) { StationModule stationOld = FindStation(OldStation); StationModule stationNew = FindStation(newStation); foreach (PointAggregate p in stationOld.arrPoint) { stationNew.arrPoint.Add(new PointAggregate(newStation, p.strName)); stationNew.intUsePointCount++; } }
public PointValueControl(PointAggregate PointSet_, Work _sWorker, int step, StationModule sm) //初始化点位参数数组 { tag_stepName = step; _Worker = _sWorker; tag_stationM = sm; InitializeComponent(); if (PointSet_ != null) { PointSet = PointSet_; } }
void OutIOStationSelect(object var) { if (var != null) { tag_StationModule = (StationModule)var; tag_PointAggregate = null; SetIndexPointAggregate(); RefreshStation(); tag_UserControl_ShowAllPoint.UserControl_ShowAllPoint_HeightLight(null, null); } }
/// <summary> /// 线程回原 /// </summary> /// <param name="stationName"></param> /// <param name="axisName"></param> /// <returns></returns> public GoHome(string stationname, string AxisName) { StationModule stationM = StationManage.FindStation(tag_AxisName); tag_stationName = stationname; tag_AxisName = AxisName; Thread homeThread = new Thread(new ParameterizedThreadStart(GoHomeRun)); homeThread.Start(); homeThread.IsBackground = true; }
//Combox选中工位后自动刷新工位参数 private void StnChioceCB_SelectedIndexChanged(object sender, EventArgs e) { tag_StationModule = StationManage.FindStation(CBStnChioce.Text); tag_PointAggregate = null; SetIndexPointAggregate(); RefreshStation(); tag_UserControl_ShowAllPoint.UserControl_ShowAllPoint_HeightLight(null, null); comboBox_IO.Focus(); comboBox_IO.Text = CBStnChioce.Text; comboBox1_SelectedIndexChanged(sender, e); NewCtrlCardIO.tag_IO_refresh = 10; }
private void StationTrialRunControl_Load(object sender, EventArgs e) { button_LineCheck.Text = tag_titleName; StationModule sm = StationManage.FindStation(tag_workBase.tag_stationName); if (sm == null) { return; } tag_manual.tag_Induction = sm.tag_Enable; checkBox2.Checked = sm.tag_Enable; }
/// <summary> /// /// </summary> /// <param name="point"></param> public AxisSafeManage(PointAggregate point) { tag_AxisSafeList = new List <AxisSafe>(); StationModule sm = StationManage.FindStation(point.strStationName); if (sm == null) { LogOutControl.OutLog("无" + point.strStationName, 0); return; } foreach (AxisConfig ac in sm.arrAxis) { Add((short)ac.tag_MotionCardManufacturer, ac.CardNum, ac.AxisNum); } }
private void 添加CCD九宫格标定点位ToolStripMenuItem_Click(object sender, EventArgs e) { if (Global.CConst.UserLevel != Global.CConst.USER_SUPERADMIN) { MessageBoxLog.Show("无权限"); return; } string strStationName = "CCD_9宫格标定"; if (tag_work.Config.arrWorkStation.Count > 0) { foreach (StationModule ms in tag_work.Config.arrWorkStation) { if (ms.strStationName != "" && ms.strStationName == strStationName) { { MessageBoxLog.Show("已有工位配置"); return; } } } } StationModule sm = new StationModule(); tag_work.Config.arrWorkStation.Add(sm); tag_work.Config.arrWorkStation[tag_work.Config.arrWorkStation.Count - 1].strStationName = strStationName; PointAggregate pa = new PointAggregate(strStationName, "标定开始"); sm.arrPoint.Add(pa); sm.intUsePointCount++; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { pa = new PointAggregate(strStationName, i + "_" + j + "点位"); sm.arrPoint.Add(pa); sm.intUsePointCount++; } } pa = new PointAggregate(strStationName, "标定结束"); sm.intUsePointCount++; sm.arrPoint.Add(pa); tag_work.Config.intUseStationCount++; tag_work.Config.Save(); FrmStationMange_Load(null, null); }
/// <summary> /// 构造3步函数 /// </summary> /// <param name="classname"></param> /// <returns></returns> public string StepCreateN3() { StationModule sm = StationManage.FindStation(tag_stationName); if (sm != null && sm.intUsePointCount > 0 && sm.intUsePointCount >= 3) { int endStep = sm.intUsePointCount - 1; string ret = null; ret = ret + StepCreateN(0, sm.arrPoint[0].strName); ret = ret + StepCreateN(1, sm.arrPoint[1].strName); ret = ret + StepCreateN(endStep, sm.arrPoint[endStep].strName); return(ret); } return(""); }
/// <summary> /// 构造第N步函数 /// </summary> /// <param name="classname"></param> /// <returns></returns> public string StepCreateN() { StationModule sm = StationManage.FindStation(tag_stationName); if (sm != null && sm.intUsePointCount > 0) { int endStep = sm.intUsePointCount - 1; string ret = null; for (int i = 0; i < endStep + 1; i++) { ret = ret + StepCreateN(i, sm.arrPoint[i].strName); } return(ret); } return(""); }
private void 除所有ToolStripMenuItem_Click(object sender, EventArgs e) { if (Global.CConst.UserLevel != Global.CConst.USER_SUPERADMIN) { MessageBoxLog.Show("无权限"); return; } if (MessageBoxLog.Show("是否删除?", "确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return; } StationModule sm = StationManage.FindStation(trVStation.SelectedNode.Text); tag_work.Config.arrWorkStation.Clear(); tag_work.Config.intUseStationCount = 0; tag_work.Config.Save(); FrmStationMange_Load(null, null); }
/// <summary> /// 查找工站输入IO 返回null 函数异常 /// </summary> /// <param name="stationM"></param> /// <param name="inputName"></param> /// <returns></returns> public static IOParameter FindInputIo(StationModule stationM, string inputName) { if (string.IsNullOrEmpty(inputName)) { return(null); } foreach (StationModule sm in _Config.arrWorkStation) { foreach (IOParameter ioP in sm.arrInputIo) { if (ioP.StrIoName == inputName) { return(ioP); } } } return(null); }
private void comboBox_Station2_SelectedIndexChanged(object sender, EventArgs e) { listBox2.Items.Clear(); foreach (StationModule sm in StationManage._Config.arrWorkStation) { int i = 0; if (!string.IsNullOrEmpty(sm.strStationName) && (sm.strStationName == comboBox_Station2.SelectedItem.ToString())) { for (i = 0; i < sm.intUseOutputIoCount; i++) { listBox2.Items.Add(sm.arrOutputIo[i].StrIoName); } tag_StationModule = sm; break; } } }
/// <summary> /// 构造初始化函数 /// </summary> /// <param name="classname"></param> /// <returns></returns> public string InitCreate() { string content0 = "\tpublic short Init()\r\n\t{\r\n"; StationModule sm = StationManage.FindStation(tag_stationName); int endStep = sm.intUsePointCount - 1; string content1 = "\t\tPointAggregate startStep = pointMotion.FindPoint(tag_stationName, \"" + sm.arrPoint[0].strName + "\",0);\r\n"; string content2 = "\t\tif (startStep == null)\r\n"; string content3 = "\t\t{\r\n"; string content4 = "\t\t\treturn -1;\r\n\t\t}\r\n"; string content5 = "\t\tstartStep.tag_BeginFun = FirstStep;\r\n"; string content6 = "\t\tPointAggregate endStep = pointMotion.FindPoint(tag_stationName, \"" + sm.arrPoint[sm.intUsePointCount - 1].strName + "\");\r\n"; string content7 = "\t\tif (endStep == null)\r\n"; string content8 = "\t\t{\r\n"; string content9 = "\t\t\treturn -1;\r\n\t\t}\r\n"; string content10 = "\t\tendStep.tag_EndFun = LastStep;\r\n"; string content11 = "\t\treturn 0;\r\n\t}\r\n"; return(annotateCreate("init", "初始化函数,初始化流程嵌入的代码,返回0 表示成功") + content0 + content1 + content2 + content3 + content4 + content5 + content6 + content7 + content8 + content9 + content10 + content11); }
/// <summary> /// 轴绝对运动 /// </summary> /// <param name="stationName"></param> /// <param name="axisName"></param> /// <param name="pointName"></param> /// <returns></returns> public static short AxisAbsoluteMove(string stationName, string axisName, string pointName, int asxisIndex) { StationModule stationM = StationManage.FindStation(stationName); if (stationM == null) { return(shrFail); } AxisConfig axisC = StationManage.FindAxis(stationM, axisName); if (axisC == null) { return(shrFail); } PointAggregate pointA = StationManage.FindPoint(stationM, pointName); if (pointA == null) { return(shrFail); } NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)axisC.tag_MotionCardManufacturer]; if (Base_ == null) { MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)axisC.tag_MotionCardManufacturer) + "控制卡初始化失败!"); return(shrFail); } short shrResult = 0; if (pointA.tag_motionType == 0) { shrResult = Base_.SR_AbsoluteMove(axisC, pointA.arrPoint[asxisIndex]); } else { shrResult = Base_.SR_RelativeMove(axisC, pointA.arrPoint[asxisIndex]); } if (shrResult != shrSuccess) { return(shrFail); } return(shrSuccess); }
/// <summary> /// 轴运动并等待停止并判断位置 /// </summary> /// <param name="stationName"></param> /// <param name="axisName"></param> /// <param name="pointName"></param> /// <param name="asxisIndex"></param> /// <returns></returns> public static short AxisAbsoluteMoveAndWaitStopVrf(string stationName, string axisName, string pointName, int asxisIndex) { if (AxisAbsoluteMove(stationName, axisName, pointName, asxisIndex) != 0) { Global.WorkVar.tag_StopState = 2; if (MessageBoxLog.Show("工位:\r\n" + stationName + "\r\n轴名:\r\n" + axisName + "\t移动异常,请检查伺服驱动!") == DialogResult.OK) { } return(shrFail); } StationModule stationM = StationManage.FindStation(stationName); if (stationM == null) { return(shrFail); } PointAggregate pointA = StationManage.FindPoint(stationM, pointName); if (pointA == null) { return(shrFail); } AxisConfig axisC = StationManage.FindAxis(stationM, axisName); if (WaitAxisStop(axisC) != 0) { return(shrFail); } double pos_loadY = 0; short ret = SR_GetPrfPos((int)axisC.tag_MotionCardManufacturer, axisC.CardNum, axisC.AxisNum, ref pos_loadY); if (Global.WorkVar.tag_SuspendState == 1 || (Global.WorkVar.bSuspendState_L && axisC.AxisName == "左Y轴") || (Global.WorkVar.bSuspendState_R && axisC.AxisName == "右Y轴")) { } else if (pos_loadY / axisC.Eucf < pointA.arrPoint[asxisIndex].dblPonitValue - 1 || pos_loadY / axisC.Eucf > pointA.arrPoint[asxisIndex].dblPonitValue + 1) { return(shrFail); } return(shrSuccess); }