Exemplo n.º 1
0
        /**********************************************************/

        /// <summary>
        /// add an interval to the report, return the UID of the interval
        /// after adding an interval, ReportPayloads can be added to the interval through
        /// the returned uid
        /// </summary>
        /// <param name="reportSpecifierID"></param>
        /// <param name="startUTC"></param>
        /// <param name="durationMinutes"></param>
        /// <returns></returns>
        public int addInterval(string reportSpecifierID, DateTime startUTC, int duration, DurationModifier durationModifier)
        {
            IntervalType intervalType = new IntervalType();


            intervalType.dtstart          = new dtstart();
            intervalType.dtstart.datetime = startUTC;

            intervalType.duration          = new DurationPropType();
            intervalType.duration.duration = "PT" + duration.ToString() + durationModifier.Value;

            List <IntervalType> reportIntervals = (_reportIntervals.ContainsKey(reportSpecifierID) ? _reportIntervals[reportSpecifierID] : null);

            if (reportIntervals == null)
            {
                reportIntervals = new List <IntervalType>();

                _reportIntervals.Add(reportSpecifierID, reportIntervals);
            }

            int uid = reportIntervals.Count;

            IntervalTypeUidUid intervalTypeUID = new IntervalTypeUidUid();

            intervalTypeUID.text = uid.ToString();

            intervalType.Item = intervalTypeUID;

            reportIntervals.Add(intervalType);

            return(uid);
        }
Exemplo n.º 2
0
        public void serializeInterval()
        {
            IntervalType intervalType = new IntervalType();

            IntervalTypeUidUid intervalTypeUID = new IntervalTypeUidUid();

            intervalTypeUID.text = "0";

            intervalType.Item = intervalTypeUID;

            string output = SerializeOadrObject.serializeOjbect(intervalType, typeof(IntervalType));

            Assert.IsTrue(output.Contains("<text>0</text>"));
            Assert.IsTrue(output.Contains("uid"));
        }
Exemplo n.º 3
0
        public void createRegisterReport()
        {
            oadrPayload payload = new oadrPayload();

            oadrSignedObject signedObject = new oadrSignedObject();

            payload.oadrSignedObject = signedObject;

            oadrRegisterReportType registerReport = new oadrRegisterReportType();

            signedObject.Item = registerReport;

            registerReport.reportRequestID = "ReportRequestID_123";
            registerReport.requestID       = "RequestID_123";
            registerReport.schemaVersion   = "2.0b";
            registerReport.venID           = "TH_VEN";

            registerReport.oadrReport = new oadrReportType[1];

            registerReport.oadrReport[0] = new oadrReportType();

            registerReport.oadrReport[0].reportName = "ReportName_123";

            registerReport.oadrReport[0].intervals    = new IntervalType[1];
            registerReport.oadrReport[0].intervals[0] = new IntervalType();

            // refID ???
            IntervalTypeUidUid uid = new IntervalTypeUidUid();

            uid.text = "UID";
            registerReport.oadrReport[0].intervals[0].Item = uid;

            oadrReportPayloadType reportPayload = new oadrReportPayloadType();

            reportPayload.rID               = "rID";
            reportPayload.accuracy          = 1.0F;
            reportPayload.accuracySpecified = true;

            registerReport.oadrReport[0].intervals[0].streamPayloadBase = new StreamPayloadBaseType[1];

            registerReport.oadrReport[0].intervals[0].streamPayloadBase[0] = reportPayload;

            Assert.IsTrue(registerReport.oadrReport[0].intervals[0].streamPayloadBase[0].GetType() == typeof(oadrReportPayloadType));

            XmlSerializer serializer = new XmlSerializer(typeof(oadrPayload));

            serializer.Serialize(Console.Out, payload);
        }
