//========================================================================= /// <summary> /// Assign a driver value. /// </summary> /// <param name="driverID"></param> /// <param name="providerID">Component that provided the value.</param> /// <param name="aValue">Returned value.</param> //========================================================================= public override void assignDriver(int driverID, uint providerID, TTypedValue aValue) { if (driverID == drvCOMPCLASS) //if this driver was a comp.type { if (compInfoList.Count == 1) { foreach (KeyValuePair <String, List <TComp> > pair in compInfoList) { List <TComp> comps = pair.Value; for (int i = 0; i < comps.Count; i++) { TComp comp = comps[i]; if (comp.compID == providerID) { comp.CompClass = aValue.asString(); //store the class type comps[i] = comp; } } } } else { throw new Exception("More requests using compInfoList<> than expected in assignDriver()"); } } else { if (!Comp.assignDriver(driverID, providerID, aValue)) { base.assignDriver(driverID, providerID, aValue); } } }
//===================================================================== /// <summary> /// /// </summary> /// <param name="typedValue"></param> public TAFTreeViewColumnTag(TTypedValue typedValue) { _typedValue = typedValue; //_sColumnData = ipsColumnData; _sVariable = _typedValue.Name; _sValue = _typedValue.asString(); _sType = _typedValue.typeName(); if (_sType.ToLower().Equals("defined") || (_typedValue.isRecord() == true)) { _sType = "record"; } if (_typedValue.isArray()) { _sType = "array"; } _sUnit = _typedValue.units(); if (typedValue is TInitValue) { TInitValue initValue = _typedValue as TInitValue; _sDescr = initValue.getDescr(); if (initValue.getDefault() != null) { _sDefault = initValue.getDefault().asString(); } else { _sDefault = ""; } if (initValue.getMin() != null) { _sMin = initValue.getMin().asString(); } else { _sMin = ""; } if (initValue.getMax() != null) { //_sMax = Math.Round( initValue.getMax().asDouble(),3).ToString(); _sMax = initValue.getMax().asString(); //initValue.getMax().typeName() //double dMaxValue = double.MaxValue; //switch (initValue.baseType()) //{ // case TTypedValue.TBaseType.ITYPE_INT1: // { // //FMax.setValue(+VERYLARGE_I1); // //FMin.setValue(-VERYLARGE_I1); // } break; // case TTypedValue.TBaseType.ITYPE_INT2: // { // //FMax.setValue(+VERYLARGE_I2); // //FMin.setValue(-VERYLARGE_I2); // } break; // case TTypedValue.TBaseType.ITYPE_INT4: // { // //FMax.setValue(+VERYLARGE_I4); // //FMin.setValue(-VERYLARGE_I4); // } break; // case TTypedValue.TBaseType.ITYPE_INT8: // { // //FMax.setValue(+VERYLARGE_I8); // //FMin.setValue(-VERYLARGE_I8); // } break; // case TTypedValue.TBaseType.ITYPE_SINGLE: // { // //FMax.setValue(+1.0 * VERYLARGE_S); // //FMin.setValue(-1.0 * VERYLARGE_S); // } break; // case TTypedValue.TBaseType.ITYPE_DOUBLE: // { // dMaxValue = TInitValue.VERYLARGE_D_POS; // //FMin.setValue(VERYLARGE_D_NEG); // } break; //} //if (initValue.getMax().asDouble() == dMaxValue) //{ // Console.WriteLine("equal"); // _sMax = ""; //} } else { _sMax = ""; } } }
//========================================================================== /// <summary> /// /// </summary> /// <param name="propertyID"></param> /// <param name="aValue"></param> //========================================================================== public override void initProperty(int propertyID, TTypedValue aValue) { String sText; uint Idx; TTypedValue varItem; if (!(FReporter is TStaticReporter) && (isWaterCastSim)) { FReporter = null; FReporter = new TStaticReporter(); } switch (propertyID) { case prpFILE: { FReporter.FileName = aValue.asString(); } break; case prpINTV: { FReporter.ReportInterval = aValue.asInteger(); } break; case prpUNIT: { sText = aValue.asString().ToLower().Trim(); for (int i = TTimeValue.SEC; i <= TTimeValue.YR; i++) { if (sText == TTimeValue.TIMETEXTS[i - 1]) { FReporter.IntervalUnit = i; } } } break; case prpOUTS: { for (Idx = 1; Idx <= aValue.count(); Idx++) { varItem = aValue.item(Idx); FReporter.addVariable(varItem.member("varname").asString(), varItem.member("alias").asString(), varItem.member("decplaces").asInteger(), FReporter.parseAggreg(varItem.member("aggreg").asString())); } } break; case prpSUMMARYFILE: { if (aValue.asString().Length == 0) { FSummaryStream = null; } else { FSummaryStream = new StreamWriter(aValue.asString()); addEvent("summaryFileWrite", evtSUMMARYWRITE, TypeSpec.KIND_SUBSCRIBEDEVENT, typeSUMMARYWRITE, "", "", 0); defineEventState(evtSUMMARYWRITE, stateDOWRITE, TStateMachine.NONLOGIC); defineEventTransition(evtSUMMARYWRITE, stateDOWRITE, 0, TStateMachine.DONE, false); } } break; case prpAPSIMFMT: { FReporter.ApsimFMT = aValue.asBool(); } break; case prpTITLE: { FReporter.Title = aValue.asStr(); } break; case prpOUTFREQ: { uint count = aValue.count(); for (uint i = 1; i <= count; i++) { //for each new event; add it to the list and also register it String eventName = aValue.item(i).asStr().ToLower(); if (!RegExtraEvents.ContainsValue(eventName)) { int eventId = evtEXTRAWRITE + RegExtraEvents.Count; addWritingEvent(eventId, eventName); RegExtraEvents.Add(eventId, eventName); } } } break; case prpDATEFMT: { FReporter.DateFMT = aValue.asStr(); } break; default: throw (new ApplicationException("Invalid ID code in initProperty()")); } if ((propertyID == prpFILE) || (propertyID == prpINTV) || //Store the initial value for later reading (propertyID == prpUNIT) || (propertyID == prpOUTS) || (propertyID == prpSUMMARYFILE)) { propertyList[propertyID].setValue(aValue); } }