String IPLC.GetIPAddress()
        {
            LastErrorCode    = 0;
            LastErrorMessage = "";

            try
            {
                if (S7 != null)
                {
                    return(S7.IP);
                }

                throw new LibS7Exception(ErrorCodes.NOTCONNECTED);
            }
            catch (PlcException EPLC)
            {
                LastErrorMessage = EPLC.ToString();
                LastErrorCode    = (UInt32)EPLC.ErrorCode;
                throw EPLC;
            }
            catch (LibS7Exception ES7)
            {
                LastErrorMessage = ES7.ToString();
                LastErrorCode    = ES7.ErrorCode;
                throw ES7;
            }
            catch (Exception E)
            {
                LastErrorMessage = E.ToString();
                LastErrorCode    = ErrorCodes.GENERICEXCEPTION;
                throw E;
            }
        }
        bool IPLC.IsAvailable()
        {
            LastErrorCode    = 0;
            LastErrorMessage = "";

            try
            {
                if (S7 != null)
                {
                    return(S7.IsConnected);
                }

                return(false);
            }
            catch (PlcException EPLC)
            {
                LastErrorMessage = EPLC.ToString();
                LastErrorCode    = (UInt32)EPLC.ErrorCode;
                throw EPLC;
            }
            catch (LibS7Exception ES7)
            {
                LastErrorMessage = ES7.ToString();
                LastErrorCode    = ES7.ErrorCode;
                throw ES7;
            }
            catch (Exception E)
            {
                LastErrorMessage = E.ToString();
                LastErrorCode    = ErrorCodes.GENERICEXCEPTION;
                throw E;
            }
        }
        void IPLC.WriteBytes(UInt32 DB, UInt32 Offset, [In, MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_UI1)] byte[] bArray)
        {
            LastErrorCode    = 0;
            LastErrorMessage = "";

            try
            {
                if (S7 != null)
                {
                    S7.WriteBytes(DataType.DataBlock, (int)DB, (int)Offset, bArray);
                }
                else
                {
                    throw new LibS7Exception(ErrorCodes.NOTCONNECTED);
                }
            }
            catch (PlcException EPLC)
            {
                LastErrorMessage = EPLC.ToString();
                LastErrorCode    = (UInt32)EPLC.ErrorCode;
                throw EPLC;
            }
            catch (LibS7Exception ES7)
            {
                LastErrorMessage = ES7.ToString();
                LastErrorCode    = ES7.ErrorCode;
                throw ES7;
            }
            catch (Exception E)
            {
                LastErrorMessage = E.ToString();
                LastErrorCode    = ErrorCodes.GENERICEXCEPTION;
                throw E;
            }
        }
        IPLCReadData IPLC.ReadBytes(UInt32 DB, UInt32 Offset, UInt32 Count)
        {
            LastErrorCode    = 0;
            LastErrorMessage = "";

            try
            {
                if (S7 != null)
                {
                    byte[] Bytes = S7.ReadBytes(DataType.DataBlock, (int)DB, (int)Offset, (int)Count);
                    return(new CPLCReadData(Bytes));
                }
                else
                {
                    throw new LibS7Exception(ErrorCodes.NOTCONNECTED);
                }
            }
            catch (PlcException EPLC)
            {
                LastErrorMessage = EPLC.ToString();
                LastErrorCode    = (UInt32)EPLC.ErrorCode;
                throw EPLC;
            }
            catch (LibS7Exception ES7)
            {
                LastErrorMessage = ES7.ToString();
                LastErrorCode    = ES7.ErrorCode;
                throw ES7;
            }
            catch (Exception E)
            {
                LastErrorMessage = E.ToString();
                LastErrorCode    = ErrorCodes.GENERICEXCEPTION;
                throw E;
            }
        }