diff --git a/S7.Net.Common/Interfaces/IPLC.cs b/S7.Net.Common/Interfaces/IPLC.cs deleted file mode 100644 index ff23de6..0000000 --- a/S7.Net.Common/Interfaces/IPLC.cs +++ /dev/null @@ -1,144 +0,0 @@ -using System; - -namespace S7.Net.Interfaces -{ - public interface IPlc : IDisposable - { - /// - /// Ip address of the plc - /// - string IP { get; set; } - - /// - /// Checks if the socket is connected and polls the other peer (the plc) to see if it's connected. - /// This is the variable that you should continously check to see if the communication is working - /// See also: http://stackoverflow.com/questions/2661764/how-to-check-if-a-socket-is-connected-disconnected-in-c - /// - bool IsConnected { get; } - - /// - /// Cpu type of the plc - /// - CpuType CPU { get; set; } - - /// - /// Rack of the plc - /// - Int16 Rack { get; set; } - - /// - /// Slot of the CPU of the plc - /// - Int16 Slot { get; set; } - - /// - /// Name of the plc (optional, is not used anywhere in the driver) - /// - string Name { get; set; } - - /// - /// Tag of the plc (optional, is not used anywhere in the driver) - /// - object Tag { get; set; } - - /// - /// Pings the IP address and returns true if the result of the ping is Success. - /// - bool IsAvailable { get; } - - /// - /// Contains the last error registered when executing a function - /// - string LastErrorString { get; } - - /// - /// Contains the last error code registered when executing a function - /// - ErrorCode LastErrorCode { get; } - - /// - /// Open a socket and connects to the plc, sending all the corrected package and returning if the connection was successful (ErroreCode.NoError) of it was wrong. - /// - /// Returns ErrorCode.NoError if the connection was successful, otherwise check the ErrorCode - ErrorCode Open(); - - /// - /// Disonnects from the plc and close the socket - /// - void Close(); - - /// - /// Reads up to 200 bytes from the plc and returns an array of bytes. You must specify the memory area type, memory are address, byte start address and bytes count. - /// If the read was not successful, check LastErrorCode or LastErrorString. - /// - /// Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. - /// Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. - /// Start byte address. If you want to read DB1.DBW200, this is 200. - /// Byte count, if you want to read 120 bytes, set this to 120. This parameter can't be higher than 200. If you need more, use recursion. - /// Returns the bytes in an array - byte[] ReadBytes(DataType dataType, int DB, int startByteAdr, int count); - - /// - /// Read and decode a certain number of bytes of the "VarType" provided. - /// This can be used to read multiple consecutive variables of the same type (Word, DWord, Int, etc). - /// If the read was not successful, check LastErrorCode or LastErrorString. - /// - /// Data type of the memory area, can be DB, Timer, Counter, Merker(Memory), Input, Output. - /// Address of the memory area (if you want to read DB1, this is set to 1). This must be set also for other memory area types: counters, timers,etc. - /// Start byte address. If you want to read DB1.DBW200, this is 200. - /// Type of the variable/s that you are reading - /// Number of the variables (NOT number of bytes) to read - /// - object Read(DataType dataType, int db, int startByteAdr, VarType varType, int varCount); - - /// - /// Reads a single variable from the plc, takes in input strings like "DB1.DBX0.0", "DB20.DBD200", "MB20", "T45", etc. - /// If the read was not successful, check LastErrorCode or LastErrorString. - /// - /// Input strings like "DB1.DBX0.0", "DB20.DBD200", "MB20", "T45", etc. - /// Returns an object that contains the value. This object must be cast accordingly. - object Read(string variable); - - /// - /// Reads all the bytes needed to fill a struct in C#, and return an object that can be casted to the struct. - /// - /// Type of the struct to be readed (es.: TypeOf(MyStruct)). - /// Address of the DB. - /// Returns a struct that must be cast. - object ReadStruct(Type structType, int db); - - /// - /// Reads all the bytes needed to fill a struct in C#, starting from a certain address, and return an object that can be casted to the struct. - /// - /// Type of the struct to be readed (es.: TypeOf(MyStruct)). - /// Address of the DB. - /// Start byte address. If you want to read DB1.DBW200, this is 200. - /// Returns a struct that must be cast. - object ReadStruct(Type structType, int db, int startByteAdr); - - /// - /// Reads all the bytes needed to fill a class in C#, and set all the properties values to the value that are read from the plc. - /// This reads ony properties, it doesn't read private variable or public variable without {get;set;} specified. - /// - /// Instance of the class that will store the values - /// Index of the DB; es.: 1 is for DB1 - void ReadClass(object sourceClass, int db); - - /// - /// Reads all the bytes needed to fill a class in C#, starting from a certain address, and set all the properties values to the value that are read from the plc. - /// This reads ony properties, it doesn't read private variable or public variable without {get;set;} specified. - /// - /// Instance of the class that will store the values - /// Index of the DB; es.: 1 is for DB1 - /// Start byte address. If you want to read DB1.DBW200, this is 200. - void ReadClass(object sourceClass, int db, int startByteAdr); - - ErrorCode WriteBytes(DataType dataType, int db, int startByteAdr, byte[] value); - object Write(DataType dataType, int db, int startByteAdr, object value); - object Write(string variable, object value); - ErrorCode WriteStruct(object structValue, int db); - ErrorCode WriteClass(object classValue, int db); - - - } -} \ No newline at end of file diff --git a/S7.Net/PLC.cs b/S7.Net/PLC.cs index 2c95734..22482b3 100644 --- a/S7.Net/PLC.cs +++ b/S7.Net/PLC.cs @@ -5,13 +5,12 @@ using System.Linq; using System.Net; using System.Net.NetworkInformation; using System.Net.Sockets; -using S7.Net.Interfaces; using S7.Net.Types; using Double = System.Double; namespace S7.Net { - public class Plc : IPlc + public class Plc { private Socket _mSocket; //TCP connection to device diff --git a/S7.Net/S7.Net.csproj b/S7.Net/S7.Net.csproj index 1dfda6f..2dc0b3a 100644 --- a/S7.Net/S7.Net.csproj +++ b/S7.Net/S7.Net.csproj @@ -72,8 +72,53 @@ - - %(RecursiveDir)%(FileName) + + Conversion + + + Enums + + + Types\Boolean + + + Types\Byte + + + Types\ByteArray + + + Types\Class + + + Types\Counter + + + Types\DataItem + + + Types\DInt + + + Types\Double + + + Types\DWord + + + Types\Int + + + Types\String + + + Types\Struct + + + Types\Timer + + + Types\Word