public bool compare(SimCapiData simCapiData) { bool equal = false; // Edge case for Number, // The string compare dosent work for numbers as the strings can be different but the number is the same // "8" != "8.0" but they are the same float value // so we have to convert the string to a float then do the compare if (GetType() == typeof(NumberData)) { NumberData numberA = (NumberData)this; float? numberB = simCapiData.getNumber(); if (numberB == null) { return(false); } equal = numberA.value == numberB.Value; //SimCapiConsole.log("NUMB |" + numberA.value.ToString() + "|" + numberB.Value.ToString() + "| equal: " + equal.ToString()); return(equal); } string a = ToString(); string b = simCapiData.ToString(); equal = a == b; //SimCapiConsole.log("|" + a + "|" + b + "| equal: " + equal.ToString()); return(equal); }
public void exposedValueChanged(SimCapiExposableValue exposableValue, SimCapiData simCapiData) { if (_valueMap.ContainsKey(exposableValue.exposedName) == false) { return; } _transporter.setValue(exposableValue.exposedName, simCapiData); }
public SimCapiValue(string key, SimCapiValueType type, bool isReadonly, bool isWriteonly, bool exposed, SimCapiData simCapiData, string[] allowedValues = null) { _key = key; _type = type; _isReadonly = isReadonly; _isWriteonly = isWriteonly; _exposed = exposed; _value = simCapiData; _allowedValues = allowedValues; }
public void setValue(string key, SimCapiData simCapiData) { if (_outGoingMap.ContainsKey(key) == false) { return; } _outGoingMap[key].setValueWithData(simCapiData); notifyValueChange(); }
public void setValueWithData(SimCapiData data) { switch (_type) { case SimCapiValueType.NUMBER: { NumberData numberData = (NumberData)_value; float?value = data.getNumber(); if (value == null) { SimCapiConsole.log("Cannot set " + _type.ToString() + " with " + data.GetType().ToString()); } else { numberData.value = value.Value; } break; } case SimCapiValueType.ARRAY: { ArrayData arrayData = (ArrayData)_value; string[] value = data.getStringArray(); if (value == null) { SimCapiConsole.log("Cannot set " + _type.ToString() + " with " + data.GetType().ToString()); } else { arrayData.value = value; } break; } case SimCapiValueType.BOOLEAN: { BoolData boolData = (BoolData)_value; bool?value = data.getBool(); if (value == null) { SimCapiConsole.log("Cannot set " + _type.ToString() + " with " + data.GetType().ToString()); } else { boolData.value = value.Value; } break; } case SimCapiValueType.STRING: case SimCapiValueType.ENUM: case SimCapiValueType.MATH_EXPR: case SimCapiValueType.ARRAY_POINT: { StringData stringData = (StringData)_value; stringData.value = data.ToString(); break; } } }