Exemple #1
0
        public double ReadDouble(string variable, int decimalNumbers)
        {
            PLC.Open();
            double value = Math.Round(Convert.ToDouble((uint)PLC.Read(variable)), decimalNumbers);

            PLC.Close();
            return(value);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public bool ReadBool(string variable)
        {
            PLC.Open();
            bool value = (bool)(PLC.Read(variable));

            PLC.Close();
            return(value);
        }
Exemple #4
0
 public bool Close()
 {
     try
     {
         PLC.Close();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemple #5
0
        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);
        }
Exemple #6
0
 public bool CloseConnection()
 {
     try
     {
         PLC.Close();
         SetErrorMessageOk();
         return(true);
     }
     catch (Exception ex)
     {
         SetErrorMessageBad(ex.Message);
         return(false);
     }
 }
Exemple #7
0
 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();
 }