コード例 #1
0
ファイル: ReportWrapper.cs プロジェクト: 2thetop/OpenADR-VEN
        /**********************************************************/

        public void addDescriptionStatus(string rID, string resourceID, string marketContext, int minSamplingPeriod, int maxSamplingPeriod,
                                         bool onChange, DurationModifier durationModifier)

        {
            addDescription(rID, resourceID, ReportEnumeratedType.xresourceStatus, ReadingTypeEnumeratedType.DirectRead, marketContext,
                           minSamplingPeriod, maxSamplingPeriod, onChange, durationModifier, null);
        }
コード例 #2
0
ファイル: ReportWrapper.cs プロジェクト: 2thetop/OpenADR-VEN
        /**********************************************************/

        public void addDescription(string rID, string resourceID, ReportEnumeratedType reportType, ReadingTypeEnumeratedType readingType,
                                   string marketContext, int minSamplingPeriod, int maxSamplingPeriod, bool onChange, DurationModifier durationModifier, ItemBaseType measuredValue = null)
        {
            oadrReportDescriptionType reportDescription = new oadrReportDescriptionType();

            reportDescription.rID = rID;
            reportDescription.reportDataSource               = new EiTargetType();
            reportDescription.reportDataSource.resourceID    = new string[1];
            reportDescription.reportDataSource.resourceID[0] = resourceID;

            reportDescription.reportType    = reportType;
            reportDescription.readingType   = readingType;
            reportDescription.marketContext = marketContext;

            reportDescription.oadrSamplingRate = new oadrSamplingRateType();
            reportDescription.oadrSamplingRate.oadrMaxPeriod = "PT" + maxSamplingPeriod.ToString() + durationModifier.Value;
            reportDescription.oadrSamplingRate.oadrMinPeriod = "PT" + minSamplingPeriod.ToString() + durationModifier.Value;

            reportDescription.oadrSamplingRate.oadrOnChange = onChange;

            reportDescription.itemBase = measuredValue;

            m_reportDescriptions.Add(rID, reportDescription);
        }
コード例 #3
0
ファイル: ReportWrapper.cs プロジェクト: 2thetop/OpenADR-VEN
        private Dictionary <string, List <StreamPayloadBaseType> > m_reportIntervalPayloads = new Dictionary <string, List <StreamPayloadBaseType> >(); // payloads for an interval for a date

        public ReportWrapper(string reportSpecifierID, ReportName reportName, int duration, DurationModifier durationModifier)
        {
            ReportSpecifierID = reportSpecifierID;
            m_reportName      = reportName;

            m_reportDuration          = new DurationPropType();
            m_reportDuration.duration = "PT" + duration.ToString() + durationModifier.Value;
        }
コード例 #4
0
ファイル: ReportWrapper.cs プロジェクト: 2thetop/OpenADR-VEN
        /**********************************************************/

        public void addIntervalResourceStatus(DateTime startUTC, string rID, uint confidence, float accuracy, DataQuality dataQuality, bool online, bool manualOverride,
                                              float capacityMin, float capacityMax, float capacityCurrent, float capacityNormal,
                                              float levelOffsetMin, float levelOffsetMax, float levelOffsetCurrent, float levelOffsetNormal,
                                              float percentOffsetMin, float percentOffsetMax, float percentOffsetCurrent, float percentOffsetNormal,
                                              float setPointMin, float setPointMax, float setPointCurrent, float setPointNormal, int duration = -1, DurationModifier durationModifier = null)
        {
            oadrReportPayloadType reportPayload = new oadrReportPayloadType();

            reportPayload.rID        = rID;
            reportPayload.confidence = confidence;
            reportPayload.accuracy   = accuracy;

            reportPayload.oadrDataQuality = dataQuality.QualityType;

            oadrPayloadResourceStatusType resourceStatus = new oadrPayloadResourceStatusType();

            resourceStatus.oadrOnline         = online;
            resourceStatus.oadrManualOverride = manualOverride;

            resourceStatus.oadrLoadControlState = new oadrLoadControlStateType();
            resourceStatus.oadrLoadControlState.oadrCapacity      = helper.OadrObjectFactory.createLoadControlStateType(capacityMin, capacityMax, capacityCurrent, capacityNormal);
            resourceStatus.oadrLoadControlState.oadrLevelOffset   = helper.OadrObjectFactory.createLoadControlStateType(levelOffsetMin, levelOffsetMax, levelOffsetCurrent, levelOffsetNormal);
            resourceStatus.oadrLoadControlState.oadrPercentOffset = helper.OadrObjectFactory.createLoadControlStateType(percentOffsetMin, percentOffsetMax, percentOffsetCurrent, percentOffsetNormal);
            resourceStatus.oadrLoadControlState.oadrSetPoint      = helper.OadrObjectFactory.createLoadControlStateType(setPointMin, setPointMax, setPointCurrent, setPointNormal);

            reportPayload.Item = resourceStatus;

            addIntervalPayload(startUTC, rID, reportPayload, duration, durationModifier);
        }
