public void RefreshMeter(EWT330Phase phase, List <DeviceValueRow <float> > rows) { for (int i = 0; i < 24; i++) { meters[i].Text = $"{rows[i].Value:f1}"; } meters[24].Text = $"{rows[24].Value:f0}"; //if (phase == EWT330Phase.P1) //{ // for (int i = 0; i < 6; i++) // { // meters[i].Text = $"{rows[i].Value:f1}"; // } // meters[24].Text = $"{rows[6].Value:f0}"; // for (int i = 0; i < 19; i++) // { // meters[i+6].Text = "0.0"; // } //} //else //{ // for (int i = 0; i < 24; i++) // { // meters[i].Text = $"{rows[i].Value:f1}"; // } // meters[24].Text = $"{rows[24].Value:f0}"; //} }
//public void DoAfterException(object sender, EventArgs args) //{ // (sender as UlEthernetClient).Close(); //} private void CreatePowerMeterValues(int index, EWT330Phase phase) { for (int i = 0; i < 25; i++) { PowerMeterValues.Add( new DeviceValueRow <float>($"{index:d2} " + ((EWT330P3Series)i).ToString(), 0)); } //switch (phase) //{ // case EWT330Phase.P1: // for (int i=0; i<7; i++) // { // PowerMeterValues.Add( // new DeviceValueRow<float>($"{index:d2} " + ((EWT330P1Series)i).ToString(), 0)); // } // break; // case EWT330Phase.P3: // for (int i = 0; i < 25; i++) // { // PowerMeterValues.Add( // new DeviceValueRow<float>($"{index:d2} " + ((EWT330P3Series)i).ToString(), 0)); // } // break; //} }
private UlWT330EthernetClient( string name, EWT330Phase phase, int scanTime, EEthernetProtocol protocol, int timeout) : base(name, scanTime, protocol, timeout) { this.Phase = phase; this.packet = " "; Mode = EEthernetMode.Real; Values = new float[ItemLength]; }
public UlWT330EthernetClient( string name, EWT330Phase phase, IPEndPoint ipPoint, int scanTime = 250, EEthernetProtocol protocol = EEthernetProtocol.Tcp, int timeout = 1000) : this(name, phase, scanTime, protocol, timeout) { IpPoint = ipPoint; }
private void SetWiringPM(int index, EWT330Phase phase) { lock (client.Udp) { packet.Clear(); packet.Command = EClientCommand.ResetIntegrationPM; packet.IArg1 = index; packet.IArg2 = (int)phase; client.Udp.Send(packet.Bytes, packet.Bytes.Length, client.IpPoint); Log(ESenderLogItem.Send, "Send a Command({0}) - IArg1 : {1}, IArg2 : {2}", packet.Command.ToString(), packet.IArg1, packet.IArg2); } client.Listener.WaitForAck(); }
public UlWT330EthernetClient( string name, EWT330Phase phase, string ip, int port, int scanTime = 250, EEthernetProtocol protocol = EEthernetProtocol.Tcp, int timeout = 1000) : this(name, phase, scanTime, protocol, timeout) { try { IpPoint = new IPEndPoint(IPAddress.Parse(ip), port); } catch (Exception e) { Log(EEthernetLogItem.Exception, e.Message); throw new WT330Exception( "Occurred invalid IP and Port in UlWT330EthernetClient.Creater", EWT330Exception.InvalidIPandPort); } }
private void Initialize() { int port, scan, count; string name, logPath, logName; EEthernetMode mode; EEthernetLogging logging; int i = 1; int length = 0; string section = $"PowerMeter.{i:d2}"; string ip = server.Ini.GetString(section, "ip"); PowerMeter.Clear(); PowerMeterValues.Clear(); while (ip != "") { name = server.Ini.GetString(section, "name"); port = server.Ini.GetInteger(section, "port"); scan = server.Ini.GetInteger(section, "scantime"); logPath = server.Ini.GetString(section, "logpath"); logName = server.Ini.GetString(section, "logfilename"); logging = GetEthernetLogging(section); mode = (server.Ini.GetString(section, "mode") == "Real") ? EEthernetMode.Real : EEthernetMode.Virtual; EWT330Phase phase = (server.Ini.GetString(section, "phase") == "P1") ? EWT330Phase.P1 : EWT330Phase.P3; length += 25; //if (phase == EWT330Phase.P1) length += 7; //else length += 25; UlWT330EthernetClient client = new UlWT330EthernetClient(name, phase, ip, port, scan); client.Mode = mode; client.Logging = logging; client.LogPath = logPath; client.LogFName = $"{logName}.{i:d2}"; PowerMeter.Add(client); CreatePowerMeterValues(i, phase); i++; section = $"PowerMeter.{i:d2}"; ip = server.Ini.GetString(section, "ip"); } i = 1; section = $"Recorder.{i:d2}"; ip = server.Ini.GetString(section, "ip"); Recorder.Clear(); while (ip != "") { name = server.Ini.GetString(section, "name"); port = server.Ini.GetInteger(section, "port"); count = server.Ini.GetInteger(section, "length"); scan = server.Ini.GetInteger(section, "scantime"); logPath = server.Ini.GetString(section, "logpath"); logName = server.Ini.GetString(section, "logfilename"); logging = GetEthernetLogging(section); mode = (server.Ini.GetString(section, "mode") == "Real") ? EEthernetMode.Real : EEthernetMode.Virtual; length += count; UlGM10EthernetClient client = new UlGM10EthernetClient(name, ip, port, count, scan); client.Mode = mode; client.Logging = logging; client.LogPath = logPath; client.LogFName = $"{logName}.{i:d2}"; Recorder.Add(client); CreateRecorderValues(i, count); i++; section = $"Recorder.{i:d2}"; ip = server.Ini.GetString(section, "ip"); } i = 1; section = $"Controller.{i:d2}"; ip = server.Ini.GetString(section, "ip"); Controller.Clear(); while (ip != "") { name = server.Ini.GetString(section, "name"); port = server.Ini.GetInteger(section, "port"); scan = server.Ini.GetInteger(section, "scantime"); logPath = server.Ini.GetString(section, "logpath"); logName = server.Ini.GetString(section, "logfilename"); logging = GetEthernetLogging(section); mode = (server.Ini.GetString(section, "mode") == "Real") ? EEthernetMode.Real : EEthernetMode.Virtual; int slaveAddr = server.Ini.GetInteger(section, "slaveaddress"); int slaveCount = server.Ini.GetInteger(section, "slavecount"); float defDecial = (float)server.Ini.GetDouble(section, "DefaultFixedDecimal"); length += (slaveCount * 12); UlUT55AEthernetClient client = new UlUT55AEthernetClient(name, ip, port, slaveAddr, slaveCount, scan); client.Mode = mode; client.Logging = logging; client.LogPath = logPath; client.LogFName = $"{logName}.{i:d2}"; int addr; float fixedDec; for (int j = 0; j < slaveCount; j++) { addr = slaveAddr + j; fixedDec = (float)server.Ini.GetDouble(section, $"FixedDecimal{addr}"); if (fixedDec < 0.1) { client.SetFixedDecimal(addr, defDecial); } else { client.SetFixedDecimal(addr, fixedDec); } } Controller.Add(client); CreateControllerValues(slaveAddr, slaveCount); i++; section = $"Controller.{i:d2}"; ip = server.Ini.GetString(section, "ip"); } Values = new float[length]; i = 1; section = $"Plc.{i:d2}"; ip = server.Ini.GetString(section, "ip"); Plc.Clear(); while (ip != "") { name = server.Ini.GetString(section, "name"); port = server.Ini.GetInteger(section, "port"); scan = server.Ini.GetInteger(section, "scantime"); logPath = server.Ini.GetString(section, "logpath"); logName = server.Ini.GetString(section, "logfilename"); logging = GetEthernetLogging(section); mode = (server.Ini.GetString(section, "mode") == "Real") ? EEthernetMode.Real : EEthernetMode.Virtual; string block = server.Ini.GetString(section, "block"); int blockLength = server.Ini.GetInteger(section, "blocklength"); UlMasterKEthernetClient client = new UlMasterKEthernetClient(name, ip, port, block, blockLength, scan); client.Mode = mode; client.Logging = logging; client.LogPath = logPath; client.LogFName = $"{logName}.{i:d2}"; Plc.Add(client); CreatePlcValues(i, blockLength); i++; section = $"Plc.{i:d2}"; ip = server.Ini.GetString(section, "ip"); } Bytes = new byte[length * 4 + PlcLength * 2]; }
private void Initialize() { // Load powermeter parameters int i = 1; int index = 0; string section; string key = $"PM{i}"; string param = client.Ini.GetString("PowerMeter", key); PowerMeter.Rows.Clear(); while (string.IsNullOrWhiteSpace(param) == false) { string[] @params = param.Split(new[] { ',' }, StringSplitOptions.None); EWT330Phase phase = (@params[1] == "P1") ? EWT330Phase.P1 : EWT330Phase.P3; PowerMeterRow <float> row = new PowerMeterRow <float>(@params[0], phase); PowerMeter.Rows.Add(row); int j = 1; section = $"{key}.Channel"; key = $"CH{j}"; param = client.Ini.GetString(section, key); while (string.IsNullOrWhiteSpace(param) == false) { //@params = param.Split(new[] { ',' }, StringSplitOptions.None); //index = int.Parse(@params[1]); DeviceValueRow <float> valueRow = new DeviceValueRow <float>(param, index++, 0); row.Values.Add(valueRow); PowerMeter.Values.Add(valueRow); j++; key = $"CH{j}"; param = client.Ini.GetString(section, key); } i++; key = $"PM{i}"; param = client.Ini.GetString("PowerMeter", key); } // Load recorder parameters i = 1; key = $"Rec{i}"; param = client.Ini.GetString("Recorder", key); Recorder.Rows.Clear(); while (string.IsNullOrWhiteSpace(param) == false) { RecorderRow <float> row = new RecorderRow <float>(param); Recorder.Rows.Add(row); int j = 1; section = $"{key}.Channel"; key = $"CH{j}"; param = client.Ini.GetString(section, key); while (string.IsNullOrWhiteSpace(param) == false) { DeviceValueRow <float> valueRow = new DeviceValueRow <float>(param, index++, 0); row.Values.Add(valueRow); Recorder.Values.Add(valueRow); j++; key = $"CH{j}"; param = client.Ini.GetString(section, key); } i++; key = $"Rec{i}"; param = client.Ini.GetString("Recorder", key); } int count = Recorder.Values.Count / 4; for (int k = 0; k < count; k++) { Recorder.ValueList[0].Add(Recorder.Values[k]); Recorder.ValueList[1].Add(Recorder.Values[k + count]); Recorder.ValueList[2].Add(Recorder.Values[k + count * 2]); if ((k + count * 3) < Recorder.Values.Count) { Recorder.ValueList[3].Add(Recorder.Values[k + count * 3]); } } string[] recParams = client.Ini.GetString("Recorder", "Pressure").Split(new[] { ',' }, StringSplitOptions.None); Recorder.PressureIndex = int.Parse(recParams[0]); Recorder.PressureLength = int.Parse(recParams[1]); recParams = client.Ini.GetString("Recorder", "Thermocouple").Split(new[] { ',' }, StringSplitOptions.None); Recorder.ThermocoupleIndex = int.Parse(recParams[0]); Recorder.ThermocoupleLength = int.Parse(recParams[1]); // Load controller parameters i = 1; key = $"Ctrl{i}"; param = client.Ini.GetString("Controller", key); Controller.Rows.Clear(); while (string.IsNullOrWhiteSpace(param) == false) { string[] @params = param.Split(new[] { ',' }, StringSplitOptions.None); int networkNo = int.Parse(@params[1]); int addr = int.Parse(@params[2]); ControllerRow <float> row = new ControllerRow <float>(@params[0], networkNo, addr); Controller.Rows.Add(row); int j = 1; section = $"{key}.Channel"; key = $"CH{j}"; param = client.Ini.GetString(section, key); while (string.IsNullOrWhiteSpace(param) == false) { //@params = param.Split(new[] { ',' }, StringSplitOptions.None); //index = int.Parse(@params[1]); DeviceValueRow <float> valueRow = new DeviceValueRow <float>(param, index++, 0); row.Values.Add(valueRow); Controller.Values.Add(valueRow); j++; key = $"CH{j}"; param = client.Ini.GetString(section, key); } i++; key = $"Ctrl{i}"; param = client.Ini.GetString("Controller", key); } // Load PLC parameters i = 1; index = 0; key = $"Plc{i}"; param = client.Ini.GetString("Plc", key); Plc.Rows.Clear(); while (string.IsNullOrWhiteSpace(param) == false) { PlcRow <UInt16> row = new PlcRow <UInt16>(param); Plc.Rows.Add(row); int j = 1; section = $"{key}.Channel"; key = $"CH{j}"; param = client.Ini.GetString(section, key); while (string.IsNullOrWhiteSpace(param) == false) { DeviceValueRow <UInt16> valueRow = new DeviceValueRow <UInt16>(param, index++, 0); row.Values.Add(valueRow); Plc.Values.Add(valueRow); j++; key = $"CH{j}"; param = client.Ini.GetString(section, key); } i++; key = $"Plc{i}"; param = client.Ini.GetString("Plc", key); } }
public PowerMeterRow(string name, EWT330Phase phase) : base(name) { Phase = phase; }