Exemplo n.º 4
0
        public void generateOadrDistributeEvent()
        {
            oadrPayload payload = new oadrPayload();

            payload.oadrSignedObject = new oadrSignedObject();

            oadrDistributeEventType distributeEvent = new oadrDistributeEventType();

            distributeEvent.schemaVersion = "2.0b";

            distributeEvent.eiResponse                     = new EiResponseType();
            distributeEvent.eiResponse.requestID           = "";
            distributeEvent.eiResponse.responseCode        = "200";
            distributeEvent.eiResponse.responseDescription = "OK";

            distributeEvent.requestID = "OadrDisReq050214_092500_050";
            distributeEvent.vtnID     = "TH_VTN";

            payload.oadrSignedObject.Item = distributeEvent;

            distributeEvent.oadrEvent = new oadrDistributeEventTypeOadrEvent[1];

            oadrDistributeEventTypeOadrEvent oadrEvent = new oadrDistributeEventTypeOadrEvent();

            distributeEvent.oadrEvent[0] = oadrEvent;

            eiEventType eiEvent = new eiEventType();

            oadrEvent.eiEvent = eiEvent;

            eiEvent.eventDescriptor = new eventDescriptorType();

            eiEvent.eventDescriptor.eventID                       = "Event050214_092500_550_0";
            eiEvent.eventDescriptor.modificationNumber            = 0;
            eiEvent.eventDescriptor.modificationDateTime          = DateTime.ParseExact("2014-02-05T17:25:00Z", "yyyy-MM-ddTHH:mm:00Z", CultureInfo.InvariantCulture);
            eiEvent.eventDescriptor.modificationReason            = "Update";
            eiEvent.eventDescriptor.priority                      = 1;
            eiEvent.eventDescriptor.eiMarketContext               = new eventDescriptorTypeEiMarketContext();
            eiEvent.eventDescriptor.eiMarketContext.marketContext = "http://MarketContext1";
            eiEvent.eventDescriptor.createdDateTime               = DateTime.ParseExact("2014-02-05T17:25:00Z", "yyyy-MM-ddTHH:mm:00Z", CultureInfo.InvariantCulture);
            eiEvent.eventDescriptor.eventStatus                   = EventStatusEnumeratedType.completed;
            eiEvent.eventDescriptor.testEvent                     = "false";
            eiEvent.eventDescriptor.vtnComment                    = "Sample Payload";
            eiEvent.eventDescriptor.vtnComment                    = "comment";

            // active period
            eiEvent.eiActivePeriod                                     = new eiActivePeriodType();
            eiEvent.eiActivePeriod.properties                          = new properties();
            eiEvent.eiActivePeriod.properties.dtstart                  = new dtstart();
            eiEvent.eiActivePeriod.properties.dtstart.datetime         = DateTime.ParseExact("2014-02-05T17:35:00Z", "yyyy-MM-ddTHH:mm:00Z", CultureInfo.InvariantCulture);
            eiEvent.eiActivePeriod.properties.duration                 = new DurationPropType();
            eiEvent.eiActivePeriod.properties.duration.duration        = "PT5M";
            eiEvent.eiActivePeriod.properties.xeiNotification          = new DurationPropType();
            eiEvent.eiActivePeriod.properties.xeiNotification.duration = "PT1M";

            // signals
            eiEvent.eiEventSignals = new eiEventSignalsType();
            eiEvent.eiEventSignals.eiEventSignal = new eiEventSignalType[1];

            eiEventSignalType signal = new eiEventSignalType();

            signal.intervals                      = new IntervalType[1];
            signal.intervals[0]                   = new IntervalType();
            signal.intervals[0].duration          = new DurationPropType();
            signal.intervals[0].duration.duration = "PT5M";
            IntervalTypeUidUid uid = new IntervalTypeUidUid();

            uid.text = "0";
            signal.intervals[0].Item = uid;

            // signal payload
            signal.intervals[0].streamPayloadBase = new StreamPayloadBaseType[1];

            signalPayloadType val = new signalPayloadType();
            PayloadFloatType  pft = new PayloadFloatType();

            pft.value = (float)3.14;
            val.Item  = pft;
            signal.intervals[0].streamPayloadBase[0] = val;

            eiEvent.eiEventSignals.eiEventSignal[0] = signal;

            // signal type
            signal.signalName = SignalNameEnumeratedType.ELECTRICITY_PRICE.ToString();
            signal.signalType = SignalTypeEnumeratedType.price;
            signal.signalID   = "SIG_02";

            currencyType currency = new currencyType();

            currency.itemDescription = currencyItemDescriptionType.currencyPerKWh;
            currency.itemUnits       = ISO3AlphaCurrencyCodeContentType.USD;
            currency.siScaleCode     = SiScaleCodeType.none;

            signal.itemBase = currency;

            signal.currentValue = new currentValueType();
            PayloadFloatType pft2 = new PayloadFloatType();

            pft2.value = (float)0.0;
            signal.currentValue.Item = pft2;

            signal.eiTarget               = new EiTargetType();
            signal.eiTarget.resourceID    = new string[2];
            signal.eiTarget.resourceID[0] = "resource1";
            signal.eiTarget.resourceID[1] = "resource2";

            oadrEvent.oadrResponseRequired = ResponseRequiredType.always;

            string xml = SerializeOadrObject.serializeOjbect(payload, payload.GetType());

            Console.Out.WriteLine(xml);

            /*serializer = new XmlSerializer(typeof(eiEventSignalType));
             *
             * MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
             *
             * signal = (eiEventSignalType)serializer.Deserialize(ms);
             *
             * Assert.IsNotNull(signal);
             *
             * ms.Close();*/
        }