public override void ManuelProcess(string Islem, string PlcCommand) { if (Status != ConnectionStatus.Opened) { Bits_Per_Second = 4800; Data_Bits = 7; Parity = System.IO.Ports.Parity.Even; Stop_Bits = StopBits.One; Connect(); if (Status != ConnectionStatus.Opened) { return; } } MeterRead = Sp.ReadExisting(); if (MeterRead == "") { Status = ConnectionStatus.Error; clsMessage.ErrorTanim = "Connection Problem"; clsGeneral.MeterConnect = "!"; Meter = 0; Sp.Close(); return; } else { if (Status != ConnectionStatus.Opened) { Bits_Per_Second = 4800; Data_Bits = 7; Parity = System.IO.Ports.Parity.Even; Stop_Bits = StopBits.One; Connect(); if (Status != ConnectionStatus.Opened) { return; } } if (clsAyar.MeterFormat.Length > MeterRead.Length) { return; } if (!clsGeneral.WriteMeterIndicator(Sp, "Meter", PlcCommand, out ReturnedValue)) { return; } clsGeneral.MeterConnect = ""; } try { Meter = ReturnedValue.ToDouble(); Sp.DiscardInBuffer(); } catch { } Sp.DiscardInBuffer(); Sp.DiscardOutBuffer(); }
public override void MeterOku() { if (Status != ConnectionStatus.Opened) { Bits_Per_Second = 4800; Data_Bits = 7; Port_No = clsAyar.MeterPortAdi; Parity = System.IO.Ports.Parity.Even; Stop_Bits = StopBits.One; Connect(); if (Status != ConnectionStatus.Opened) { return; } } clsGeneral.MeterConnect = ""; Sp.DiscardInBuffer(); Sp.DiscardOutBuffer(); Sp.DataReceived -= Sp_DataReceived; Sp.DataReceived += Sp_DataReceived; byte[] Dizi = new byte[] { 0x02, 0x30, 0x30, 0x30, 0x31, 0x52, 0x30, 0x30, 0x31, 0x35, 0x33, 0x37, 0x03, 0x0D }; //Encoding.ASCII.GetBytes(txtGiden.Text); Sp.Write(Dizi, 0, Dizi.Length); }