Exemple #1
0
        /// <summary>
        /// convenience function, reads cimdata file, calls getGroupStatus, returns result
        /// </summary>
        /// <param name="path">file name</param>
        /// <param name="mrid">der group unique identifier</param>
        /// <param name="q">apparent or real</param>
        /// <returns></returns>
        public static CIMData.DERStatus getDERGroupStatus(String path, String mrid, quantity q, ref String SOAPMessage, ref String SoapResponse)
        {
            CIM c = new CIM();

            c._data = DERMSInterface.CIMData.read(path);
            CIMData.DERStatus status = c.getDERGroupStatus(mrid, q);
            SOAPMessage  = c.LastMessageSent;
            SoapResponse = c.LastMessageReceived;
            return(status);
        }
Exemple #2
0
        public static int getDERGroupStatus(
            [MarshalAs(UnmanagedType.LPTStr)] String path,
            [MarshalAs(UnmanagedType.LPTStr)] String mrid,
            [MarshalAs(UnmanagedType.LPTStr)] String q,
            [MarshalAs(UnmanagedType.LPTStr)] ref String xml)
        {
            DERResult     result   = new DERResult();
            List <String> nameList = new List <string>();

            try
            {
                quantity qtype = (quantity)Enum.Parse(typeof(DERMSInterface.quantity), q);

                Console.WriteLine("DER file : " + path);
                Console.WriteLine("DERGroupName : " + mrid);
                String            SOAPMessage  = null;
                String            SOAPResponse = null;
                CIMData.DERStatus status       = CIM.getDERGroupStatus(path, mrid, qtype, ref SOAPMessage, ref SOAPResponse);
                int rvalue = CIM.CreateDERGroup(path, mrid, nameList.ToArray <String>(), ref SOAPMessage, ref SOAPResponse);
                result.Status       = status;
                result.SOAPMessage  = SOAPMessage;
                result.SOAPResponse = SOAPResponse;
                result.Returncode   = 0;
            }
            catch (Exception e)
            {
                result.Returncode   = 1;
                result.ErrorMessage = e.ToString();
                Console.WriteLine("DERConfigureException: {0}", e);
            }

            XmlSerializer ser    = new XmlSerializer(typeof(DERResult));
            StringWriter  writer = new StringWriter();

            ser.Serialize(writer, result);
            xml = writer.ToString();

            return(result.Returncode);
        }
Exemple #3
0
        /// <summary>
        /// send Get DER Group status SOAP message, get the status of the der
        /// </summary>
        /// <param name="mrid">unique identifier of DER group to be retrieved</param>
        /// <param name="q">real power or reactive power</param>
        /// <returns></returns>
        public CIMData.DERStatus getDERGroupStatus(String mrid, quantity q)
        {
            // initialize the soap call
            CIMGetDERGroupStatuses.GetDERGroupStatuses_Port client;
            CIMData.header header = _data.GetDERStatusHeader;

            if (!hasData(header.EndPoint))
            {
                throw new DERConfigureException("End Point required");
            }

            client = new CIMGetDERGroupStatuses.GetDERGroupStatuses_PortClient("GetDERGroupStatuses_Port", header.EndPoint);


            // initialize the vars used for the SOAP call
            CIMGetDERGroupStatuses.GetDERGroupStatusesRequest  req     = new CIMGetDERGroupStatuses.GetDERGroupStatusesRequest();
            CIMGetDERGroupStatuses.DERGroupStatusesPayloadType payload = new CIMGetDERGroupStatuses.DERGroupStatusesPayloadType();
            CIMGetDERGroupStatuses.HeaderType to = new CIMGetDERGroupStatuses.HeaderType();


            // build header
            CIMGetDERGroupStatuses.HeaderTypeVerb v = new CIMGetDERGroupStatuses.HeaderTypeVerb();
            if (Enum.TryParse(header.Verb, out v))
            {
                to.Verb = v;
            }
            else
            {
                to.Verb = CIMGetDERGroupStatuses.HeaderTypeVerb.get;
            }
            to.Noun         = header.Noun;
            to.ReplyAddress = header.ReplyAddress;
            to.Revision     = header.Revision;
            to.Source       = header.Source;
            to.AckRequired  = header.AckRequired;
            if (to.AckRequired == true)
            {
                to.AckRequiredSpecified = true;
            }
            to.Comment = header.Comment;
            to.Context = header.Context;

            if (hasData(header.UserOrganization) || hasData(header.UserID))
            {
                to.User              = new CIMGetDERGroupStatuses.UserType();
                to.User.UserID       = (hasData(header.UserID)) ? header.UserID : "epri"; // required
                to.User.Organization = header.UserOrganization;                           // optional
            }

            // load up the payload
            req.GetDERGroupStatusesRequestMessage.Header  = to;
            req.GetDERGroupStatusesRequestMessage.Request = new CIMGetDERGroupStatuses.GetDERGroupStatusesRequestType();
            req.GetDERGroupStatusesRequestMessage.Request.GetDERGroupStatuses         = new CIMGetDERGroupStatuses.DERGroupStatus[1];
            req.GetDERGroupStatusesRequestMessage.Request.GetDERGroupStatuses[0]      = new CIMGetDERGroupStatuses.DERGroupStatus();
            req.GetDERGroupStatusesRequestMessage.Request.GetDERGroupStatuses[0].mRID = mrid;

            // log outgoing, call soap, log return message
            _lastMessageSent = logMessage <CIMGetDERGroupStatuses.GetDERGroupStatusesRequest>(req);
            CIMGetDERGroupStatuses.GetDERGroupStatusesResponse reply = client.GetDERGroupStatuses(req);
            _lastMessageReceived = logMessage <CIMGetDERGroupStatuses.GetDERGroupStatusesResponse>(reply);


            CIMGetDERGroupStatuses.DERGroupStatus1[] statuses = reply.GetDERGroupStatusesResponseMessage.Payload.DERGroupStatuses;


            if (statuses.Length > 1)
            {
                throw new DERResponseException("GETDERGroupStatus returned multiple DER Groups.");
            }
            else if (statuses.Length < 1)
            {
                throw new DERResponseException("GETDERGroupStatus returned NO DER Groups.");
            }
            else
            {
                // we're loading up our own object, DERStatus
                CIMData.DERStatus status = new CIMData.DERStatus();
                status.Mrid = statuses[0].mRID;

                CIMGetDERGroupStatuses.EndDeviceGroup1 edg = statuses[0].EndDeviceGroup;
                if (edg.otherCapabilities == null)
                {
                    return(status);
                }

                // todo : missing values in here, problem with wsdl vs object
                CIMGetDERGroupStatuses.otherCapability cap = edg.otherCapabilities;
                status.PresentValue = edg.Item.value;

                return(status);
            }
        }