private void okCancelButton_ButtonClick(object aSender, EventArgs aEventArgs) { if (okCancelButton.DialogResult == DialogResult.Cancel) { DialogResult = DialogResult.Cancel; } else { try { if (String.IsNullOrWhiteSpace(itemEditBox_Value.ItemName)) { throw new ArgumentException("Output Item is missing. "); } var lChecker = new RepeatItemNameChecker(); lChecker.addItemName(itemEditBox_On.ItemName); lChecker.addItemName(itemEditBox_Value.ItemName); mGenerator.mOnItemHandle = mBrowser.getItemHandleByName(itemEditBox_On.ItemName); mGenerator.mValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_Value.ItemName); mGenerator.SignalIndex = comboBox_Signal.SelectedIndex; mGenerator.Bias = (double)spinEdit_Bias.Value; mGenerator.Amplitude = (double)spinEdit_Amplitude.Value; mGenerator.PeriodMS = (uint)spinEdit_PeriodMS.Value; mGenerator.TurnMS = (uint)spinEdit_TurnMS.Value; DialogResult = DialogResult.OK; } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); } } }
private bool checkElmParams(bool aCheckSelected) { try { var lIndexSet = new HashSet <int>(); var lChecker = new RepeatItemNameChecker(); lIndexSet.Add((int)spinEdit_Index.Value); lChecker.addItemName(itemEditBox_Item.ItemName); lChecker.addItemName(itemEditBox_Value.ItemName); int lCount = dataGridView_Bit.Rows.Count; for (int i = 0; i < lCount; i++) { if (aCheckSelected == false && i == dataGridView_Bit.SelectedRows[0].Index) { continue; } if (lIndexSet.Add((int)StringUtils.StringToObject(typeof(Int32), dataGridView_Bit.Rows[i].Cells[0].Value.ToString())) == false) { throw new ArgumentException("Bit '" + spinEdit_Index.Value.ToString() + "' already exists. "); } lChecker.addItemName(dataGridView_Bit.Rows[i].Cells[1].Value.ToString()); } } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); return(false); } return(true); }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute <String>("Switch"); lChecker.addItemName(lItem); mSwitchItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Input1"); lChecker.addItemName(lItem); mInput1ItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Input2"); lChecker.addItemName(lItem); mInput2ItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Value"); lChecker.addItemName(lItem); mValueItemHandle = mItemBrowser.getItemHandleByName(lItem); In2ToIn1MS = lReader.getAttribute <UInt32>("In2ToIn1MS", mIn2ToIn1MS); In1ToIn2MS = lReader.getAttribute <UInt32>("In1ToIn2MS", mIn1ToIn2MS); }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute <String>("On", ""); lChecker.addItemName(lItem); mOnItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Value"); lChecker.addItemName(lItem); mValueItemHandle = mItemBrowser.getItemHandleByName(lItem); SignalString = lReader.getAttribute <String>("Signal"); Bias = lReader.getAttribute <Double>("Bias", mBias); Amplitude = lReader.getAttribute <Double>("Amplitude", mAmplitude); PeriodMS = lReader.getAttribute <UInt32>("PeriodMS", mPeriodMS); TurnMS = lReader.getAttribute <UInt32>("TurnMS", mTurnMS); StartMS = lReader.getAttribute <UInt32>("StartMS", mStartMS); try { mValue = (double)mItemBrowser.readItemValue(mValueItemHandle); } catch { if (mSignal > 0) { mPeriodStartMS = MiscUtils.TimerMS - mStartMS; mCurrentMS = mStartMS; mFSM.executeStateAction(); } } }
private void okCancelButton_ButtonClick(object aSender, EventArgs aEventArgs) { if (okCancelButton.DialogResult == DialogResult.Cancel) { DialogResult = DialogResult.Cancel; } else { try { if (String.IsNullOrWhiteSpace(itemEditBox_Switch.ItemName)) { throw new ArgumentException("Switch Item is missing. "); } if (String.IsNullOrWhiteSpace(itemEditBox_In1.ItemName)) { throw new ArgumentException("Input №1 Item is missing. "); } if (String.IsNullOrWhiteSpace(itemEditBox_In2.ItemName)) { throw new ArgumentException("Input №2 Item is missing. "); } if (String.IsNullOrWhiteSpace(itemEditBox_Value.ItemName)) { throw new ArgumentException("Output Item is missing. "); } var lChecker = new RepeatItemNameChecker(); lChecker.addItemName(itemEditBox_Switch.ItemName); lChecker.addItemName(itemEditBox_In1.ItemName); lChecker.addItemName(itemEditBox_In2.ItemName); lChecker.addItemName(itemEditBox_Value.ItemName); mOneOfTwo.mSwitchItemHandle = mBrowser.getItemHandleByName(itemEditBox_Switch.ItemName); mOneOfTwo.mInput1ItemHandle = mBrowser.getItemHandleByName(itemEditBox_In1.ItemName); mOneOfTwo.mInput2ItemHandle = mBrowser.getItemHandleByName(itemEditBox_In2.ItemName); mOneOfTwo.mValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_Value.ItemName); mOneOfTwo.In1ToIn2MS = (uint)spinEdit_In1ToIn2MS.Value; mOneOfTwo.In2ToIn1MS = (uint)spinEdit_In2ToIn1MS.Value; DialogResult = DialogResult.OK; } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); } } }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute <String>("Y"); lChecker.addItemName(lItem); mValueItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("X"); lChecker.addItemName(lItem); mInputItemHandle = mItemBrowser.getItemHandleByName(lItem); var lPoints = new SortedDictionary <double, double>(); aXMLTextReader.Read(); if (aXMLTextReader.Name.Equals("Points", StringComparison.Ordinal)) { aXMLTextReader.Read(); double lX, lY; while (aXMLTextReader.Name.Equals("Point", StringComparison.Ordinal) && aXMLTextReader.IsStartElement()) { lX = lReader.getAttribute <Double>("X"); lY = lReader.getAttribute <Double>("Y"); if (lPoints.ContainsKey(lX)) { throw new ArgumentException("Point where X equals '" + lX.ToString() + "' already exists. "); } lPoints.Add(lX, lY); aXMLTextReader.Read(); } } if (lPoints.Count >= 2) { Points = lPoints; } else { throw new ArgumentException("Points number must be equal or grater than two. "); } }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute <String>("X"); lChecker.addItemName(lItem); mXValueItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Y"); lChecker.addItemName(lItem); mYValueItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Visible", ""); lChecker.addItemName(lItem); mVisibleItemHandle = mItemBrowser.getItemHandleByName(lItem); if (aXMLTextReader.IsEmptyElement == false) { aXMLTextReader.Read(); if (aXMLTextReader.Name.Equals("Image", StringComparison.Ordinal)) { if (aXMLTextReader.IsEmptyElement == false) { aXMLTextReader.Read(); mImgMemStrm = new MemoryStream(Convert.FromBase64String(aXMLTextReader.ReadString())); } } } if (mImgMemStrm == null) { throw new ArgumentException("Image does not exist. "); } try { mBmp = new Bitmap(mImgMemStrm); } catch (Exception lExc) { mImgMemStrm.Close(); mImgMemStrm = null; throw new ArgumentException("Image is wrong. " + lExc.Message, lExc); } }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute <String>("Remote", ""); lChecker.addItemName(lItem); mRemoteItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("OnCMD", ""); lChecker.addItemName(lItem); mOnCMDItemHandle = mItemBrowser.getItemHandleByName(lItem); mUseOneCommand = lReader.getAttribute <Boolean>("UseOneCMD", mUseOneCommand); lItem = lReader.getAttribute <String>("OffCMD", ""); lChecker.addItemName(lItem); mOffCMDItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("EsdCMD", ""); lChecker.addItemName(lItem); mEsdCMDItemHandle = mItemBrowser.getItemHandleByName(lItem); OnMS = lReader.getAttribute <UInt32>("OnMS", mOnMS); OffMS = lReader.getAttribute <UInt32>("OffMS", mOffMS); lItem = lReader.getAttribute <String>("On", ""); lChecker.addItemName(lItem); mOnItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Power", ""); lChecker.addItemName(lItem); mPowerItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Alarm", ""); lChecker.addItemName(lItem); mAlarmItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("OnBtn", ""); lChecker.addItemName(lItem); mOnBtnItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("OffBtn", ""); lChecker.addItemName(lItem); mOffBtnItemHandle = mItemBrowser.getItemHandleByName(lItem); }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute <String>("Value"); lChecker.addItemName(lItem); mValueItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Input"); lChecker.addItemName(lItem); mInputItemHandle = mItemBrowser.getItemHandleByName(lItem); LagMS = lReader.getAttribute <UInt32>("LagMS", LagMS); Gain = lReader.getAttribute <Double>("Gain", Gain); }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); mFront = (EFront)Enum.Parse(typeof(EFront), lReader.getAttribute <String>("Front")); mPositiveInc = lReader.getAttribute <Boolean>("PositiveIncrease"); mNegativeInc = lReader.getAttribute <Boolean>("NegativeIncrease"); string lItem = lReader.getAttribute <String>("Input"); lChecker.addItemName(lItem); mInValueItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Output"); lChecker.addItemName(lItem); mOutValueItemHandle = mItemBrowser.getItemHandleByName(lItem); }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute <String>("InputItem"); lChecker.addItemName(lItem); mInValueItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("OutputItem"); lChecker.addItemName(lItem); mOutValueItemHandle = mItemBrowser.getItemHandleByName(lItem); Inverse = lReader.getAttribute <Boolean>("Inverse", Inverse); OnDelayMS = lReader.getAttribute <UInt32>("OnDelayMS", OnDelayMS); OffDelayMS = lReader.getAttribute <UInt32>("OffDelayMS", OffDelayMS); }
private void okCancelButton_ButtonClick(object aSender, EventArgs aEventArgs) { if (okCancelButton.DialogResult == DialogResult.Cancel) { DialogResult = DialogResult.Cancel; } else { try { if (String.IsNullOrWhiteSpace(itemEditBox_Value.ItemName)) { throw new ArgumentException("Output Item is missing. "); } if (String.IsNullOrWhiteSpace(itemEditBox_Set.ItemName)) { throw new ArgumentException("Item for trigger set is missing. "); } if (String.IsNullOrWhiteSpace(itemEditBox_Reset.ItemName)) { throw new ArgumentException("Item for trigger reset is missing. "); } var lChecker = new RepeatItemNameChecker(); lChecker.addItemName(itemEditBox_Value.ItemName); lChecker.addItemName(itemEditBox_Set.ItemName); lChecker.addItemName(itemEditBox_Reset.ItemName); mTrigger.SR_RS = radioButton_SR.Checked; mTrigger.mValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_Value.ItemName); mTrigger.mSetItemHandle = mBrowser.getItemHandleByName(itemEditBox_Set.ItemName); mTrigger.mResetItemHandle = mBrowser.getItemHandleByName(itemEditBox_Reset.ItemName); } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); return; } DialogResult = DialogResult.OK; } }
private void okCancelButton_ButtonClick(object aSender, EventArgs aEventArgs) { if (okCancelButton.DialogResult == DialogResult.Cancel) { DialogResult = DialogResult.Cancel; } else { try { if (String.IsNullOrWhiteSpace(itemEditBox_In1.ItemName)) { throw new ArgumentException("Input №1 Item is missing. "); } if (String.IsNullOrWhiteSpace(itemEditBox_In2.ItemName)) { throw new ArgumentException("Input №2 Item is missing. "); } if (String.IsNullOrWhiteSpace(itemEditBox_Value.ItemName)) { throw new ArgumentException("Output Item is missing. "); } var lChecker = new RepeatItemNameChecker(); lChecker.addItemName(itemEditBox_In1.ItemName); lChecker.addItemName(itemEditBox_In2.ItemName); lChecker.addItemName(itemEditBox_Value.ItemName); mComparator.mInput1ItemHandle = mBrowser.getItemHandleByName(itemEditBox_In1.ItemName); mComparator.mInput2ItemHandle = mBrowser.getItemHandleByName(itemEditBox_In2.ItemName); mComparator.mValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_Value.ItemName); mComparator.OperationIndex = comboBox_Operation.SelectedIndex; } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); return; } DialogResult = DialogResult.OK; } }
private void okCancelButton_ButtonClick(object aSender, EventArgs aEventArgs) { if (okCancelButton.DialogResult == DialogResult.Cancel) { DialogResult = DialogResult.Cancel; } else { try { if (String.IsNullOrWhiteSpace(itemEditBox_Input.ItemName)) { throw new ArgumentException("Input Item is missing. "); } if (String.IsNullOrWhiteSpace(itemEditBox_Value.ItemName)) { throw new ArgumentException("Output Item is missing. "); } var lChecker = new RepeatItemNameChecker(); lChecker.addItemName(itemEditBox_Input.ItemName); lChecker.addItemName(itemEditBox_Value.ItemName); mCounter.mInValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_Input.ItemName); mCounter.mOutValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_Value.ItemName); mCounter.Front = (EFront)comboBox_Front.SelectedIndex; mCounter.PositiveInc = (comboBox_P.SelectedIndex == 0); mCounter.NegativeInc = (comboBox_N.SelectedIndex == 0); mCounter.mReadOutput = checkBox_ReadOutput.Checked; DialogResult = DialogResult.OK; } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); } } }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); OperationString = lReader.getAttribute <String>("Operation"); string lItem = lReader.getAttribute <String>("Input1"); lChecker.addItemName(lItem); mInput1ItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Input2"); lChecker.addItemName(lItem); mInput2ItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Value"); lChecker.addItemName(lItem); mValueItemHandle = mItemBrowser.getItemHandleByName(lItem); }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute <String>("Set"); lChecker.addItemName(lItem); mSetItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Reset"); lChecker.addItemName(lItem); mResetItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Value"); lChecker.addItemName(lItem); mValueItemHandle = mItemBrowser.getItemHandleByName(lItem); SR_RS = lReader.getAttribute <Boolean>("SR_RS"); }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute <String>("On", ""); lChecker.addItemName(lItem); mOnItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Value"); lChecker.addItemName(lItem); mValueItemHandle = mItemBrowser.getItemHandleByName(lItem); SignalString = lReader.getAttribute <String>("Signal"); Bias = lReader.getAttribute <Double>("Bias", Bias); Amplitude = lReader.getAttribute <Double>("Amplitude", Amplitude); PeriodMS = lReader.getAttribute <UInt32>("PeriodMS", PeriodMS); TurnMS = lReader.getAttribute <UInt32>("TurnMS", TurnMS); }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute <String>("InputItem"); lChecker.addItemName(lItem); mInValueItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("OutputItem"); lChecker.addItemName(lItem); mOutValueItemHandle = mItemBrowser.getItemHandleByName(lItem); double lInMax = lReader.getAttribute <Double>("MaxInputValue"); double lInMin = lReader.getAttribute <Double>("MinInputValue"); double lOutMax = lReader.getAttribute <Double>("MaxOutputValue"); double lOutMin = lReader.getAttribute <Double>("MinOutputValue"); mValueScale.setProperties(lInMax, lInMin, lOutMax, lOutMin); }
private void okCancelButton_ButtonClick(object aSender, EventArgs aEventArgs) { if (okCancelButton.DialogResult == DialogResult.Cancel) { DialogResult = DialogResult.Cancel; } else { try { if (String.IsNullOrWhiteSpace(itemEditBox_In.ItemName)) { throw new ArgumentException("Input Item is missing. "); } if (String.IsNullOrWhiteSpace(itemEditBox_Out.ItemName)) { throw new ArgumentException("Output Item is missing. "); } var lChecker = new RepeatItemNameChecker(); lChecker.addItemName(itemEditBox_On.ItemName); lChecker.addItemName(itemEditBox_In.ItemName); lChecker.addItemName(itemEditBox_Out.ItemName); mDelay.mOnItemHandle = mBrowser.getItemHandleByName(itemEditBox_On.ItemName); mDelay.mInValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_In.ItemName); mDelay.mOutValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_Out.ItemName); mDelay.DelayMS = (uint)spinEdit_Delay.Value; } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); return; } DialogResult = DialogResult.OK; } }
private void okCancelButton_ButtonClick(object aSender, EventArgs aEventArgs) { if (okCancelButton.DialogResult == DialogResult.Cancel) { DialogResult = DialogResult.Cancel; } else { try { if (String.IsNullOrWhiteSpace(itemEditBox_In.ItemName)) { throw new ArgumentException("Input Item is missing. "); } if (String.IsNullOrWhiteSpace(itemEditBox_Out.ItemName)) { throw new ArgumentException("Output Item is missing. "); } var lChecker = new RepeatItemNameChecker(); lChecker.addItemName(itemEditBox_In.ItemName); lChecker.addItemName(itemEditBox_Out.ItemName); mDelay.mInValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_In.ItemName); mDelay.mOutValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_Out.ItemName); mDelay.Inverse = checkBox_Inverse.Checked; mDelay.OnDelayMS = (uint)spinEdit_On.Value; mDelay.OffDelayMS = (uint)spinEdit_Off.Value; } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); return; } DialogResult = DialogResult.OK; } }
private void okCancelButton_ButtonClick(object aSender, EventArgs aEventArgs) { if (okCancelButton.DialogResult == DialogResult.Cancel) { DialogResult = DialogResult.Cancel; } else { try { if (String.IsNullOrWhiteSpace(itemEditBox_X.ItemName)) { throw new ArgumentException("X Item is missing. "); } if (String.IsNullOrWhiteSpace(itemEditBox_Y.ItemName)) { throw new ArgumentException("Y Item is missing. "); } var lChecker = new RepeatItemNameChecker(); lChecker.addItemName(itemEditBox_X.ItemName); lChecker.addItemName(itemEditBox_Y.ItemName); mXYDependency.mInputItemHandle = mBrowser.getItemHandleByName(itemEditBox_X.ItemName); mXYDependency.mValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_Y.ItemName); mXYDependency.Points = mPoints; } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); return; } DialogResult = DialogResult.OK; } }
private void okCancelButton_ButtonClick(object aSender, EventArgs aEventArgs) { if (okCancelButton.DialogResult == DialogResult.Cancel) { DialogResult = DialogResult.Cancel; } else { try { if (String.IsNullOrWhiteSpace(itemEditBox_Value.ItemName)) { throw new ArgumentException("Output Item is missing. "); } var lChecker = new RepeatItemNameChecker(); lChecker.addItemName(itemEditBox_On.ItemName); lChecker.addItemName(itemEditBox_Value.ItemName); mGenerator.mOnItemHandle = mBrowser.getItemHandleByName(itemEditBox_On.ItemName); mGenerator.mValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_Value.ItemName); mGenerator.SignalIndex = comboBox_Signal.SelectedIndex; mGenerator.Bias = (double)spinEdit_Bias.Value; mGenerator.Amplitude = (double)spinEdit_Amplitude.Value; mGenerator.PeriodMS = (uint)spinEdit_PeriodMS.Value; mGenerator.TurnMS = (uint)spinEdit_TurnMS.Value; } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); return; } DialogResult = DialogResult.OK; } }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute<String>("Value"); lChecker.addItemName(lItem); mValueItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute<String>("Input"); lChecker.addItemName(lItem); mInputItemHandle = mItemBrowser.getItemHandleByName(lItem); LagMS = lReader.getAttribute<UInt32>("LagMS", LagMS); Gain = lReader.getAttribute<Double>("Gain", Gain); }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute <String>("Item"); lChecker.addItemName(lItem); mValueItemHandle = mItemBrowser.getItemHandleByName(lItem); double lPMax = lReader.getAttribute <Double>("MaxPhysicalValue"); double lPMin = lReader.getAttribute <Double>("MinPhysicalValue"); double lRawMax = lReader.getAttribute <Double>("MaxRawValue"); double lRawMin = lReader.getAttribute <Double>("MinRawValue"); mValueScale.setProperties(lRawMax, lRawMin, lPMax, lPMin); mFaultValue = lReader.getAttribute <Double>("FaultValue", mFaultValue); if (mFaultValue > lRawMin && mFaultValue < lRawMax) { throw new ArgumentException("Fault value is inside normal range. "); } mUnits = lReader.getAttribute <String>("Units", mUnits); #region Thresholds if (aXMLTextReader.IsEmptyElement == false) { aXMLTextReader.Read(); if (aXMLTextReader.Name.Equals("Thresholds", StringComparison.Ordinal)) { if (aXMLTextReader.IsEmptyElement == false) { List <int> lItems = new List <int>(); List <double> lValues = new List <double>(); List <ValuesCompare> lOperations = new List <ValuesCompare>(); double lValue; aXMLTextReader.Read(); while (aXMLTextReader.Name.Equals("Threshold", StringComparison.Ordinal)) { lOperations.Add(new ValuesCompare(lReader.getAttribute <String>("Operation"))); lValue = lReader.getAttribute <Double>("Value"); if (lValue > mValueScale.OutMax) { throw new ArgumentException("Threshold value is more than maximum of physical value. "); } if (lValue < mValueScale.OutMin) { throw new ArgumentException("Threshold value is less than minimum of physical value. "); } lValues.Add(lValue); lItem = lReader.getAttribute <String>("Item"); lChecker.addItemName(lItem); lItems.Add(mItemBrowser.getItemHandleByName(lItem)); aXMLTextReader.Read(); } if (lOperations.Count != 0) { mThdItemHandles = lItems.ToArray(); mThdItemValues = new bool[lOperations.Count]; mThdValues = lValues.ToArray(); mThdOperations = lOperations.ToArray(); } } aXMLTextReader.Read(); } } #endregion }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute <String>("ArrayItem"); lChecker.addItemName(lItem); mArrayValueItemHandle = mItemBrowser.getItemHandleByName(lItem); mDataFlow = (EDataFlow)Enum.Parse(typeof(EDataFlow), lReader.getAttribute <String>("DataFlow", mDataFlow.ToString())); #region Elements if (aXMLTextReader.IsEmptyElement == false) { aXMLTextReader.Read(); if (aXMLTextReader.Name.Equals("Elements", StringComparison.Ordinal)) { if (aXMLTextReader.IsEmptyElement == false) { List <int> lIndexes = new List <int>(); List <int> lItems = new List <int>(); var lIndexSet = new HashSet <int>(); int lMaxIndex = -1; int lIndex; aXMLTextReader.Read(); while (aXMLTextReader.Name.Equals("Element", StringComparison.Ordinal)) { lIndex = (int)lReader.getAttribute <UInt32>("Index"); if (lIndexSet.Add(lIndex) == false) { throw new ArgumentException("Index '" + lIndex.ToString() + "' already exists. "); } lIndexes.Add(lIndex); if (lIndex > lMaxIndex) { lMaxIndex = lIndex; } lItem = lReader.getAttribute <String>("Item"); lChecker.addItemName(lItem); lItems.Add(mItemBrowser.getItemHandleByName(lItem)); aXMLTextReader.Read(); } if (lIndexes.Count != 0) { mElementItemHandles = new int[lMaxIndex + 1]; for (int i = 0; i < mElementItemHandles.Length; i++) { mElementItemHandles[i] = -1; } mElementValueChanged = new bool[mElementItemHandles.Length]; mArrayValue = new object[mElementItemHandles.Length]; int lCount = lIndexes.Count; for (int i = 0; i < lCount; i++) { lIndex = lIndexes[i]; mElementItemHandles[lIndex] = lItems[i]; } } } aXMLTextReader.Read(); } } #endregion }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute<String>("InputItem"); lChecker.addItemName(lItem); mInValueItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute<String>("OutputItem"); lChecker.addItemName(lItem); mOutValueItemHandle = mItemBrowser.getItemHandleByName(lItem); Inverse = lReader.getAttribute<Boolean>("Inverse", Inverse); OnDelayMS = lReader.getAttribute<UInt32>("OnDelayMS", OnDelayMS); OffDelayMS = lReader.getAttribute<UInt32>("OffDelayMS", OffDelayMS); }
private bool checkElmParams(bool aCheckSelected) { try { var lIndexSet = new HashSet<int>(); var lChecker = new RepeatItemNameChecker(); lIndexSet.Add((int)spinEdit_Index.Value); lChecker.addItemName(itemEditBox_Item.ItemName); lChecker.addItemName(itemEditBox_Value.ItemName); int lCount = dataGridView_Bit.Rows.Count; for (int i = 0; i < lCount; i++) { if (aCheckSelected == false && i == dataGridView_Bit.SelectedRows[0].Index) { continue; } if (lIndexSet.Add((int)StringUtils.StringToObject(typeof(Int32), dataGridView_Bit.Rows[i].Cells[0].Value.ToString())) == false) { throw new ArgumentException("Bit '" + spinEdit_Index.Value.ToString() + "' already exists. "); } lChecker.addItemName(dataGridView_Bit.Rows[i].Cells[1].Value.ToString()); } } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); return false; } return true; }
private void okCancelButton_ButtonClick(object aSender, EventArgs aEventArgs) { if (okCancelButton.DialogResult == DialogResult.Cancel) { Cancel(); } else { try { if (String.IsNullOrWhiteSpace(itemEditBox_X.ItemName)) { throw new ArgumentException("X position Item is missing. "); } if (String.IsNullOrWhiteSpace(itemEditBox_Y.ItemName)) { throw new ArgumentException("Y position Item is missing. "); } if (mImgMemStrm == null || mBmp == null) { throw new ArgumentException("Image is empty. "); } var lChecker = new RepeatItemNameChecker(); lChecker.addItemName(itemEditBox_X.ItemName); lChecker.addItemName(itemEditBox_Y.ItemName); lChecker.addItemName(mBrowser.getItemNameByHandle(mVisibleItemHandle)); lChecker.addItemName(mBrowser.getItemNameByHandle(mMovingByUserItemHandle)); lChecker.addItemName(mBrowser.getItemNameByHandle(mWidthItemHandle)); lChecker.addItemName(mBrowser.getItemNameByHandle(mHeightItemHandle)); lChecker.addItemName(mBrowser.getItemNameByHandle(mLabelItemHandle)); lChecker.addItemName(mBrowser.getItemNameByHandle(mRotateItemHandle)); mMove.mXValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_X.ItemName); mMove.mYValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_Y.ItemName); mMove.mVisibleItemHandle = mVisibleItemHandle; if (mMove.mVisibleItemHandle == -1) { mMove.mVisible = true; } mMove.mUserCanMove = mUserMove; mMove.mMovingByUserItemHandle = mMovingByUserItemHandle; mMove.mWidthItemHandle = mWidthItemHandle; if (mWidthItemHandle == -1) { mMove.mWidth = mBmp.Width; } mMove.mHeightItemHandle = mHeightItemHandle; if (mHeightItemHandle == -1) { mMove.mHeight = mBmp.Height; } mMove.mLabelItemHandle = mLabelItemHandle; if (mLabelItemHandle == -1) { mMove.mLabel = ""; } mMove.mLabelFont = mLabelFont; mMove.mLabelColor = mLabelColor; mMove.mRotateItemHandle = mRotateItemHandle; if (mRotateItemHandle == -1) { mMove.mRotate = 0.0f; } if (mMove.mBmp != null && ReferenceEquals(mMove.mBmp, mBmp) == false) { mMove.mBmp.Dispose(); } if (mMove.mImgMemStrm != null && ReferenceEquals(mMove.mImgMemStrm, mImgMemStrm) == false) { mMove.mImgMemStrm.Close(); } mMove.mImgMemStrm = mImgMemStrm; mMove.mBmp = mBmp; mMove.raiseValuesChanged(); mMove.raisePropertiesChanged(); DialogResult = DialogResult.OK; } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); } } }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute<String>("ArrayItem"); lChecker.addItemName(lItem); mArrayValueItemHandle = mItemBrowser.getItemHandleByName(lItem); mDataFlow = (EDataFlow)Enum.Parse(typeof(EDataFlow), lReader.getAttribute<String>("DataFlow", mDataFlow.ToString())); #region Elements if (aXMLTextReader.IsEmptyElement == false) { aXMLTextReader.Read(); if (aXMLTextReader.Name.Equals("Elements", StringComparison.Ordinal)) { if (aXMLTextReader.IsEmptyElement == false) { List<int> lIndexes = new List<int>(); List<int> lItems = new List<int>(); var lIndexSet = new HashSet<int>(); int lMaxIndex = -1; int lIndex; aXMLTextReader.Read(); while (aXMLTextReader.Name.Equals("Element", StringComparison.Ordinal)) { lIndex = (int)lReader.getAttribute<UInt32>("Index"); if (lIndexSet.Add(lIndex) == false) { throw new ArgumentException("Index '" + lIndex.ToString() + "' already exists. "); } lIndexes.Add(lIndex); if (lIndex > lMaxIndex) { lMaxIndex = lIndex; } lItem = lReader.getAttribute<String>("Item"); lChecker.addItemName(lItem); lItems.Add(mItemBrowser.getItemHandleByName(lItem)); aXMLTextReader.Read(); } if (lIndexes.Count != 0) { mElementItemHandles = new int[lMaxIndex + 1]; for (int i = 0; i < mElementItemHandles.Length; i++) { mElementItemHandles[i] = -1; } mElementValueChanged = new bool[mElementItemHandles.Length]; mArrayValue = new object[mElementItemHandles.Length]; int lCount = lIndexes.Count; for (int i = 0; i < lCount; i++) { lIndex = lIndexes[i]; mElementItemHandles[lIndex] = lItems[i]; } } } aXMLTextReader.Read(); } } #endregion }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute<String>("Item"); lChecker.addItemName(lItem); mValueItemHandle = mItemBrowser.getItemHandleByName(lItem); double lPMax = lReader.getAttribute<Double>("MaxPhysicalValue"); double lPMin = lReader.getAttribute<Double>("MinPhysicalValue"); double lRawMax = lReader.getAttribute<Double>("MaxRawValue"); double lRawMin = lReader.getAttribute<Double>("MinRawValue"); mValueScale.setProperties(lRawMax, lRawMin, lPMax, lPMin); mFaultValue = lReader.getAttribute<Double>("FaultValue", mFaultValue); if (mFaultValue > lRawMin && mFaultValue < lRawMax) { throw new ArgumentException("Fault value is inside normal range. "); } mUnits = lReader.getAttribute<String>("Units", mUnits); #region Thresholds if (aXMLTextReader.IsEmptyElement == false) { aXMLTextReader.Read(); if (aXMLTextReader.Name.Equals("Thresholds", StringComparison.Ordinal)) { if (aXMLTextReader.IsEmptyElement == false) { List<int> lItems = new List<int>(); List<double> lValues = new List<double>(); List<ValuesCompare> lOperations = new List<ValuesCompare>(); double lValue; aXMLTextReader.Read(); while (aXMLTextReader.Name.Equals("Threshold", StringComparison.Ordinal)) { lOperations.Add(new ValuesCompare(lReader.getAttribute<String>("Operation"))); lValue = lReader.getAttribute<Double>("Value"); if (lValue > mValueScale.OutMax) { throw new ArgumentException("Threshold value is more than maximum of physical value. "); } if (lValue < mValueScale.OutMin) { throw new ArgumentException("Threshold value is less than minimum of physical value. "); } lValues.Add(lValue); lItem = lReader.getAttribute<String>("Item"); lChecker.addItemName(lItem); lItems.Add(mItemBrowser.getItemHandleByName(lItem)); aXMLTextReader.Read(); } if (lOperations.Count != 0) { mThdItemHandles = lItems.ToArray(); mThdItemValues = new bool[lOperations.Count]; mThdValues = lValues.ToArray(); mThdOperations = lOperations.ToArray(); } } aXMLTextReader.Read(); } } #endregion }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute<String>("Remote", ""); lChecker.addItemName(lItem); mRemoteItemHandle = mItemBrowser.getItemHandleByName(lItem); uint lUInt = lReader.getAttribute<UInt32>("TravelMS", mTravelMS); if (lUInt < MinTravelMS) { throw new ArgumentException("Travel time of valve has to be equal or more than " + StringUtils.ObjectToString(MinTravelMS) + ". "); } TravelMS = lUInt; lUInt = lReader.getAttribute<UInt32>("LimitSwitchMS", mLimitSwitchMS); if (lUInt == 0) { throw new ArgumentException("Limit switch time of valve has to be more than 0. "); } LimitSwitchMS = lUInt; mAnalogCtrl = lReader.getAttribute<Boolean>("AnalogControl", mAnalogCtrl); double lMax, lMin; lItem = lReader.getAttribute<String>("PositionCMD", ""); lChecker.addItemName(lItem); mPositionCMDItemHandle = mItemBrowser.getItemHandleByName(lItem); lMax = lReader.getAttribute<Double>("PositionCMDMax", mPositionCMDScale.InMax); lMin = lReader.getAttribute<Double>("PositionCMDMin", mPositionCMDScale.InMin); mPositionCMDScale.setProperties(lMax, lMin, 100.0D, 0.0D); lItem = lReader.getAttribute<String>("OpenCMD", ""); lChecker.addItemName(lItem); mOpenCMDItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute<String>("CloseCMD", ""); lChecker.addItemName(lItem); mCloseCMDItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute<String>("StopCMD", ""); lChecker.addItemName(lItem); mStopCMDItemHandle = mItemBrowser.getItemHandleByName(lItem); mImpulseCtrl = lReader.getAttribute<Boolean>("ImpulseControl", mImpulseCtrl); lItem = lReader.getAttribute<String>("EsdCMD", ""); lChecker.addItemName(lItem); mEsdCMDItemHandle = mItemBrowser.getItemHandleByName(lItem); mEsdOpen = lReader.getAttribute<Boolean>("EsdOpen", mEsdOpen); lItem = lReader.getAttribute<String>("OpenLimit", ""); lChecker.addItemName(lItem); mOpenLimitItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute<String>("Opens", ""); lChecker.addItemName(lItem); mOpensItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute<String>("ClosedLimit", ""); lChecker.addItemName(lItem); mClosedLimitItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute<String>("Closes", ""); lChecker.addItemName(lItem); mClosesItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute<String>("Rotation", ""); lChecker.addItemName(lItem); mRotationItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute<String>("Position", ""); lChecker.addItemName(lItem); mPositionItemHandle = mItemBrowser.getItemHandleByName(lItem); lMax = lReader.getAttribute<Double>("PositionMax", mPositionScale.InMax); lMin = lReader.getAttribute<Double>("PositionMin", mPositionScale.InMin); mPositionScale.setProperties(lMax, lMin, 100.0D, 0.0D); mFaultValue = lReader.getAttribute<Double>("FaultValue", mFaultValue); lItem = lReader.getAttribute<String>("Alarm1", ""); lChecker.addItemName(lItem); mAlarm1ItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute<String>("Alarm2", ""); lChecker.addItemName(lItem); mAlarm2ItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute<String>("Power", ""); lChecker.addItemName(lItem); mPowerItemHandle = mItemBrowser.getItemHandleByName(lItem); }
private void okCancelButton_ButtonClick(object aSender, EventArgs aEventArgs) { if (okCancelButton.DialogResult == DialogResult.Cancel) { DialogResult = DialogResult.Cancel; } else { try { #region Check double lMin; double lMax; double lFValue; try { lMin = StringUtils.toDouble(textBox_PositionCMDMin.Text); } catch (Exception lExc) { throw new ArgumentException("Wrong minimum value for 'Position' command. ", lExc); } try { lMax = StringUtils.toDouble(textBox_PositionCMDMax.Text); } catch (Exception lExc) { throw new ArgumentException("Wrong maximum value for 'Position' command. ", lExc); } mValve.mPositionCMDScale.checkProperties(lMax, lMin, 100.0D, 0.0D); try { lMin = StringUtils.toDouble(textBox_PositionMin.Text); } catch (Exception lExc) { throw new ArgumentException("Wrong minimum value for 'Position' signal. ", lExc); } try { lMax = StringUtils.toDouble(textBox_PositionMax.Text); } catch (Exception lExc) { throw new ArgumentException("Wrong maximum value for 'Position' signal. ", lExc); } mValve.mPositionScale.checkProperties(lMax, lMin, 100.0D, 0.0D); try { lFValue = StringUtils.toDouble(textBox_FValue.Text); } catch (Exception lExc) { throw new ArgumentException("Wrong fault value. ", lExc); } if (checkBox_ImpCtrl.Checked && checkBox_UseOneCommand.Checked) { throw new ArgumentException("Impulse control is not supported when using only one command. "); } var lChecker = new RepeatItemNameChecker(); lChecker.addItemName(itemEditBox_Remote.ItemName); lChecker.addItemName(itemEditBox_PositionCMD.ItemName); lChecker.addItemName(itemEditBox_OpenCMD.ItemName); lChecker.addItemName(itemEditBox_CloseCMD.ItemName); lChecker.addItemName(itemEditBox_StopCMD.ItemName); lChecker.addItemName(itemEditBox_EsdCMD.ItemName); lChecker.addItemName(itemEditBox_OpenLimit.ItemName); lChecker.addItemName(itemEditBox_Opens.ItemName); lChecker.addItemName(itemEditBox_ClosedLimit.ItemName); lChecker.addItemName(itemEditBox_Closes.ItemName); lChecker.addItemName(itemEditBox_Rotation.ItemName); lChecker.addItemName(itemEditBox_Position.ItemName); lChecker.addItemName(itemEditBox_Alarm1.ItemName); lChecker.addItemName(itemEditBox_Alarm2.ItemName); lChecker.addItemName(itemEditBox_Power.ItemName); #endregion mValve.mAnalogCtrl = (tabControl_Control.SelectedIndex == 1); mValve.mEsdOpen = checkBox_EsdOpen.Checked; mValve.mImpulseCtrl = checkBox_ImpCtrl.Checked; mValve.mPositionCMDScale.setProperties(StringUtils.toDouble(textBox_PositionCMDMax.Text), StringUtils.toDouble(textBox_PositionCMDMin.Text), 100.0D, 0.0D); mValve.mPositionScale.setProperties(StringUtils.toDouble(textBox_PositionMax.Text), StringUtils.toDouble(textBox_PositionMin.Text), 100.0D, 0.0D); mValve.mFaultValue = lFValue; mValve.LimitSwitchMS = (uint)spinEdit_LimitMS.Value; mValve.TravelMS = (uint)spinEdit_TravelMS.Value; mValve.mRemoteItemHandle = mBrowser.getItemHandleByName(itemEditBox_Remote.ItemName); if (mValve.mRemoteItemHandle == -1) { mValve.Remote = true; } mValve.mPositionCMDItemHandle = mBrowser.getItemHandleByName(itemEditBox_PositionCMD.ItemName); mValve.mOpenCMDItemHandle = mBrowser.getItemHandleByName(itemEditBox_OpenCMD.ItemName); if (mValve.mOpenCMDItemHandle == -1) { mValve.mOpenCMD = false; } mValve.UseOneCommand = checkBox_UseOneCommand.Checked; mValve.mCloseCMDItemHandle = mBrowser.getItemHandleByName(itemEditBox_CloseCMD.ItemName); if (mValve.mCloseCMDItemHandle == -1) { mValve.mCloseCMD = false; } mValve.mStopCMDItemHandle = mBrowser.getItemHandleByName(itemEditBox_StopCMD.ItemName); if (mValve.mStopCMDItemHandle == -1) { mValve.mStopCMD = false; } mValve.mEsdCMDItemHandle = mBrowser.getItemHandleByName(itemEditBox_EsdCMD.ItemName); if (mValve.mEsdCMDItemHandle == -1) { mValve.mEsdCMD = false; } mValve.mOpenLimitItemHandle = mBrowser.getItemHandleByName(itemEditBox_OpenLimit.ItemName); mValve.mOpensItemHandle = mBrowser.getItemHandleByName(itemEditBox_Opens.ItemName); mValve.mClosedLimitItemHandle = mBrowser.getItemHandleByName(itemEditBox_ClosedLimit.ItemName); mValve.mClosesItemHandle = mBrowser.getItemHandleByName(itemEditBox_Closes.ItemName); mValve.mRotationItemHandle = mBrowser.getItemHandleByName(itemEditBox_Rotation.ItemName); mValve.mPositionItemHandle = mBrowser.getItemHandleByName(itemEditBox_Position.ItemName); mValve.mAlarm1ItemHandle = mBrowser.getItemHandleByName(itemEditBox_Alarm1.ItemName); if (mValve.mAlarm1ItemHandle == -1) { mValve.Alarm1 = false; } mValve.mAlarm2ItemHandle = mBrowser.getItemHandleByName(itemEditBox_Alarm2.ItemName); if (mValve.mAlarm2ItemHandle == -1) { mValve.Alarm2 = false; } mValve.mPowerItemHandle = mBrowser.getItemHandleByName(itemEditBox_Power.ItemName); if (mValve.mPowerItemHandle == -1) { mValve.Power = true; } mValve.IgnoreCommands = checkBox_IgnoreCommands.Checked; mValve.ForseLimSwitches = checkBox_ForceLimSwitches.Checked; mValve.PositionFault = checkBox_PositionF.Checked; DialogResult = DialogResult.OK; } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); } } }
private bool checkThdParams(bool aCheckSelected) { try { double lValue; double lPMin; double lPMax; try { lValue = StringUtils.toDouble(textBox_ThdValue.Text); } catch(Exception lExc) { throw new ArgumentException("Wrong threshold value. ", lExc); } try { lPMin = StringUtils.toDouble(textBox_PMin.Text); } catch(Exception lExc) { throw new ArgumentException("Wrong minimum value for physical signal. ", lExc); } try { lPMax = StringUtils.toDouble(textBox_PMax.Text); } catch (Exception lExc) { throw new ArgumentException("Wrong maximum value for physical signal. ", lExc); } if (lValue > lPMax) { throw new ArgumentException("Threshold value is more than maximum of physical value. "); } if (lValue < lPMin) { throw new ArgumentException("Threshold value is less than minimum of physical value. "); } if (String.IsNullOrWhiteSpace(itemEditBox_Thd.ItemName)) { throw new ArgumentException("Threshold Item is missing. "); } var lChecker = new RepeatItemNameChecker(); lChecker.addItemName(itemEditBox_Item.ItemName); lChecker.addItemName(itemEditBox_Thd.ItemName); int lCount = dataGridView_Thd.Rows.Count; for (int i = 0; i < lCount; i++) { if (aCheckSelected == false && i == dataGridView_Thd.SelectedRows[0].Index) { continue; } lChecker.addItemName(dataGridView_Thd.Rows[i].Cells[2].Value.ToString()); } } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); return false; } return true; }
private void okCancelButton_ButtonClick(object aSender, EventArgs aEventArgs) { if (okCancelButton.DialogResult == DialogResult.Cancel) { DialogResult = DialogResult.Cancel; } else { try { if (String.IsNullOrWhiteSpace(itemEditBox_Value.ItemName)) { throw new ArgumentException("Value Item is missing. "); } var lIndexSet = new HashSet<int>(); var lChecker = new RepeatItemNameChecker(); lChecker.addItemName(itemEditBox_Value.ItemName); int lMaxIndex = -1; int lIndex; int lCount = dataGridView_Bit.Rows.Count; for (int i = 0; i < lCount; i++) { lIndex = (int)StringUtils.StringToObject(typeof(Int32), dataGridView_Bit.Rows[i].Cells[0].Value.ToString()); if (lIndexSet.Add(lIndex) == false) { throw new ArgumentException("Bit '" + lIndex.ToString() + "' already exists. "); } if (lIndex > lMaxIndex) { lMaxIndex = lIndex; } lChecker.addItemName(dataGridView_Bit.Rows[i].Cells[1].Value.ToString()); } mSplitter.mBitsValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_Value.ItemName); mSplitter.mBitItemHandles = new int[lMaxIndex + 1]; for (int i = 0; i < mSplitter.mBitItemHandles.Length; i++) { mSplitter.mBitItemHandles[i] = -1; } mSplitter.mBitValueChanged = new bool[mSplitter.mBitItemHandles.Length]; mSplitter.mBitsValue = new bool[mSplitter.mBitItemHandles.Length]; for (int i = 0; i < lCount; i++) { lIndex = (int)StringUtils.StringToObject(typeof(Int32), dataGridView_Bit.Rows[i].Cells[0].Value.ToString()); mSplitter.mBitItemHandles[lIndex] = mBrowser.getItemHandleByName(dataGridView_Bit.Rows[i].Cells[1].Value.ToString()); } switch (comboBox_DataFlow.SelectedIndex) { case 0: mSplitter.mDataFlow = EDataFlow.FROM; break; case 1: mSplitter.mDataFlow = EDataFlow.TO; break; case 2: mSplitter.mDataFlow = EDataFlow.BOTH; break; } } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); return; } DialogResult = DialogResult.OK; } }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); OperatorString = lReader.getAttribute<String>("Operator"); string lItem = lReader.getAttribute<String>("Input1"); lChecker.addItemName(lItem); mInput1ItemHandle = mItemBrowser.getItemHandleByName(lItem); mInput1Inverse = lReader.getAttribute<Boolean>("Input1Inverse", mInput1Inverse); lItem = lReader.getAttribute<String>("Input2", ""); lChecker.addItemName(lItem); mInput2ItemHandle = mItemBrowser.getItemHandleByName(lItem); mInput2Inverse = lReader.getAttribute<Boolean>("Input2Inverse", mInput2Inverse); lItem = lReader.getAttribute<String>("Value"); lChecker.addItemName(lItem); mValueItemHandle = mItemBrowser.getItemHandleByName(lItem); }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); SendData = lReader.getAttribute<Boolean>("SendData", SendData); UpdateRoKiSimMS = (int)lReader.getAttribute<UInt32>("UpdateRoKiSimMS", (uint)UpdateRoKiSimMS); if (aXMLTextReader.IsEmptyElement == false) { aXMLTextReader.Read(); if (aXMLTextReader.Name.Equals("Joints", StringComparison.Ordinal)) { if (aXMLTextReader.IsEmptyElement == false) { var lIndexSet = new HashSet<int>(); int lIndex; int lArrayIndex; string lItem; aXMLTextReader.Read(); while (aXMLTextReader.Name.Equals("Joint", StringComparison.Ordinal)) { lIndex = (int)lReader.getAttribute<UInt32>("Index"); if(lIndex == 0 || lIndex > 6) { throw new ArgumentException("Wrong joint number. "); } if (lIndexSet.Add(lIndex) == false) { throw new ArgumentException("Joint №" + lIndex.ToString() + " already exists. "); } lArrayIndex = lIndex - 1; lItem = lReader.getAttribute<String>("SetPointItem", ""); lChecker.addItemName(lItem); mAxisSPItemHandle[lArrayIndex] = mItemBrowser.getItemHandleByName(lItem); mMaxSpeed[lArrayIndex] = lReader.getAttribute<Double>("MaxSpeed", mMaxSpeed[lArrayIndex]); if (mMaxSpeed[lArrayIndex] <= 0.0D) { throw new ArgumentException("Maximum speed of joint №" + lIndex.ToString() + " must be greater than zero. "); } lItem = lReader.getAttribute<String>("AngleItem", ""); lChecker.addItemName(lItem); mAxisAngleItemHandle[lArrayIndex] = mItemBrowser.getItemHandleByName(lItem); mMaxAngle[lArrayIndex] = lReader.getAttribute<Double>("MaxAngle", mMaxAngle[lArrayIndex]); mMinAngle[lArrayIndex] = lReader.getAttribute<Double>("MinAngle", mMinAngle[lArrayIndex]); if (mMaxAngle[lArrayIndex] <= mMinAngle[lArrayIndex]) { throw new ArgumentException("The maximum angle of joint №" + lIndex.ToString() + " has to be greater than minimum. "); } aXMLTextReader.Read(); } } aXMLTextReader.Read(); } } }
private void okCancelButton_ButtonClick(object aSender, EventArgs aEventArgs) { if (okCancelButton.DialogResult == DialogResult.Cancel) { DialogResult = DialogResult.Cancel; } else { try { var lChecker = new RepeatItemNameChecker(); lChecker.addItemName(itemEditBox_Power.ItemName); lChecker.addItemName(itemEditBox_OnCMD.ItemName); lChecker.addItemName(itemEditBox_OffCMD.ItemName); lChecker.addItemName(itemEditBox_EsdCMD.ItemName); lChecker.addItemName(itemEditBox_On.ItemName); lChecker.addItemName(itemEditBox_Alarm.ItemName); lChecker.addItemName(itemEditBox_Remote.ItemName); lChecker.addItemName(itemEditBox_OnBtn.ItemName); lChecker.addItemName(itemEditBox_OffBtn.ItemName); mPump.IgnoreCommands = checkBox_IgnoreCommands.Checked; mPump.OnMS = (uint)spinEdit_On.Value; mPump.OffMS = (uint)spinEdit_Off.Value; mPump.mRemoteItemHandle = mBrowser.getItemHandleByName(itemEditBox_Remote.ItemName); if (mPump.mRemoteItemHandle == -1) { mPump.Remote = true; } mPump.mOnCMDItemHandle = mBrowser.getItemHandleByName(itemEditBox_OnCMD.ItemName); if (mPump.mOnCMDItemHandle == -1) { mPump.mOnCMD = false; } mPump.mOffCMDItemHandle = mBrowser.getItemHandleByName(itemEditBox_OffCMD.ItemName); if (mPump.mOffCMDItemHandle == -1) { mPump.mOffCMD = false; } mPump.mEsdCMDItemHandle = mBrowser.getItemHandleByName(itemEditBox_EsdCMD.ItemName); if (mPump.mEsdCMDItemHandle == -1) { mPump.mEsdCMD = false; } mPump.mOnItemHandle = mBrowser.getItemHandleByName(itemEditBox_On.ItemName); mPump.mAlarmItemHandle = mBrowser.getItemHandleByName(itemEditBox_Alarm.ItemName); if (mPump.mAlarmItemHandle == -1) { mPump.Alarm = false; } mPump.mPowerItemHandle = mBrowser.getItemHandleByName(itemEditBox_Power.ItemName); if (mPump.mPowerItemHandle == -1) { mPump.Power = true; } mPump.mOnBtnItemHandle = mBrowser.getItemHandleByName(itemEditBox_OnBtn.ItemName); if (mPump.mOnBtnItemHandle == -1) { mPump.OnBtn = false; } mPump.mOffBtnItemHandle = mBrowser.getItemHandleByName(itemEditBox_OffBtn.ItemName); if (mPump.mOffBtnItemHandle == -1) { mPump.OffBtn = false; } } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); return; } DialogResult = DialogResult.OK; } }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute<String>("On", ""); lChecker.addItemName(lItem); mOnItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute<String>("Value"); lChecker.addItemName(lItem); mValueItemHandle = mItemBrowser.getItemHandleByName(lItem); SignalString = lReader.getAttribute<String>("Signal"); Bias = lReader.getAttribute<Double>("Bias", Bias); Amplitude = lReader.getAttribute<Double>("Amplitude", Amplitude); PeriodMS = lReader.getAttribute<UInt32>("PeriodMS", PeriodMS); TurnMS = lReader.getAttribute<UInt32>("TurnMS", TurnMS); }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); double lMax, lMin; string lItem = lReader.getAttribute <String>("StartCMD", ""); lChecker.addItemName(lItem); mStartCMDItemHandle = mItemBrowser.getItemHandleByName(lItem); mUseOneCommand = lReader.getAttribute <Boolean>("UseOneCMD", mUseOneCommand); lItem = lReader.getAttribute <String>("StopCMD", ""); lChecker.addItemName(lItem); mStopCMDItemHandle = mItemBrowser.getItemHandleByName(lItem); StartMS = lReader.getAttribute <UInt32>("StartMS", mStartMS); StopMS = lReader.getAttribute <UInt32>("StopMS", mStopMS); lItem = lReader.getAttribute <String>("SpeedCMD", ""); lChecker.addItemName(lItem); mSpeedCMDItemHandle = mItemBrowser.getItemHandleByName(lItem); lMax = lReader.getAttribute <Double>("SpeedCMDMax", mSpeedCMDScale.InMax); lMin = lReader.getAttribute <Double>("SpeedCMDMin", mSpeedCMDScale.InMin); mSpeedCMDScale.setProperties(lMax, lMin, 100.0D, 0.0D); lItem = lReader.getAttribute <String>("Moving", ""); lChecker.addItemName(lItem); mMovingItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Alarm", ""); lChecker.addItemName(lItem); mAlarmItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Reverse", ""); lChecker.addItemName(lItem); mReverseItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Acceleration", ""); lChecker.addItemName(lItem); mAccelerationItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Braking", ""); lChecker.addItemName(lItem); mBrakingItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Speed", ""); lChecker.addItemName(lItem); mSpeedItemHandle = mItemBrowser.getItemHandleByName(lItem); lMax = lReader.getAttribute <Double>("SpeedMax", mSpeedScale.InMax); lMin = lReader.getAttribute <Double>("SpeedMin", mSpeedScale.InMin); mSpeedScale.setProperties(lMax, lMin, 100.0D, 0.0D); lItem = lReader.getAttribute <String>("Forward", ""); lChecker.addItemName(lItem); mForwardItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Backward", ""); lChecker.addItemName(lItem); mBackwardItemHandle = mItemBrowser.getItemHandleByName(lItem); }
private void okCancelButton_ButtonClick(object aSender, EventArgs aEventArgs) { if (okCancelButton.DialogResult == DialogResult.Cancel) { DialogResult = DialogResult.Cancel; } else { try { if (String.IsNullOrWhiteSpace(itemEditBox_Input.ItemName)) { throw new ArgumentException("Input Item is missing. "); } if (String.IsNullOrWhiteSpace(itemEditBox_Output.ItemName)) { throw new ArgumentException("Output Item is missing. "); } var lChecker = new RepeatItemNameChecker(); lChecker.addItemName(itemEditBox_Input.ItemName); lChecker.addItemName(itemEditBox_Output.ItemName); double lInMin; double lInMax; double lOutMin; double lOutMax; try { lInMin = StringUtils.toDouble(textBox_InMin.Text); } catch (Exception lExc) { throw new ArgumentException("Wrong minimum value for input signal. ", lExc); } try { lInMax = StringUtils.toDouble(textBox_InMax.Text); } catch (Exception lExc) { throw new ArgumentException("Wrong maximum value for input signal. ", lExc); } try { lOutMin = StringUtils.toDouble(textBox_OutMin.Text); } catch (Exception lExc) { throw new ArgumentException("Wrong minimum value for output signal. ", lExc); } try { lOutMax = StringUtils.toDouble(textBox_OutMax.Text); } catch (Exception lExc) { throw new ArgumentException("Wrong maximum value for output signal. ", lExc); } mScaleReal.mValueScale.setProperties(lInMax, lInMin, lOutMax, lOutMin); mScaleReal.mInValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_Input.ItemName); mScaleReal.mOutValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_Output.ItemName); DialogResult = DialogResult.OK; } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); } } }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute<String>("InputItem"); lChecker.addItemName(lItem); mInValueItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute<String>("OutputItem"); lChecker.addItemName(lItem); mOutValueItemHandle = mItemBrowser.getItemHandleByName(lItem); double lInMax = lReader.getAttribute<Double>("MaxInputValue"); double lInMin = lReader.getAttribute<Double>("MinInputValue"); double lOutMax = lReader.getAttribute<Double>("MaxOutputValue"); double lOutMin = lReader.getAttribute<Double>("MinOutputValue"); mValueScale.setProperties(lInMax, lInMin, lOutMax, lOutMin); }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute<String>("Set"); lChecker.addItemName(lItem); mSetItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute<String>("Reset"); lChecker.addItemName(lItem); mResetItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute<String>("Value"); lChecker.addItemName(lItem); mValueItemHandle = mItemBrowser.getItemHandleByName(lItem); SR_RS = lReader.getAttribute<Boolean>("SR_RS"); }
private void okCancelButton_ButtonClick(object aSender, EventArgs aEventArgs) { if (okCancelButton.DialogResult == DialogResult.Cancel) { DialogResult = DialogResult.Cancel; } else { try { var lChecker = new RepeatItemNameChecker(); lChecker.addItemName(itemEditBox_Power.ItemName); lChecker.addItemName(itemEditBox_OnCMD.ItemName); lChecker.addItemName(itemEditBox_OffCMD.ItemName); lChecker.addItemName(itemEditBox_EsdCMD.ItemName); lChecker.addItemName(itemEditBox_On.ItemName); lChecker.addItemName(itemEditBox_Alarm.ItemName); lChecker.addItemName(itemEditBox_Remote.ItemName); lChecker.addItemName(itemEditBox_OnBtn.ItemName); lChecker.addItemName(itemEditBox_OffBtn.ItemName); mPump.IgnoreCommands = checkBox_IgnoreCommands.Checked; mPump.UseOneCommand = checkBox_UseOneCommand.Checked; mPump.OnMS = (uint)spinEdit_On.Value; mPump.OffMS = (uint)spinEdit_Off.Value; mPump.mRemoteItemHandle = mBrowser.getItemHandleByName(itemEditBox_Remote.ItemName); if (mPump.mRemoteItemHandle == -1) { mPump.Remote = true; } mPump.mOnCMDItemHandle = mBrowser.getItemHandleByName(itemEditBox_OnCMD.ItemName); if (mPump.mOnCMDItemHandle == -1) { mPump.mOnCMD = false; } mPump.mOffCMDItemHandle = mBrowser.getItemHandleByName(itemEditBox_OffCMD.ItemName); if (mPump.mOffCMDItemHandle == -1) { mPump.mOffCMD = false; } mPump.mEsdCMDItemHandle = mBrowser.getItemHandleByName(itemEditBox_EsdCMD.ItemName); if (mPump.mEsdCMDItemHandle == -1) { mPump.mEsdCMD = false; } mPump.mOnItemHandle = mBrowser.getItemHandleByName(itemEditBox_On.ItemName); mPump.mAlarmItemHandle = mBrowser.getItemHandleByName(itemEditBox_Alarm.ItemName); if (mPump.mAlarmItemHandle == -1) { mPump.Alarm = false; } mPump.mPowerItemHandle = mBrowser.getItemHandleByName(itemEditBox_Power.ItemName); if (mPump.mPowerItemHandle == -1) { mPump.Power = true; } mPump.mOnBtnItemHandle = mBrowser.getItemHandleByName(itemEditBox_OnBtn.ItemName); if (mPump.mOnBtnItemHandle == -1) { mPump.OnBtn = false; } mPump.mOffBtnItemHandle = mBrowser.getItemHandleByName(itemEditBox_OffBtn.ItemName); if (mPump.mOffBtnItemHandle == -1) { mPump.OffBtn = false; } DialogResult = DialogResult.OK; } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); } } }
private void okCancelButton_ButtonClick(object aSender, EventArgs aEventArgs) { if (okCancelButton.DialogResult == DialogResult.Cancel) { DialogResult = DialogResult.Cancel; } else { try { if (String.IsNullOrWhiteSpace(itemEditBox_Value.ItemName)) { throw new ArgumentException("Value Item is missing. "); } var lIndexSet = new HashSet <int>(); var lChecker = new RepeatItemNameChecker(); lChecker.addItemName(itemEditBox_Value.ItemName); int lMaxIndex = -1; int lIndex; int lCount = dataGridView_Bit.Rows.Count; for (int i = 0; i < lCount; i++) { lIndex = (int)StringUtils.StringToObject(typeof(Int32), dataGridView_Bit.Rows[i].Cells[0].Value.ToString()); if (lIndexSet.Add(lIndex) == false) { throw new ArgumentException("Bit '" + lIndex.ToString() + "' already exists. "); } if (lIndex > lMaxIndex) { lMaxIndex = lIndex; } lChecker.addItemName(dataGridView_Bit.Rows[i].Cells[1].Value.ToString()); } mSplitter.mBitsValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_Value.ItemName); mSplitter.mBitItemHandles = new int[lMaxIndex + 1]; for (int i = 0; i < mSplitter.mBitItemHandles.Length; i++) { mSplitter.mBitItemHandles[i] = -1; } mSplitter.mBitValueChanged = new bool[mSplitter.mBitItemHandles.Length]; mSplitter.mBitsValue = new bool[mSplitter.mBitItemHandles.Length]; for (int i = 0; i < lCount; i++) { lIndex = (int)StringUtils.StringToObject(typeof(Int32), dataGridView_Bit.Rows[i].Cells[0].Value.ToString()); mSplitter.mBitItemHandles[lIndex] = mBrowser.getItemHandleByName(dataGridView_Bit.Rows[i].Cells[1].Value.ToString()); } switch (comboBox_DataFlow.SelectedIndex) { case 0: mSplitter.mDataFlow = EDataFlow.FROM; break; case 1: mSplitter.mDataFlow = EDataFlow.TO; break; case 2: mSplitter.mDataFlow = EDataFlow.BOTH; break; } } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); return; } DialogResult = DialogResult.OK; } }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); SendData = lReader.getAttribute <Boolean>("SendData", SendData); UpdateRoKiSimMS = (int)lReader.getAttribute <UInt32>("UpdateRoKiSimMS", (uint)UpdateRoKiSimMS); if (aXMLTextReader.IsEmptyElement == false) { aXMLTextReader.Read(); if (aXMLTextReader.Name.Equals("Joints", StringComparison.Ordinal)) { if (aXMLTextReader.IsEmptyElement == false) { var lIndexSet = new HashSet <int>(); int lIndex; int lArrayIndex; string lItem; aXMLTextReader.Read(); while (aXMLTextReader.Name.Equals("Joint", StringComparison.Ordinal)) { lIndex = (int)lReader.getAttribute <UInt32>("Index"); if (lIndex == 0 || lIndex > 6) { throw new ArgumentException("Wrong joint number. "); } if (lIndexSet.Add(lIndex) == false) { throw new ArgumentException("Joint №" + lIndex.ToString() + " already exists. "); } lArrayIndex = lIndex - 1; lItem = lReader.getAttribute <String>("SetPointItem", ""); lChecker.addItemName(lItem); mAxisSPItemHandle[lArrayIndex] = mItemBrowser.getItemHandleByName(lItem); mMaxSpeed[lArrayIndex] = lReader.getAttribute <Double>("MaxSpeed", mMaxSpeed[lArrayIndex]); if (mMaxSpeed[lArrayIndex] <= 0.0D) { throw new ArgumentException("Maximum speed of joint №" + lIndex.ToString() + " must be greater than zero. "); } lItem = lReader.getAttribute <String>("AngleItem", ""); lChecker.addItemName(lItem); mAxisAngleItemHandle[lArrayIndex] = mItemBrowser.getItemHandleByName(lItem); mMaxAngle[lArrayIndex] = lReader.getAttribute <Double>("MaxAngle", mMaxAngle[lArrayIndex]); mMinAngle[lArrayIndex] = lReader.getAttribute <Double>("MinAngle", mMinAngle[lArrayIndex]); if (mMaxAngle[lArrayIndex] <= mMinAngle[lArrayIndex]) { throw new ArgumentException("The maximum angle of joint №" + lIndex.ToString() + " has to be greater than minimum. "); } aXMLTextReader.Read(); } } aXMLTextReader.Read(); } } }
private void okCancelButton_ButtonClick(object aSender, EventArgs aEventArgs) { if (okCancelButton.DialogResult == DialogResult.Cancel) { DialogResult = DialogResult.Cancel; } else { try { if (String.IsNullOrWhiteSpace(itemEditBox_Item.ItemName)) { throw new ArgumentException("Item is missing. "); } double lRawMin; double lRawMax; double lFValue; double lPMin; double lPMax; try { lRawMin = StringUtils.toDouble(textBox_RawMin.Text); } catch (Exception lExc) { throw new ArgumentException("Wrong minimum value for raw signal. ", lExc); } try { lRawMax = StringUtils.toDouble(textBox_RawMax.Text); } catch (Exception lExc) { throw new ArgumentException("Wrong maximum value for raw signal. ", lExc); } try { lFValue = StringUtils.toDouble(textBox_FValue.Text); } catch (Exception lExc) { throw new ArgumentException("Wrong fault value for raw signal. ", lExc); } try { lPMin = StringUtils.toDouble(textBox_PMin.Text); } catch (Exception lExc) { throw new ArgumentException("Wrong minimum value for physical signal. ", lExc); } try { lPMax = StringUtils.toDouble(textBox_PMax.Text); } catch (Exception lExc) { throw new ArgumentException("Wrong maximum value for physical signal. ", lExc); } mAnalogSensor.mValueScale.checkProperties(lRawMax, lRawMin, lPMax, lPMin); if (lFValue > lRawMin && lFValue < lRawMax) { throw new ArgumentException("Fault value is inside normal range. "); } var lChecker = new RepeatItemNameChecker(); lChecker.addItemName(itemEditBox_Item.ItemName); double lValue; int lCount = dataGridView_Thd.Rows.Count; for (int i = 0; i < lCount; i++) { lChecker.addItemName(dataGridView_Thd.Rows[i].Cells[2].Value.ToString()); try { lValue = StringUtils.toDouble(dataGridView_Thd.Rows[i].Cells[1].Value.ToString()); } catch (Exception lExc) { throw new ArgumentException("Wrong threshold value '" + dataGridView_Thd.Rows[i].Cells[1].Value.ToString() + "'. ", lExc); } if (lValue > lPMax) { throw new ArgumentException("Threshold value is more than maximum of physical value. "); } if (lValue < lPMin) { throw new ArgumentException("Threshold value is less than minimum of physical value. "); } } mAnalogSensor.mValueItemHandle = mBrowser.getItemHandleByName(itemEditBox_Item.ItemName); mAnalogSensor.Units = textBox_Units.Text; mAnalogSensor.mValueScale.setProperties(lRawMax, lRawMin, lPMax, lPMin); mAnalogSensor.mFault = checkBox_Fault.Checked; mAnalogSensor.mFaultValue = lFValue; int lThdCount = dataGridView_Thd.Rows.Count; mAnalogSensor.mThdItemHandles = new int[lThdCount]; mAnalogSensor.mThdItemValues = new bool[lThdCount]; mAnalogSensor.Thresholds = new double[lThdCount]; mAnalogSensor.mThdOperations = new ValuesCompare[lThdCount]; for (int i = 0; i < lThdCount; i++) { mAnalogSensor.mThdOperations[i] = new ValuesCompare(dataGridView_Thd.Rows[i].Cells[0].Value.ToString()); mAnalogSensor.Thresholds[i] = StringUtils.toDouble(dataGridView_Thd.Rows[i].Cells[1].Value.ToString()); mAnalogSensor.mThdItemHandles[i] = mBrowser.getItemHandleByName(dataGridView_Thd.Rows[i].Cells[2].Value.ToString()); } } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); return; } DialogResult = DialogResult.OK; } }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); string lItem = lReader.getAttribute <String>("X"); lChecker.addItemName(lItem); mXValueItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Y"); lChecker.addItemName(lItem); mYValueItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Visible", ""); lChecker.addItemName(lItem); mVisibleItemHandle = mItemBrowser.getItemHandleByName(lItem); mUserCanMove = lReader.getAttribute <Boolean>("UserCanMove", mUserCanMove); lItem = lReader.getAttribute <String>("MovingByUser", ""); lChecker.addItemName(lItem); mMovingByUserItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Width", ""); lChecker.addItemName(lItem); mWidthItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Height", ""); lChecker.addItemName(lItem); mHeightItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Label", ""); lChecker.addItemName(lItem); mLabelItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Rotate", ""); lChecker.addItemName(lItem); mRotateItemHandle = mItemBrowser.getItemHandleByName(lItem); mLabelFont = lReader.getAttribute <Font>("LabelFont", mLabelFont); mLabelColor = lReader.getAttribute <Color>("LabelColor", mLabelColor); if (aXMLTextReader.IsEmptyElement == false) { aXMLTextReader.Read(); if (aXMLTextReader.Name.Equals("Image", StringComparison.Ordinal)) { if (aXMLTextReader.IsEmptyElement == false) { aXMLTextReader.Read(); mImgMemStrm = new MemoryStream(Convert.FromBase64String(aXMLTextReader.ReadString())); } } } if (mImgMemStrm == null) { throw new ArgumentException("Image does not exist. "); } try { mBmp = new Bitmap(mImgMemStrm); } catch (Exception lExc) { mImgMemStrm.Close(); mImgMemStrm = null; throw new ArgumentException("Image is wrong. " + lExc.Message, lExc); } mWidth = mBmp.Width; mHeight = mBmp.Height; }