Indexer.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using System;
  2. namespace libmodbussharp
  3. {
  4. public class RegistersInputSigned {
  5. ModbusCore core = null;
  6. internal RegistersInputSigned (ModbusCore core) {
  7. this.core = core;
  8. }
  9. public Int16 this [int indexer] {
  10. get {
  11. return core.GetRegisterInputSigned(indexer);
  12. }
  13. set {
  14. core.SetRegisterInput(indexer, value);
  15. }
  16. }
  17. }
  18. public class RegistersInputUnsigned {
  19. ModbusCore core = null;
  20. internal RegistersInputUnsigned (ModbusCore core) {
  21. this.core = core;
  22. }
  23. public UInt16 this [int indexer] {
  24. get {
  25. return core.GetRegisterInputUnsigned(indexer);
  26. }
  27. set {
  28. core.SetRegisterInput(indexer, value);
  29. }
  30. }
  31. }
  32. public class RegistersRWSigned {
  33. ModbusCore core = null;
  34. internal RegistersRWSigned (ModbusCore core) {
  35. this.core = core;
  36. }
  37. public Int16 this [int indexer] {
  38. get {
  39. return core.GetRegisterRWSigned(indexer);
  40. }
  41. set {
  42. core.SetRegisterRW(indexer, value);
  43. }
  44. }
  45. }
  46. public class RegistersRWUnsigned {
  47. ModbusCore core = null;
  48. internal RegistersRWUnsigned (ModbusCore core) {
  49. this.core = core;
  50. }
  51. public UInt16 this [int indexer] {
  52. get {
  53. return core.GetRegisterRWUnsigned(indexer);
  54. }
  55. set {
  56. core.SetRegisterRW(indexer, value);
  57. }
  58. }
  59. }
  60. public class BitsRW {
  61. ModbusCore core = null;
  62. internal BitsRW (ModbusCore core) {
  63. this.core = core;
  64. }
  65. public bool this [int indexer] {
  66. get {
  67. return core.GetBitsRW(indexer);
  68. }
  69. set {
  70. core.SetBitsRW (indexer, value);
  71. }
  72. }
  73. }
  74. public class BitsInput {
  75. ModbusCore core = null;
  76. internal BitsInput (ModbusCore core) {
  77. this.core = core;
  78. }
  79. public bool this [int indexer] {
  80. get {
  81. return core.GetBitsInput(indexer);
  82. }
  83. set {
  84. core.SetBitsInput (indexer, value);
  85. }
  86. }
  87. }
  88. }