/* * Go button : Execute the get der group request */ private void getDERGroup_Click(object sender, System.EventArgs e) { List<String> derms = new List<string>(); foreach (Control c in getDERGroupMemberPanel.Controls.OfType<TextBox>()) { if (c.Text != null && c.Text.Length > 0) derms.Add(c.Text); } if (derms.Count > 0) { // DERMSInterface.GetDERGroupHeader header = new DERMSInterface.GetDERGroupHeader(); DERMSInterface.CIM cim = new DERMSInterface.CIM(); // default endpoint from app config if not set if (this.getDERGroupEndPoint.Text != null && this.getDERGroupEndPoint.Text.Length > 0) cim.EndPoint = this.getDERGroupEndPoint.Text; String[] reply = cim.getDERGroup(derms.ToArray<String>()); GetDERGroupLogText.Clear(); GetDERGroupLogText.SelectionFont = new Font("Verdana", 12, FontStyle.Bold); GetDERGroupLogText.AppendText("Sent:" + Environment.NewLine + Environment.NewLine); GetDERGroupLogText.SelectionFont = new Font("Verdana", 10, FontStyle.Regular); GetDERGroupLogText.AppendText(cim.LastMessageSent + Environment.NewLine + Environment.NewLine); GetDERGroupLogText.SelectionFont = new Font("Verdana", 12, FontStyle.Bold); GetDERGroupLogText.AppendText("Reply:" + Environment.NewLine + Environment.NewLine); GetDERGroupLogText.SelectionFont = new Font("Verdana", 10, FontStyle.Regular); GetDERGroupLogText.AppendText(cim.LastMessageReceived + Environment.NewLine + Environment.NewLine); } }
public static int requestDERGroupMembers([MarshalAs(UnmanagedType.LPTStr)] String path, [MarshalAs(UnmanagedType.LPTStr)] String mrid, [MarshalAs(UnmanagedType.LPTStr)] ref String xml) { DERResult result = new DERResult(); try { Console.WriteLine("DER file : " + path); Console.WriteLine("MRID : " + mrid); String SOAPMessage = null; String SOAPResponse = null; String[] rvalue = CIM.requestDERGroupMembers(path, mrid, ref SOAPMessage, ref SOAPResponse); result.Members = rvalue; result.SOAPMessage = SOAPMessage; result.SOAPResponse = SOAPResponse; result.Returncode = 0; } catch (Exception e) { result.Returncode = 1; result.ErrorMessage = e.ToString(); Console.Write("Exception thrown by requestDERGroupMembers : ", e); } XmlSerializer ser = new XmlSerializer(typeof(DERResult)); StringWriter writer = new StringWriter(); ser.Serialize(writer, result); xml = writer.ToString(); return(result.Returncode); }
/// <summary> /// loads a CIM data file into memory, returns a CIM object /// </summary> /// <param name="path">file name</param> /// <returns></returns> public static CIM loadConfigFile(string path) { CIM c = new CIM(); c._data = DERMSInterface.CIMData.read(path); return(c); }
/// <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); }
/// <summary> /// convenience function reads CIMData file, calls createDER, returns all in one call /// </summary> /// <param name="DERGroupName">group to be created, must be in the config file</param> /// <param name="path">file name</param> /// <returns></returns> public static int CreateDERGroup(string path, String DERGroupName, String[] members, ref String SOAPMessage, ref String SOAPResponse) { CIM c = new CIM(); c._data = DERMSInterface.CIMData.read(path); int rc = c.createDERGroup(DERGroupName, null); SOAPMessage = c.LastMessageSent; SOAPResponse = c.LastMessageReceived; return(rc); }
/// <summary> /// convenience function reads cimdata file, calls dispatch /// </summary> /// <param name="path"> filename</param> /// <param name="DERGroupName">DER group name</param> /// <param name="q">apparent or real</param> /// <param name="isOverride">send my own value, rather than pulling from config</param> /// <param name="overrideValue">value to send</param> /// <returns></returns> public static int DispatchDERGroup(String path, String DERGroupName, quantity q, ref String SOAPMessage, ref String SoapResponse, Boolean isOverride = false, double overrideValue = 0.0) { CIM c = new CIM(); c._data = DERMSInterface.CIMData.read(path); int rc = c.DispatchDERGroup(DERGroupName, q, isOverride, overrideValue); SOAPMessage = c.LastMessageSent; SoapResponse = c.LastMessageReceived; return(rc); }
public static int createDERGroup( [MarshalAs(UnmanagedType.LPTStr)] String path, [MarshalAs(UnmanagedType.LPTStr)] String mrid, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeConst = _arraySize)] String[] names, [MarshalAs(UnmanagedType.LPTStr)] ref String xml) { DERResult result = new DERResult(); List <String> nameList = new List <string>(); try { /* * the String[] names is terminated when we find * a value = null. This is due to marshalling in * c#. We build a list and then pass a normal string * array to the createDerGroup */ for (int i = 0; i < _arraySize; i++) { if (names[i] == null) { break; } nameList.Add(names[i]); } Console.WriteLine("DER file : " + path); Console.WriteLine("DERGroupName : " + mrid); String SOAPMessage = null; String SOAPResponse = null; int rvalue = CIM.CreateDERGroup(path, mrid, nameList.ToArray <String>(), ref SOAPMessage, ref SOAPResponse); 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); }
public static int dispatchDERGroup( [MarshalAs(UnmanagedType.LPTStr)] String path, [MarshalAs(UnmanagedType.LPTStr)] String mrid, [MarshalAs(UnmanagedType.LPTStr)] String q, [MarshalAs(UnmanagedType.LPTStr)] ref String xml, [MarshalAs(UnmanagedType.Bool)] bool isOverride, [MarshalAs(UnmanagedType.R8)] double overrideValue) { DERResult result = new DERResult(); try { quantity qtype = (quantity)Enum.Parse(typeof(DERMSInterface.quantity), q); Console.WriteLine("DER file : " + path); Console.WriteLine("DERGroupName : " + mrid); Console.WriteLine("Override : " + isOverride); Console.WriteLine("Override value : " + overrideValue); String SOAPMessage = null; String SOAPResponse = null; int rvalue = CIM.DispatchDERGroup(path, mrid, qtype, ref SOAPMessage, ref SOAPResponse, isOverride, overrideValue); result.SOAPMessage = SOAPMessage; result.SOAPResponse = SOAPResponse; result.Returncode = 0; } catch (Exception e) { result.Returncode = 1; result.ErrorMessage = e.ToString(); Console.WriteLine("Exception: {0}", e); } XmlSerializer ser = new XmlSerializer(typeof(DERResult)); StringWriter writer = new StringWriter(); ser.Serialize(writer, result); xml = writer.ToString(); return(result.Returncode); }
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); }
/// <summary> /// convenience function, loads config and requests der member info /// </summary> /// <param name="path">file name</param> /// <param name="mrid">unique identifier for DER group</param> /// <returns></returns> public static String[] requestDERGroupMembers(String path, String mrid, ref String SOAPMessage, ref String SOAPResponse) { CIM c = new CIM(); c._data = DERMSInterface.CIMData.read(path); String[] s = c.requestDERGroupMembers(mrid); if (s == null || s.Length < 1) { Console.WriteLine("DEBUG : soap call returned 0 records"); } else { Console.WriteLine("DEBUG : soap call returned " + s.Length + " records"); foreach (string a in s) { Console.WriteLine("DEBUG : member = " + a); } } SOAPMessage = c.LastMessageSent; SOAPResponse = c.LastMessageReceived; return(s); }
private void createDERGroup_Click(object sender, System.EventArgs e) { // DERMSInterface.GetDERGroupHeader header = new DERMSInterface.GetDERGroupHeader(); DERMSInterface.CIM cim = new DERMSInterface.CIM(); // default endpoint from app config if not set if (this.getDERGroupEndPoint.Text != null && this.getDERGroupEndPoint.Text.Length > 0) { cim.EndPoint = this.getDERGroupEndPoint.Text; } List <String> derms = new List <string>(); foreach (Control c in DerMemberPanel.Controls.OfType <TextBox>()) { if (c.Text != null && c.Text.Length > 0) { derms.Add(c.Text); } } if (derms.Count > 0) { int reply = cim.createDERGroup(DERGroupText.Text, derms.ToArray <String>()); createDERGroupLogText.Text = ""; createDERGroupLogText.SelectionFont = new Font("Verdana", 12, FontStyle.Bold); createDERGroupLogText.AppendText("Sent:" + Environment.NewLine + Environment.NewLine); createDERGroupLogText.SelectionFont = new Font("Verdana", 10, FontStyle.Regular); createDERGroupLogText.AppendText(cim.LastMessageSent + Environment.NewLine + Environment.NewLine); createDERGroupLogText.SelectionFont = new Font("Verdana", 12, FontStyle.Bold); createDERGroupLogText.AppendText("Reply:" + Environment.NewLine + Environment.NewLine); createDERGroupLogText.SelectionFont = new Font("Verdana", 10, FontStyle.Regular); createDERGroupLogText.AppendText(cim.LastMessageReceived + Environment.NewLine + Environment.NewLine); } }