public bool this[int index] { get { index = list[index]; if (enabled && used.Bit(index)) { bool flag; if (isOutPut) { provider.GetDigOut(index, out flag); } else { provider.GetDigIn(index, out flag); } flag = (mask.Bit(index) ^ flag); return(flag); } else { return(false); } } set { index = list[index]; if (isOutPut && enabled && used.Bit(index)) { bool flag = mask.Bit(index); flag ^= value; provider.SetDigOut(index, flag); } } }
private void UpDataIOStatus() { if (Common.DI != null && Common.DI.Enabled) { uint input = Common.DI.Status; cutWater.Text = input.Bit(Common.DI.IOList[DiDefine.CUT_WATER]) ?"1":"0"; mainAIR.Text = input.Bit(Common.DI.IOList[DiDefine.MAIN_AIR]) ? "1" : "0"; mainWater.Text = input.Bit(Common.DI.IOList[DiDefine.MAIN_WATER]) ? "1" : "0"; workAir.Text = input.Bit(Common.DI.IOList[DiDefine.WORK_AIR]) ? "1" : "0"; tabAir.Text = input.Bit(Common.DI.IOList[DiDefine.TAB_AIR])? "1" : "0"; } }
public static bool CuttingCheckStatus() { if (!Globals.DebugMode) { uint inputData = DI.Status; int m = DI.IOList[DiDefine.MAIN_WATER]; if (!inputData.Bit(m))//主气压不足 { } m = DI.IOList[DiDefine.MAIN_AIR]; if (!inputData.Bit(m))//主气压不足 { } m = DI.IOList[DiDefine.EMG_SIG]; if (!inputData.Bit(m))//急停被按下 { } m = DI.IOList[DiDefine.CUT_WATER]; if (Globals.DevData.CutWaterChecked && !inputData.Bit(m))//切割水不足 { } m = DI.IOList[DiDefine.LEAK_WATER]; if (Globals.DevData.LeakWaterChecked && !inputData.Bit(m))//漏水检测 { } if (Globals.BldData.BldRemainder < Globals.BldData.SafetyMargin)//刀具露出量小于安全余量 { } if (Globals.BldData.LenAfterReplace > Globals.BldData.MaxSafeLength)//长度超标 { } if (Globals.BldData.LinesAfterReplace > Globals.BldData.MaxSafeLines)//刀数超标 { } //刀破检测 // } return(true); }
private void SystemIOControlManager_AutoUpdateEventHander(object sender, EventArgs e) { if (update) { uint input = Common.DI.Status; uint output = Common.DO.Status; int n = 0; if (inputValue != input) { UInt32 v = inputValue ^ input; for (int i = 0; i < ioCount; i++) { n = Common.DI.IOList[i]; if (v.Bit(n)) { bool flag = input.Bit(n); ipBtList[n].BackColor = flag ? enBkColor : diBkColor; ipBtList[n].ForeColor = flag ? enForeColor : diForeColor; } } inputValue = input; } if (outputValue != output) { UInt32 v = outputValue ^ output; for (int i = 0; i < ioCount; i++) { n = Common.DO.IOList[i]; if (v.Bit(n)) { bool flag = output.Bit(n); opBtList[n].BackColor = flag ? enBkColor : diBkColor; opBtList[n].ForeColor = flag ? enForeColor : diForeColor; } } outputValue = output; } } }
/// <summary> /// Handles the Tick event of the tmrCadence control. /// Computes the new display status for each cadenced control based on its <see cref = "ICadencedControl.Cadence" /> /// property and requests the control update itself with the new value. /// </summary> /// <param name = "sender">The source of the event.</param> /// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param> private void TmrCadenceTick(object sender, ElapsedEventArgs e) { // First check if there are any managed controls and, if not, shut down the timer. if (UpdateList.Count < 1) { CadenceTimer.Stop(); // Stop any further tick events. CadenceTimer.Elapsed -= TmrCadenceTick; // Withdraw the event handler delegate. return; // Nothing more to do. } // Increment and (if necessary) wrap the cadence bit position index. if (++CadenceBitPosition > 31) { CadenceBitPosition = 0; } // Make a clone of the UpdateList collection to avoid threading problems, // and InvalidOperationException if we need to modify the list. // Note that this only clones teh collection, the objects referenced objects are not cloned. var clonedUpdateList = new List <ICadencedControl>(UpdateList); // Visit each managed control and ask it to update its status. foreach (ICadencedControl item in clonedUpdateList) { if (item == null) { continue; } var control = item as Control; // Attempt to cast the item to a WinForms control if (control != null && !control.Visible) { continue; // Shortcut invisible controls. } try { uint cadenceMask = (uint)item.Cadence; bool state = cadenceMask.Bit(CadenceBitPosition); if (control != null && control.InvokeRequired) // It its a control and we're not on the GUI thread, marshall to the GUI thread. { control.Invoke(new CadenceUpdateDelegate(item.CadenceUpdate), new object[] { state }); } else // If it's not a control or we are already on the GUI thread, simply call the item's update method. { item.CadenceUpdate(state); } } catch (InvalidOperationException ex) { // This probably means that the collection was modified while we were iterating over it. // This shouldn't happen, so emit some diagnostics and then stop processing updates for this cycle. Trace.WriteLine("Collection possibly modified while iterating\n" + ex); break; } catch (Exception ex) { // If any managed item causes an exception of any other kind, remove it from the update list. Debug.WriteLine("Exception while updating ICadencedControl - removing item from update list\n" + ex); UpdateList.Remove(item); // This is why we needed to use a cloned collection } } }
public static byte BeBit(this uint v, int n) { return(v.Bit(n ^ 24)); }
public void AutoUpate(int cycTime = 10) { if (!Globals.Load) { return; } switch (underControl.SelectedIndex) { case 0: { if (cycTick++ > cycTime) { cycTick = 0; if (underAxis1.Enabled != Globals.IDIE) { underAxis1.Enabled = Globals.IDIE; } if (ST1.LED != Globals.IsInit) { ST1.LED = Globals.IsInit; } if (Common.SPD != null && Common.SPD.IsInit) { bool flag = !Common.SPD.SpeedZore; //当前运转状态 if (ST2.LED != flag) { ST2.LED = flag; } } else { ST2.LED = false; } if (Common.DO.Enabled) { uint output = Common.DO.Status; if (ST4.LED != output.Bit(Common.DO.IOList[DoDefine.CUT_WATER])) { ST4.LED = output.Bit(Common.DO.IOList[DoDefine.CUT_WATER]); } if (ST3.LED != output.Bit(Common.DO.IOList[DoDefine.WORK_AIR])) //吸台气压 { ST3.LED = output.Bit(Common.DO.IOList[DoDefine.WORK_AIR]); } if (ST5.LED != output.Bit(Common.DO.IOList[DoDefine.TAB_AIR])) //吸台气压 { ST5.LED = output.Bit(Common.DO.IOList[DoDefine.TAB_AIR]); } } else { ST3.LED = false; ST4.LED = false; } if (ST6.LED != Globals.TestedHeight) { ST6.LED = Globals.TestedHeight; } } } break; case 1: { underAxis1.AutoUpdata(); } break; default: break; } }