ModSimEx.frm 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. VERSION 4.00
  2. Begin VB.Form Form1
  3. Caption = "Form1"
  4. ClientHeight = 3150
  5. ClientLeft = 3255
  6. ClientTop = 2910
  7. ClientWidth = 5130
  8. Height = 3555
  9. Left = 3195
  10. LinkTopic = "Form1"
  11. ScaleHeight = 3150
  12. ScaleWidth = 5130
  13. Top = 2565
  14. Width = 5250
  15. Begin VB.TextBox Text2
  16. Height = 285
  17. Left = 3360
  18. TabIndex = 3
  19. Text = "Text2"
  20. Top = 240
  21. Width = 495
  22. End
  23. Begin VB.TextBox Text1
  24. Height = 285
  25. Left = 3360
  26. TabIndex = 2
  27. Text = "Text1"
  28. Top = 600
  29. Width = 855
  30. End
  31. Begin VB.Timer Timer1
  32. Interval = 1000
  33. Left = 1200
  34. Top = 1680
  35. End
  36. Begin VB.Label Label8
  37. Caption = "Text1.text = temp"
  38. Height = 255
  39. Left = 1920
  40. TabIndex = 9
  41. Top = 2160
  42. Width = 2655
  43. End
  44. Begin VB.Label Label7
  45. Caption = "ModSim32.ReadPoint (1, 40100, temp)"
  46. Height = 255
  47. Left = 1920
  48. TabIndex = 8
  49. Top = 1920
  50. Width = 2775
  51. End
  52. Begin VB.Label Label6
  53. Caption = "tick = tick + 1"
  54. Height = 255
  55. Left = 1920
  56. TabIndex = 7
  57. Top = 1680
  58. Width = 2775
  59. End
  60. Begin VB.Label Label5
  61. Caption = "ModSim32.WritePoint (1, 40100, tick)"
  62. Height = 255
  63. Left = 1920
  64. TabIndex = 6
  65. Top = 1440
  66. Width = 3015
  67. End
  68. Begin VB.Label Label4
  69. Caption = "(Each Second)"
  70. Height = 255
  71. Left = 600
  72. TabIndex = 5
  73. Top = 1440
  74. Width = 1095
  75. End
  76. Begin VB.Label Label3
  77. Caption = "Timer Operation:"
  78. Height = 255
  79. Left = 480
  80. TabIndex = 4
  81. Top = 1200
  82. Width = 1215
  83. End
  84. Begin VB.Label Label2
  85. Caption = "Modbus Node Address"
  86. Height = 255
  87. Left = 1560
  88. TabIndex = 1
  89. Top = 240
  90. Width = 1695
  91. End
  92. Begin VB.Label Label1
  93. Caption = "40100"
  94. Height = 255
  95. Left = 2640
  96. TabIndex = 0
  97. Top = 600
  98. Width = 615
  99. End
  100. End
  101. Attribute VB_Name = "Form1"
  102. Attribute VB_Creatable = False
  103. Attribute VB_Exposed = False
  104. Public m_sim As IModSim
  105. Dim tick As Integer
  106. Dim device As Integer
  107. Dim address As Long
  108. Private Sub Form_Load()
  109. Set m_sim = CreateObject("ModSim32.Document")
  110. tick = 0
  111. device = 1
  112. address = 40100
  113. Label1.Caption = address
  114. Text2.Text = device
  115. End Sub
  116. Private Sub Timer1_Timer()
  117. Dim status As Integer
  118. Dim temp As Integer
  119. status = m_sim.WritePoint(device, address, tick)
  120. If status = 0 Then
  121. tick = tick + 1
  122. End If
  123. status = m_sim.ReadPoint(device, address, temp)
  124. If status = 0 Then
  125. Text1.Text = temp
  126. End If
  127. End Sub