public static void SetDatumValue(String value, DatumType datum) { if (datum != null && !String.IsNullOrEmpty(value)) { int iValue; long lValue; double dValue; uint uiValue; ulong ulValue; if (datum is binary) { ((binary)datum).value = value; } if (datum is boolean) { ((boolean)datum).value = value.Equals("1"); // 0 or 1 } if (datum is dateTime) { ((dateTime)datum).value = DateTime.Parse(value); //YYYY-MM-DD } if (datum is @double && double.TryParse(value, out dValue)) { ((@double)datum).value = dValue; } if (datum is hexadecimal) { ((hexadecimal)datum).value = value; //^[0-9A-Fa-f]+$ } if (datum is integer && int.TryParse(value, out iValue)) { ((integer)datum).value = iValue; } if (datum is @long && long.TryParse(value, out lValue)) { ((@long)datum).value = lValue; } if (datum is octal) { ((octal)datum).value = value; //^[1-7][0-7]*$ } if (datum is @string) { ((@string)datum).Value = value; } if (datum is unsignedInteger && uint.TryParse(value, out uiValue)) { ((unsignedInteger)datum).value = uiValue; } if (datum is unsignedLong && ulong.TryParse(value, out ulValue)) { ((unsignedLong)datum).value = ulValue; } } }
public void CopyTo(DatumType copy) { copy.standardUnit = standardUnit; copy.unitQualifier = unitQualifier; copy.nonStandardUnit = nonStandardUnit; copy.Confidence = Confidence; copy.ConfidenceSpecified = ConfidenceSpecified; copy.Resolution = Resolution; copy.ResolutionSpecified = ResolutionSpecified; copy.ErrorLimits = ErrorLimits; copy.Range = Range; }
public static DatumType GetDatumFromType(ComboBox combo) { DatumType datum = null; switch (combo.SelectedIndex) { case (int)DatumTypes.BINARY: datum = new binary(); break; case (int)DatumTypes.BOOL: datum = new boolean(); break; case (int)DatumTypes.DATETIME: datum = new dateTime(); break; case (int)DatumTypes.DOUBLE: datum = new @double(); break; case (int)DatumTypes.HEX: datum = new hexadecimal(); break; case (int)DatumTypes.INT: datum = new integer(); break; case (int)DatumTypes.LONG: datum = new @long(); break; case (int)DatumTypes.OCT: datum = new octal(); break; case (int)DatumTypes.STRING: datum = new @string(); break; case (int)DatumTypes.UINT: datum = new unsignedInteger(); break; case (int)DatumTypes.ULONG: datum = new unsignedLong(); break; } return(datum); }
public static Object GetDatumValue(DatumType datum) { Object value = null; if (datum is binary) { value = ((binary)datum).value; } if (datum is boolean) { value = ((boolean)datum).value; } if (datum is dateTime) { value = ((dateTime)datum).value; } if (datum is @double) { value = ((@double)datum).value; } if (datum is hexadecimal) { value = ((hexadecimal)datum).value; } if (datum is integer) { value = ((integer)datum).value; } if (datum is @long) { value = ((@long)datum).value; } if (datum is octal) { value = ((octal)datum).value; } if (datum is @string) { value = ((@string)datum).Value; } if (datum is unsignedInteger) { value = ((unsignedInteger)datum).value; } if (datum is unsignedLong) { value = ((unsignedLong)datum).value; } return(value); }
public static void SetDatumType(ComboBox combo, DatumType datum) { if (datum is binary) { combo.SelectedIndex = (int)DatumTypes.BINARY; } if (datum is boolean) { combo.SelectedIndex = (int)DatumTypes.BOOL; } if (datum is dateTime) { combo.SelectedIndex = (int)DatumTypes.DATETIME; } if (datum is @double) { combo.SelectedIndex = (int)DatumTypes.DOUBLE; } if (datum is hexadecimal) { combo.SelectedIndex = (int)DatumTypes.HEX; } if (datum is integer) { combo.SelectedIndex = (int)DatumTypes.INT; } if (datum is @long) { combo.SelectedIndex = (int)DatumTypes.LONG; } if (datum is octal) { combo.SelectedIndex = (int)DatumTypes.OCT; } if (datum is @string) { combo.SelectedIndex = (int)DatumTypes.STRING; } if (datum is unsignedInteger) { combo.SelectedIndex = (int)DatumTypes.UINT; } if (datum is unsignedLong) { combo.SelectedIndex = (int)DatumTypes.ULONG; } }
public static Object GetNominalDatumValue(DatumType datum) { Object value = null; if (datum is binary) { value = ((binary)datum).value; } else if (datum is boolean) { value = ((boolean)datum).value; } else if (datum is dateTime) { value = ((dateTime)datum).value; } else if (datum is @double || datum is integer || datum is @long || datum is unsignedInteger || datum is unsignedLong) { Physical physical = new Physical(datum.ToString()); value = physical.Magnitude.AnyQuantity.NominalValue; } else if (datum is hexadecimal) { value = ((hexadecimal)datum).value; } else if (datum is octal) { value = ((octal)datum).value; } else if (datum is @string) { value = ((@string)datum).Value; } return(value); }
public static bool LoadFromFile(string fileName, out DatumType obj) { System.Exception exception; return LoadFromFile(fileName, out obj, out exception); }
/// <summary> /// Deserializes xml markup from file into an DatumType object /// </summary> /// <param name="fileName">string xml file to load and deserialize</param> /// <param name="obj">Output DatumType object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns> public static bool LoadFromFile(string fileName, out DatumType obj, out System.Exception exception) { exception = null; obj = default(DatumType); try { obj = LoadFromFile(fileName); return true; } catch (System.Exception ex) { exception = ex; return false; } }
public static bool Deserialize(string input, out DatumType obj) { System.Exception exception; return Deserialize(input, out obj, out exception); }
/// <summary> /// Deserializes workflow markup into an DatumType object /// </summary> /// <param name="input">string workflow markup to deserialize</param> /// <param name="obj">Output DatumType object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string input, out DatumType obj, out System.Exception exception) { exception = null; obj = default(DatumType); try { obj = Deserialize(input); return true; } catch (System.Exception ex) { exception = ex; return false; } }
public static void SetDatumValue(String value, DatumType datum) { if (datum != null && !String.IsNullOrEmpty(value)) { int iValue; long lValue; double dValue; uint uiValue; ulong ulValue; if (datum is binary) ((binary) datum).value = value; if (datum is boolean) ((boolean) datum).value = value.Equals("1"); // 0 or 1 if (datum is dateTime) ((dateTime) datum).value = DateTime.Parse(value); //YYYY-MM-DD if (datum is @double && double.TryParse(value, out dValue)) ((@double) datum).value = dValue; if (datum is hexadecimal) ((hexadecimal) datum).value = value; //^[0-9A-Fa-f]+$ if (datum is integer && int.TryParse(value, out iValue)) ((integer) datum).value = iValue; if (datum is @long && long.TryParse(value, out lValue)) ((@long) datum).value = lValue; if (datum is octal) ((octal) datum).value = value; //^[1-7][0-7]*$ if (datum is @string) ((@string) datum).Value = value; if (datum is unsignedInteger && uint.TryParse(value, out uiValue)) ((unsignedInteger) datum).value = uiValue; if (datum is unsignedLong && ulong.TryParse(value, out ulValue)) ((unsignedLong) datum).value = ulValue; } }
public static Object GetNominalDatumValue(DatumType datum) { Object value = null; if (datum is binary) value = ((binary)datum).value; else if (datum is boolean) value = ((boolean)datum).value; else if (datum is dateTime) value = ((dateTime)datum).value; else if (datum is @double || datum is integer || datum is @long || datum is unsignedInteger || datum is unsignedLong ) { Physical physical = new Physical(datum.ToString()); value = physical.Magnitude.AnyQuantity.NominalValue; } else if (datum is hexadecimal) value = ((hexadecimal)datum).value; else if (datum is octal) value = ((octal)datum).value; else if (datum is @string) value = ((@string)datum).Value; return value; }
private void btnLimit1_Click(object sender, EventArgs e) { //Datum.SetDatumValue(edtDatumType.Value, datum); datum = edtDatumType.DatumType; ControlsToData(); //Load the limit item if (_limitControlType == ControlType.SimpleLimit) { _singleLimit.Item = datum; if (cmbLimitComparitor.SelectedValue != null ) _singleLimit.comparator = (ComparisonOperator)Enum.Parse( typeof (ComparisonOperator), (String) cmbLimitComparitor.SelectedValue); var form = new SingleLimitForm(_singleLimit); RegisterForm( form ); form.Closed += delegate(object sndr, EventArgs ee) { UnRegisterForm((Form)sndr); if (ee is FormClosedEventArgs) { var f = (Form)sndr; if (DialogResult.OK == f.DialogResult) { try { SingleLimit = form.SingleLimit; if (OnSelectLimit != null) OnSelectLimit(_singleLimit); if (LimitChanged != null) LimitChanged(_singleLimit); } catch (Exception err) { MessageBox.Show(@"Error: " + err.Message, @"E R R O R"); } } } }; form.Show(); } else if (_limitControlType == ControlType.ExpectedLimit) { _expectedLimit.Item = datum; _expectedLimit.comparator = (EqualityComparisonOperator) Enum.Parse(typeof(EqualityComparisonOperator), (String)cmbLimitComparitor.SelectedValue); var form = new ExpectedLimitForm(_expectedLimit); RegisterForm( form ); form.Closed += delegate(object sndr, EventArgs ee) { UnRegisterForm((Form)sndr); if (ee is FormClosedEventArgs) { var f = (Form)sndr; if (DialogResult.OK == f.DialogResult) { try { ExpectedLimit = form.LimitExpected; } catch (Exception err) { MessageBox.Show(@"Error: " + err.Message, @"E R R O R"); } } } }; form.Show(); } }
private void ControlsToData() { datum = datumTypeControl.Datum; }
private void ControlsToData() { if (_datum == null) _datum = ATMLModelLibrary.model.common.Datum.GetDatumFromType(cmbDatumType); _datum = edtDatum.DatumType; _datum.ResolutionSpecified = chkResolution.Checked; if (chkResolution.Checked) _datum.Resolution = Convert.ToDouble(edtResolution.Value); _datum.ConfidenceSpecified = chkConfidence.Checked; if (chkConfidence.Checked) _datum.Confidence = Convert.ToDouble(edtConfidence.Value); _datum.nonStandardUnit = edtNonStandardUnit.GetValue<string>(); _datum.standardUnit = standardUnitControl.StandardUnit; _datum.unitQualifier = qualifierComboBox.SelectedItem as String; _datum.ErrorLimits = errorLimitControl.Limit; _datum.Range = rangeLimitControl.Limit; }
public static Object GetDatumValue(DatumType datum) { Object value = null; if (datum is binary) value = ((binary) datum).value; if (datum is boolean) value = ((boolean) datum).value; if (datum is dateTime) value = ((dateTime) datum).value; if (datum is @double) value = ((@double) datum).value; if (datum is hexadecimal) value = ((hexadecimal) datum).value; if (datum is integer) value = ((integer) datum).value; if (datum is @long) value = ((@long) datum).value; if (datum is octal) value = ((octal) datum).value; if (datum is @string) value = ((@string) datum).Value; if (datum is unsignedInteger) value = ((unsignedInteger) datum).value; if (datum is unsignedLong) value = ((unsignedLong) datum).value; return value; }
private void cmbLimit1Type_SelectedIndexChanged(object sender, EventArgs e) { if (!Initializing) { datum = Datum.GetDatumFromType(cmbLimitType); edtDatumType.DatumType = datum; ControlsToData(); if (LimitChanged != null) LimitChanged(_singleLimit); } }
public static void SetDatumType(ComboBox combo, DatumType datum) { if (datum is binary) combo.SelectedIndex = (int) DatumTypes.BINARY; if (datum is boolean) combo.SelectedIndex = (int) DatumTypes.BOOL; if (datum is dateTime) combo.SelectedIndex = (int) DatumTypes.DATETIME; if (datum is @double) combo.SelectedIndex = (int) DatumTypes.DOUBLE; if (datum is hexadecimal) combo.SelectedIndex = (int) DatumTypes.HEX; if (datum is integer) combo.SelectedIndex = (int) DatumTypes.INT; if (datum is @long) combo.SelectedIndex = (int) DatumTypes.LONG; if (datum is octal) combo.SelectedIndex = (int) DatumTypes.OCT; if (datum is @string) combo.SelectedIndex = (int) DatumTypes.STRING; if (datum is unsignedInteger) combo.SelectedIndex = (int) DatumTypes.UINT; if (datum is unsignedLong) combo.SelectedIndex = (int) DatumTypes.ULONG; }
private void ControlsToData() { InitLimit(); if (datum == null) datum = Datum.GetDatumFromType(cmbLimitType); //Datum.SetDatumValue(edtLimitValue.GetValue<string>(), datum); datum = edtDatumType.DatumType; if (datum != null) datum.standardUnit = standardUnitControl.StandardUnit; if (_limitControlType == ControlType.SimpleLimit) { _singleLimit.Item = datum; if (cmbLimitComparitor.SelectedValue != null) _singleLimit.comparator = (ComparisonOperator) Enum.Parse(typeof (ComparisonOperator), (String) cmbLimitComparitor.SelectedValue); } else if (_limitControlType == ControlType.ExpectedLimit) { _expectedLimit.Item = datum; if (cmbLimitComparitor.SelectedValue != null) _expectedLimit.comparator = (EqualityComparisonOperator) Enum.Parse(typeof (EqualityComparisonOperator), (String) cmbLimitComparitor.SelectedValue); } }
public void CopyTo( DatumType copy ) { copy.standardUnit = standardUnit; copy.unitQualifier = unitQualifier; copy.nonStandardUnit = nonStandardUnit; copy.Confidence = Confidence; copy.ConfidenceSpecified = ConfidenceSpecified; copy.Resolution = Resolution; copy.ResolutionSpecified = ResolutionSpecified; copy.ErrorLimits = ErrorLimits; copy.Range = Range; }
private void DataToControls() { if (_singleLimit != null || _expectedLimit != null) { Initializing = true; object item = null; if (_singleLimit != null && _limitControlType == ControlType.SimpleLimit) { cmbLimitComparitor.SelectedIndex = cmbLimitComparitor.FindStringExact(Enum.GetName(typeof (ComparisonOperator), _singleLimit.comparator)); item = _singleLimit.Item; } else if (_expectedLimit != null && _limitControlType == ControlType.ExpectedLimit ) { cmbLimitComparitor.SelectedIndex = cmbLimitComparitor.FindStringExact(Enum.GetName(typeof (EqualityComparisonOperator), _expectedLimit.comparator)); item = _expectedLimit.Item; } ShowTextPanel = false; if (item is DatumType) { datum = item as DatumType; standardUnitControl.StandardUnit = datum.standardUnit; //edtLimitValue.Value = Datum.GetDatumValue(datum); edtDatumType.DatumType = datum; Datum.SetDatumType(cmbLimitType, datum); } else { ShowTextPanel = true; if (item != null) lblText.Text = item.ToString(); } Initializing = false; } }