User Activity

  • Modified a comment on discussion What you would like to see in Snap7 on Snap7

    This code is used by me. Code is tested with C# 7.1 This additional functions allow to write/read System types directly into PLC //EXAMPLE private enum ScannerState : WORD { Ready = 0, Busy = 1, Complete = 2, } //... var result = Client.DBWrite(dbNumber, stateOffset, ScannerState.Complete); //... var result = Client.DBRead<ScannerState>(dbNumber, stateOffset, out var state); 1) class S7, add functions: public static class S7 ... public static byte[] GetBytes<T>(T value, bool reverse = false)//T =...

  • Modified a comment on discussion What you would like to see in Snap7 on Snap7

    This code is used by me. 1) class S7, add functions: public static class S7 ... public static byte[] GetBytes<T>(T value, bool reverse = false)//T = BYTE,WORD,SINGLE,ect...,ENUM { if (value == null) return new byte[0]; Type type; dynamic any; byte[] bytes; if (typeof(T).IsEnum) { type = Enum.GetUnderlyingType(typeof(T)); any = Convert.ChangeType(value, type); } else { type = typeof(T); any = value; } switch (any) { case byte val: bytes = new byte[] { val }; break; case sbyte val: bytes = new byte[]...

  • Modified a comment on discussion What you would like to see in Snap7 on Snap7

    This code is used by me. class S7, add functions: public static class S7 ... public static byte[] GetBytes<T>(T value, bool reverse = false)//T = BYTE,WORD,SINGLE,ect...,ENUM { if (value == null) return new byte[0]; Type type; dynamic any; byte[] bytes; if (typeof(T).IsEnum) { type = Enum.GetUnderlyingType(typeof(T)); any = Convert.ChangeType(value, type); } else { type = typeof(T); any = value; } switch (any) { case byte val: bytes = new byte[] { val }; break; case sbyte val: bytes = new byte[]...

  • Posted a comment on discussion What you would like to see in Snap7 on Snap7

    This code is used by me. class S7, add functions: public static class S7 ... public static byte[] GetBytes<T>(T value, bool reverse = false)//T = BYTE,WORD,SINGLE,ect...,ENUM { if (value == null) return new byte[0]; Type type; dynamic any; byte[] bytes; if (typeof(T).IsEnum) { type = Enum.GetUnderlyingType(typeof(T)); any = Convert.ChangeType(value, type); } else { type = typeof(T); any = value; } switch (any) { case byte val: bytes = new byte[] { val }; break; case sbyte val: bytes = new byte[]...

View All

Personal Data

Username:
mrhiden
Joined:
2018-03-16 13:47:52

Projects

  • No projects to display.

Personal Tools