コード例 #5
0
ファイル: ReportWrapper.cs プロジェクト: 2thetop/OpenADR-VEN
        /**********************************************************/

        public void addIntervalReportPayload(DateTime startUTC, string rID, uint confidence, float accuracy, float payload, DataQuality dataQuality, int duration = -1, DurationModifier durationModifier = null)
        {
            oadrReportPayloadType reportPayload = new oadrReportPayloadType();

            reportPayload.rID        = rID;
            reportPayload.confidence = confidence;
            reportPayload.accuracy   = accuracy;

            reportPayload.oadrDataQuality = dataQuality.QualityType;

            PayloadFloatType payloadFloat = new PayloadFloatType();

            payloadFloat.value = payload;

            reportPayload.Item = payloadFloat;

            addIntervalPayload(startUTC, rID, reportPayload, duration, durationModifier);
        }
コード例 #6
0
ファイル: ReportWrapper.cs プロジェクト: 2thetop/OpenADR-VEN
        /**********************************************************/

        /// <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 void addInterval(string rid, 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;
         *
         *  IntervalTypeWrapper wrapper = new IntervalTypeWrapper();
         *  // wrapper.interval = intervalType;
         *  wrapper.rid = rid;
         *
         *  m_reportIntervals.Add(wrapper);
         * }*/

        /**********************************************************/

        private void addIntervalPayload(DateTime startUTC, string rid, oadrReportPayloadType reportPayload, int duration = -1, DurationModifier durationModifier = null)
        {
            List <StreamPayloadBaseType> intervalPayloads;

            string key = startUTC.ToString();

            IntervalType interval;

            if (!m_reportIntervals.ContainsKey(key))
            {
                interval = helper.OadrObjectFactory.createIntervalType(startUTC, duration, durationModifier);

                m_reportIntervals.Add(key, interval);

                m_reportIntervalPayloads.Add(key, new List <StreamPayloadBaseType>());
            }

            // if an interval contains an 'interval' and 'point data', duration must be present
            // conformance rule 342 provides rules for when dtstart and duration must be present, but fails
            // to specify what should be done when both 'interval' and 'point data' are present
            // the OADR alliance said dtstart and duration should be present if both types of data are present
            interval = m_reportIntervals[key];

            if (interval.duration == null && duration != -1)
            {
                m_reportIntervals[key] = helper.OadrObjectFactory.createIntervalType(startUTC, duration, durationModifier);
            }
            ;

            intervalPayloads = m_reportIntervalPayloads[key];
            intervalPayloads.Add(reportPayload);
        }
コード例 #7
0
ファイル: ReportWrapper.cs プロジェクト: 2thetop/OpenADR-VEN
        /**********************************************************/

        public void addDescriptionPowerItem(string rID, string resourceID, ReportEnumeratedType reportType, ReadingTypeEnumeratedType readingType,
                                            string marketContext, int minSamplingPeriod, int maxSamplingPeriod, bool onChange, DurationModifier durationModifier,
                                            ePowerItemType powerItemType, string description, string units, SiScaleCodeType siScaleCode, decimal hertz, decimal voltage, bool ac)
        {
            PowerItemType powerItem = null;

            switch (powerItemType)
            {
            case ePowerItemType.PowerApparent:
                powerItem = new PowerApparentType();
                break;

            case ePowerItemType.PowerReactive:
                powerItem = new PowerReactiveType();
                break;

            case ePowerItemType.PowerReal:
                powerItem = new PowerRealType();
                break;

            default:
                powerItem = new PowerApparentType();
                break;
            }

            powerItem.itemDescription = description;
            powerItem.itemUnits       = units;
            powerItem.siScaleCode     = siScaleCode;

            powerItem.powerAttributes         = new PowerAttributesType();
            powerItem.powerAttributes.hertz   = hertz;
            powerItem.powerAttributes.voltage = voltage;

            addDescription(rID, resourceID, reportType, readingType, marketContext, minSamplingPeriod, maxSamplingPeriod, onChange, durationModifier, powerItem);
        }
コード例 #8
0
ファイル: ReportWrapper.cs プロジェクト: 2thetop/OpenADR-VEN
        /**********************************************************/

        public void addDescriptionEnergyItem(string rID, string resourceID, ReportEnumeratedType reportType, ReadingTypeEnumeratedType readingType,
                                             string marketContext, int minSamplingPeriod, int maxSamplingPeriod, bool onChange, DurationModifier durationModifier,
                                             eEnergyItemType energyItemType, string description, string units, SiScaleCodeType siScaleCode)
        {
            EnergyItemType energyItem = null;

            switch (energyItemType)
            {
            case eEnergyItemType.EnergyApparent:
                energyItem = new EnergyApparentType();
                break;

            case eEnergyItemType.EnergyReactive:
                energyItem = new EnergyReactiveType();
                break;

            case eEnergyItemType.EnergyReal:
                energyItem = new EnergyRealType();
                break;

            default:
                energyItem = new EnergyApparentType();
                break;
            }

            energyItem.itemDescription = description;
            energyItem.itemUnits       = units;
            energyItem.siScaleCode     = siScaleCode;

            addDescription(rID, resourceID, reportType, readingType, marketContext, minSamplingPeriod, maxSamplingPeriod, onChange, durationModifier, energyItem);
        }
