public double ReadDouble(string variable, int decimalNumbers) { PLC.Open(); double value = Math.Round(Convert.ToDouble((uint)PLC.Read(variable)), decimalNumbers); PLC.Close(); return(value); }
public bool ReadBool(DataType dataType, int db, int startByteAdr) { PLC.Open(); bool value = Convert.ToBoolean(PLC.ReadBytes(dataType, db, startByteAdr, 1)[0]); PLC.Close(); return(value); }
public bool ReadBool(string variable) { PLC.Open(); bool value = (bool)(PLC.Read(variable)); PLC.Close(); return(value); }
public bool Close() { try { PLC.Close(); return(true); } catch (Exception) { return(false); } }
public int ReadInt(string variable) { //int test = Int.FromByteArray((byte[])PLC.Read(variable)); PLC.Open(); var value = PLC.Read(variable); PLC.Close(); if (Convert.ToInt32(value) == 0) { return(0); } return((ushort)value); }
public bool CloseConnection() { try { PLC.Close(); SetErrorMessageOk(); return(true); } catch (Exception ex) { SetErrorMessageBad(ex.Message); return(false); } }
private void bndisconnect_Click(object sender, EventArgs e) { try { if (plc != null) { plc.Close(); btnconnect.Enabled = true; } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Information", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } }
public void Close() { isConnect = false; plc.Close(); }