예제 #1
0
        //==========================================================================
        /// <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);
            }
        }