コード例 #1
0
        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;
            }
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
        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;
            }
        }
コード例 #4
0
        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;
            }
        }