コード例 #9
0
        /**********************************************************/

        public void addDescription(string reportSpecifierID, string rID, string resourceID, ReportEnumeratedType reportType, ReadingTypeEnumeratedType readingType,
                                   string marketContext, int minSamplingPeriod, int maxSamplingPeriod, bool onChange, DurationModifier durationModifier, ItemBaseType measuredValue = null)
        {
            oadrReportDescriptionType reportDescription = new oadrReportDescriptionType();

            reportDescription.rID = rID;
            reportDescription.reportDataSource               = new EiTargetType();
            reportDescription.reportDataSource.resourceID    = new string[1];
            reportDescription.reportDataSource.resourceID[0] = resourceID;

            reportDescription.reportType    = reportType;
            reportDescription.readingType   = readingType;
            reportDescription.marketContext = marketContext;

            reportDescription.oadrSamplingRate = new oadrSamplingRateType();
            reportDescription.oadrSamplingRate.oadrMaxPeriod = "PT" + maxSamplingPeriod.ToString() + durationModifier.Value;
            reportDescription.oadrSamplingRate.oadrMinPeriod = "PT" + minSamplingPeriod.ToString() + durationModifier.Value;

            reportDescription.oadrSamplingRate.oadrOnChange = onChange;

            Dictionary <string, oadrReportDescriptionType> reportDescriptions = (_reportDescriptions.ContainsKey(reportSpecifierID) ? _reportDescriptions[reportSpecifierID] : null);

            if (reportDescriptions == null)
            {
                reportDescriptions = new Dictionary <string, oadrReportDescriptionType>();
                _reportDescriptions[reportSpecifierID] = reportDescriptions;
            }

            reportDescription.itemBase = measuredValue;

            reportDescriptions[rID] = reportDescription;
        }
コード例 #10
0
        public void addReport(string reportSpecifierID, ReportName reportName, int duration, DurationModifier durationModifier)
        {
            oadrReportType report = new oadrReportType();

            report.reportRequestID = "0";

            report.reportSpecifierID = reportSpecifierID;
            report.reportName        = reportName.Name;

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

            _reports.Add(report.reportSpecifierID, report);

            _reportNames.Add(report.reportSpecifierID, reportName);
        }
コード例 #11
0
        /**********************************************************/

        public int addIntervalResourceStatus(string reportSpecifierID, DateTime startUTC, int duration, DurationModifier durationModifier,
                                             string rID, uint confidence, float accuracy, DataQuality dataQuality, bool online, bool manualOverride,
                                             float capacityMin, float capacityMax, float capacityCurrent, float capacityNormal,
                                             float levelOffsetMin, float levelOffsetMax, float levelOffsetCurrent, float levelOffsetNormal,
                                             float percentOffsetMin, float percentOffsetMax, float percentOffsetCurrent, float percentOffsetNormal,
                                             float setPointMin, float setPointMax, float setPointCurrent, float setPointNormal)
        {
            int uid = addInterval(reportSpecifierID, startUTC, duration, durationModifier);

            addIntervalResourceStatus(reportSpecifierID, uid, rID, confidence, accuracy, dataQuality, online, manualOverride, capacityMin, capacityMax, capacityCurrent,
                                      capacityNormal, levelOffsetMin, levelOffsetMax, levelOffsetCurrent, levelOffsetNormal, percentOffsetMin, percentOffsetMax, percentOffsetCurrent,
                                      percentOffsetNormal, setPointMin, setPointMax, setPointCurrent, setPointNormal);

            return(uid);
        }
コード例 #12
0
        /**********************************************************/

        /// <summary>
        /// adds an interval and a ReportPayload to the interval
        /// calling this function is the same as calling addInterval followed by addIntervalReportPayload
        /// </summary>
        /// <param name="reportSpecifierID"></param>
        /// <param name="startUTC"></param>
        /// <param name="durationMinutes"></param>
        /// <param name="rID"></param>
        /// <param name="confidence"></param>
        /// <param name="accuracy"></param>
        /// <param name="payload"></param>
        /// <param name="dataQuality"></param>
        /// <returns></returns>
        public int addIntervalReportPayload(string reportSpecifierID, DateTime startUTC, int duration, DurationModifier durationModifier,
                                            string rID, uint confidence, float accuracy, float payload, DataQuality dataQuality)
        {
            int uid = addInterval(reportSpecifierID, startUTC, duration, durationModifier);

            addIntervalReportPayload(reportSpecifierID, uid, rID, confidence, accuracy, payload, dataQuality);

            return(uid);
        }
コード例 #13
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);
        }