public bool DoGetInPut(int lineIdx, out bool onOff) { onOff = false; try { //ErrorMessage.Clear(); IGXFeatureControl fc = GetFeatureControl(); if (fc == null) { return(false); } string strLine = ""; if (lineIdx == 0) { strLine = "Line0"; } else if (lineIdx == 1) { strLine = "Line1"; } else if (lineIdx == 2) { strLine = "Line2"; } else if (lineIdx == 3) { strLine = "Line3"; } else { //ErrorMessage.Append("触发线序号无效。"); return(false); } fc.GetEnumFeature("LineSelector").SetValue(strLine); onOff = fc.GetBoolFeature("LineStatus").GetValue(); return(true); } catch (Exception ex) { return(false); } }
public bool DoSetOutPut(int lineIdx, bool onOff) { try { ////ErrorMessage.Clear(); IGXFeatureControl fc = GetFeatureControl(); if (fc == null) { return(false); } string strLine = ""; if (lineIdx == 0) { strLine = "Line0"; } else if (lineIdx == 1) { strLine = "Line1"; } else if (lineIdx == 2) { strLine = "Line2"; } else if (lineIdx == 3) { strLine = "Line3"; } else { ////ErrorMessage.Append("触发线序号无效。"); return(false); } int tryTime = 10; for (int i = 0; i < tryTime; ++i) {//频繁输出会报异常 try{ fc.GetEnumFeature("LineSelector").SetValue(strLine); break; }catch (Exception ex) { } System.Threading.Thread.Sleep(10); if (i == (tryTime - 1)) { return(false); } } for (int i = 0; i < tryTime; ++i) {//频繁输出会报异常 try { fc.GetEnumFeature("LineMode").SetValue("Output"); break; } catch (Exception ex) { } System.Threading.Thread.Sleep(10); if (i == (tryTime - 1)) { return(false); } } //fc.GetBoolFeature("LineStatus").SetValue(onOff); for (int i = 0; i < tryTime; ++i) {//频繁输出会报异常 try { fc.GetBoolFeature("UserOutputValue").SetValue(false); break; } catch (Exception ex) { } System.Threading.Thread.Sleep(10); if (i == (tryTime - 1)) { return(false); } } for (int i = 0; i < tryTime; ++i) {//频繁输出会报异常 try { fc.GetBoolFeature("LineInverter").SetValue(onOff); break; } catch (Exception ex) { } System.Threading.Thread.Sleep(10); if (i == (tryTime - 1)) { return(false); } } return(true); } catch (Exception ex) { return(false); } }