Esempio n. 1
0
        /****************************************************************************
         *	Description	:	SIEMENS Industrial Ethernet Fetch-Telegram
         *
         *	Return      :	array of bytes/int
         *	              on error "null" is returned
         *
         ***************************************************************************/
        public byte[] FetchData(DataType DataType, int DBNr, int StartAdress, int Length)
        {
            if (!ReconnectIfDisconnected())
            {
                return(null);
            }

            lock (threading)
            {
                var buff = new byte[Length];
                _s7client.DBRead(DBNr, StartAdress, Length, buff);
                return(buff);
            }
        }
Esempio n. 2
0
 public bool checkZustand(TextBox txtBox)
 {
     if (client.Connected)
     {
         if (art == 0)
         {
             byte[] buffer = new byte[1];
             int    result = client.DBRead(db, dbByte, 1, buffer);
             zustand = Sharp7.S7.GetBitAt(buffer, 0, dbBit);
             txtBox.AppendText(Environment.NewLine + DateTime.Now.ToString() + "DBRead-Return-Value: " + result.ToString() + " Zustand: " + zustand.ToString() + " Buffer: " + buffer.ToString());
             checkUueberwachung();
             return(zustand);
         }
         else if (art == 1)
         {
             byte[] buffer = new byte[1];
             int    result = client.MBRead(merkerByte, 1, buffer);
             zustand = Sharp7.S7.GetBitAt(buffer, 0, merkerBit);
             txtBox.AppendText(Environment.NewLine + DateTime.Now.ToString() + "MBRead-Return-Value: " + result.ToString() + " Zustand: " + zustand.ToString() + " Buffer: " + buffer.ToString());
             //txtBox.AppendText("\n" + DateTime.Now.ToString() + "MBRead-Return-Value: " + result.ToString() + " Zustand: " + zustand.ToString() + " Buffer: " + buffer.ToString());
             //txtBox.AppendText("\n" + DateTime.Now.ToString() + "MBRead-Return-Value: " + result.ToString() + " Zustand: " + zustand.ToString() + " Buffer: " + buffer.ToString());
             checkUueberwachung();
             return(zustand);
         }
         else
         {
             txtBox.AppendText(Environment.NewLine + DateTime.Now.ToString() + " keine Verbindung");
             return(false);
         }
     }
     else
     {
         zustand = false;
         txtBox.AppendText(Environment.NewLine + DateTime.Now.ToString() + "\n Nicht Online");
         //Exception ex = new Exception();
         //throw ex;
         return(false);
     }
 }