/// <summary> /// SOAP call to get the list of DERs within a DERGroup /// </summary> /// <param name="name">name of DERGroup</param> /// <returns>array of strings of DER member names</returns> public String[] requestDERGroupMembers(String mrid) { try { // initialize SOAP call CIMGetDERGroup.GetDERGroup_PortClient client; CIMData.header header = _data.GetDERHeader; if (!hasData(header.EndPoint)) { throw new DERConfigureException("End Point required"); } client = new CIMGetDERGroup.GetDERGroup_PortClient("GetDERGroupImplPort", header.EndPoint); // initialize SOAP vars CIMGetDERGroup.GetDERGroupRequestMessageType req = new CIMGetDERGroup.GetDERGroupRequestMessageType(); CIMGetDERGroup.DERGroupPayloadType payload = new CIMGetDERGroup.DERGroupPayloadType(); req.Payload = payload; req.Request = new CIMGetDERGroup.GetDERGroupRequestType(); req.Request.StartTime = System.DateTime.Now; CIMGetDERGroup.HeaderType to = new CIMGetDERGroup.HeaderType(); req.Header = to; // build header CIMGetDERGroup.HeaderTypeVerb v = new CIMGetDERGroup.HeaderTypeVerb(); if (Enum.TryParse(header.Verb, out v)) { to.Verb = v; } to.Verb = CIMGetDERGroup.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 CIMGetDERGroup.UserType(); to.User.UserID = (hasData(header.UserID)) ? header.UserID : "epri"; // required to.User.Organization = header.UserOrganization; // optional } // load the SOAP payload payload.DERGroups = new CIMGetDERGroup.EndDeviceGroup[1]; payload.DERGroups[0] = new CIMGetDERGroup.EndDeviceGroup(); payload.DERGroups[0].mRID = mrid; payload.DERGroups[0].Version = new CIMGetDERGroup.EndDeviceGroupVersion(); payload.DERGroups[0].Version.major = _data.Version.Major; payload.DERGroups[0].Version.minor = _data.Version.Minor; payload.DERGroups[0].Version.revision = _data.Version.Revision; payload.DERGroups[0].Version.versionDate = _data.Version.Date; //' log out message, make call, log return message _lastMessageSent = logMessage <CIMGetDERGroup.GetDERGroupRequestMessageType>(req); CIMGetDERGroup.DERGroupResponseMessageType reply = client.GetDERGroup(req); _lastMessageReceived = logMessage <CIMGetDERGroup.DERGroupResponseMessageType>(reply); if (reply.Payload.DERGroups != null && reply.Payload.DERGroups.Length > 0) { List <String> ders = new List <string>(); foreach (CIMGetDERGroup.EndDeviceGroup dev in reply.Payload.DERGroups) { ders.Add(dev.name); } return(ders.ToArray()); } } catch (Exception e) { Console.WriteLine("Exception : " + e.ToString()); } return(null); }
/// <summary> /// executes a create DER SOAP command /// </summary> /// <param name="DERGroupName">name of der group to create</param> /// <param name="members">list of der's (their names) to create, defaultNull = all</param> /// <returns></returns> public int createDERGroup(String DERGroupName, String[] members) { if (DERGroupName == null || DERGroupName.Length < 1) { throw new DERConfigureException("createDERGroup illegal argument, DERGroup name not set"); } // intialize service CIMChangeDERGroup.DERGroup_PortClient client; CIMData.header header = _data.CreateDERHeader; if (!hasData(header.EndPoint)) { throw new DERConfigureException("End Point required"); } client = new CIMChangeDERGroup.DERGroup_PortClient("DERGroup_Port", header.EndPoint); // Initialize service vars DERMSInterface.CIMChangeDERGroup.DERGroupRequestMessageType req = new DERMSInterface.CIMChangeDERGroup.DERGroupRequestMessageType(); CIMChangeDERGroup.HeaderType to = new CIMChangeDERGroup.HeaderType(); req.Header = to; // initialize header CIMChangeDERGroup.HeaderTypeVerb v = new CIMChangeDERGroup.HeaderTypeVerb(); if (header.Verb != null && Enum.TryParse(header.Verb, out v)) { to.Verb = v; } else { to.Verb = CIMChangeDERGroup.HeaderTypeVerb.change; } 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 CIMChangeDERGroup.UserType(); to.User.UserID = (hasData(header.UserID)) ? header.UserID : "epri"; // required to.User.Organization = header.UserOrganization; // optional } // initialize the payload req.Payload = new CIMChangeDERGroup.DERGroupPayloadType(); req.Payload.DERGroups = new CIMChangeDERGroup.EndDeviceGroup[1]; req.Payload.DERGroups[0] = new CIMChangeDERGroup.EndDeviceGroup(); req.Payload.DERGroups[0].Version = new CIMChangeDERGroup.EndDeviceGroupVersion(); req.Payload.DERGroups[0].Version.major = _data.Version.Major; req.Payload.DERGroups[0].Version.minor = _data.Version.Minor; req.Payload.DERGroups[0].Version.revision = _data.Version.Revision; req.Payload.DERGroups[0].Version.versionDate = _data.Version.Date; // find the data that matches the DER name passed CIMData.DERGroup group = _data.Groups.Find(x => x.GroupName.Equals(DERGroupName)); if (group == null) { throw new DERConfigureException("DERGroup Name " + DERGroupName + " not found in configuration file"); } else { req.Payload.DERGroups[0].name = group.GroupName; req.Payload.DERGroups[0].mRID = group.Mrid; List <CIMChangeDERGroup.DERMember> DERMembers = new List <CIMChangeDERGroup.DERMember>(); // load the ders that go with the DER Group foreach (CIMData.device dev in group.Devices) { // todo : Is the purpose of members to filter our DERS to be created? if (members == null || (members != null && Array.Find(members, x => x.Equals(dev.Name)) != null)) { CIMChangeDERGroup.DERMember d = new CIMChangeDERGroup.DERMember(); DERMembers.Add(d); d.name = dev.Name; d.mRID = dev.Mrid; d.CapabilityList = new CIMChangeDERGroup.DERMemberCapabilityList(); d.CapabilityList.ActivePower = new CIMChangeDERGroup.ActivePower(); d.CapabilityList.ActivePower.value = (float)dev.WattCapacity; d.CapabilityList.ActivePower.multiplier = CIMChangeDERGroup.multiplier.k; d.CapabilityList.ActivePower.unit = "W"; d.CapabilityList.ReactivePower = new CIMChangeDERGroup.ReactivePower(); d.CapabilityList.ReactivePower.value = (float)dev.VarCapacity; d.CapabilityList.ReactivePower.multiplier = CIMChangeDERGroup.multiplier.k; d.CapabilityList.ReactivePower.unit = "VAr"; // TODO : New xsd, add the watts etc... } } req.Payload.DERGroups[0].EndDevice = DERMembers.ToArray(); // Log outbound, send the message to DER Server, log return message _lastMessageSent = logMessage <DERMSInterface.CIMChangeDERGroup.DERGroupRequestMessageType>(req); DERMSInterface.CIMChangeDERGroup.DERGroupResponseMessageType reply = client.CreateDERGroup(req); _lastMessageReceived = logMessage <DERMSInterface.CIMChangeDERGroup.DERGroupResponseMessageType>(reply); if (reply.Reply.Result.CompareTo(CIMChangeDERGroup.ReplyTypeResult.OK) == 0) { return(0); } return(1); } }
/// <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); } }
/// <summary> /// executes a create DERdispatch soap command /// </summary> /// <param name="DERGroupName">DERGroup name</param> /// <param name="q">realPower or reactivePower</param> /// <param name="isOverride">send overrideValue instead of value from cimdata</param> /// <param name="overrideValue">value to be used for dispatch</param> /// <returns></returns> public int DispatchDERGroup(String MRID, quantity q, Boolean isOverride = false, double overrideValue = 0.0) { CIMDERGroupDispatches.DERGroupDispatches_PortClient client; CIMData.header header = _data.DispatchDERHeader; if (!hasData(header.EndPoint)) { throw new DERConfigureException("End Point required"); } // initialize SOAP server client = new CIMDERGroupDispatches.DERGroupDispatches_PortClient("DERGroupDispatches_Port", header.EndPoint); // intiailize service arguments CIMDERGroupDispatches.HeaderType to = new CIMDERGroupDispatches.HeaderType(); CIMDERGroupDispatches.DERGroupDispatchesPayloadType payload = new CIMDERGroupDispatches.DERGroupDispatchesPayloadType(); CIMDERGroupDispatches.DERGroupDispatchesRequestMessageType req = new CIMDERGroupDispatches.DERGroupDispatchesRequestMessageType(); req.Payload = payload; req.Header = to; // set service header arguments CIMDERGroupDispatches.HeaderTypeVerb v = new CIMDERGroupDispatches.HeaderTypeVerb(); if (header.Verb != null && Enum.TryParse(header.Verb, out v)) { to.Verb = v; } else { to.Verb = CIMDERGroupDispatches.HeaderTypeVerb.create; } 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 CIMDERGroupDispatches.UserType(); to.User.UserID = (hasData(header.UserID)) ? header.UserID : "epri"; // required to.User.Organization = header.UserOrganization; // optional } // load the data for the SOAP call CIMData.DERGroup group = _data.Groups.Find(x => x.Mrid.Equals(MRID)); if (group != null) { payload.DERGroupDispatches = new CIMDERGroupDispatches.DERGroupDispatch[1]; payload.DERGroupDispatches[0] = new CIMDERGroupDispatches.DERGroupDispatch(); payload.DERGroupDispatches[0].DERGroup = new CIMDERGroupDispatches.DERGroup(); payload.DERGroupDispatches[0].DERGroup.mRID = group.Mrid; payload.DERGroupDispatches[0].DERGroup.name = group.GroupName; // TODO : Docs say mrid, but name is required in wsdl. Ask Gerry. payload.DERGroupDispatches[0].RequestedCapability = new CIMDERGroupDispatches.RequestedCapability(); payload.DERGroupDispatches[0].RequestedCapability.capabilityType = (CIMDERGroupDispatches.capabilityType)Enum.Parse(typeof(CIMDERGroupDispatches.capabilityType), q.ToString()); // load with value passed, or reactive value, or real value if (isOverride == true) { payload.DERGroupDispatches[0].RequestedCapability.value = (float)overrideValue; } else if (q.Equals(quantity.ApparentPower)) { payload.DERGroupDispatches[0].RequestedCapability.value = (float)group.getVarCapacity(); } else { payload.DERGroupDispatches[0].RequestedCapability.value = (float)group.getWattCapacity(); } // set the multiplier and units if (q.Equals(quantity.RealPower)) { payload.DERGroupDispatches[0].RequestedCapability.capabilityMultiplier = CIMDERGroupDispatches.UnitMultiplier.k; payload.DERGroupDispatches[0].RequestedCapability.capabilityUnits = "W"; } else { payload.DERGroupDispatches[0].RequestedCapability.capabilityMultiplier = CIMDERGroupDispatches.UnitMultiplier.k; payload.DERGroupDispatches[0].RequestedCapability.capabilityUnits = "VAr"; } // log message to be sent, send message, log result _lastMessageSent = logMessage <DERMSInterface.CIMDERGroupDispatches.DERGroupDispatchesRequestMessageType>(req); CIMDERGroupDispatches.DERGroupDispatchesResponseMessageType reply = client.CreateDERGroupDispatches(req); _lastMessageReceived = logMessage <CIMDERGroupDispatches.DERGroupDispatchesResponseMessageType>(reply); if (reply.Reply.Result.CompareTo(CIMDERGroupDispatches.ReplyTypeResult.OK) == 0) { return(0); } else { return(1); } } else { throw new DERConfigureException("DERGroup MRID " + MRID + " not found in configuration file"); } }