Controls if HMI input signals are transmitted to JavaScript in real-time or latched.
Controls if HMI input signals are transmitted to JavaScript in real-time or latched.
Visual Basic |
---|
Public Property hmi_enable_input_clock As Boolean |
With WebKitX you can create HMI Dash Boards by forwarding sensor data to HTML and JavaScript for rendering. The input signals are latched and the clock frequency is controlled by Settings.hmi_input_clock_frequency_hz which defaults to 2Hz. This means that input signal values are buffered by WebKitX and are flushed to HTML/JavaScript every 500 milliseconds. If no input signals are registered since last flush then no emission takes place. You can disable the input latch and pass the input signal values at real-time by setting the Settings.hmi_enable_input_clock to False.
Option Explicit Private Sub Form_Resize() On Error Resume Next WebKitX1.Move 0, 0, ScaleWidth, ScaleHeight Err.Clear End Sub Private Sub Form_Load() ' Load Human Machine Interface markup WebKitX1.HMI_URL = "file:///" + App.Path + "/index.html" End Sub Private Sub WebKitX1_OnCreate(ByVal Settings As WebKitXCEF3Lib.ISettings, CommandLineSwitches As String) ' Set WebKitX HMI values to flush/refresh at rate 1Hz (every 1sec). Settings.hmi_enable_input_clock = True Settings.hmi_input_clock_frequency_hz = 1 End Sub Private Sub WebKitX1_OnPageComplete(ByVal url As String) ' We use a timer at 60Hz to simulate high-frequency sensors. Timer1.Interval = (1000 / 60) Timer1.Enabled = True End Sub Private Sub Timer1_Timer() ' We read values from "sensors" and pass them to six (6) different HMI I/O channels. ' We read sensor values 60 times per second (every ~16ms). WebKitX uses input latches ' to retain input values and flush them to HTML at a rate of 1Hz (every 1sec). WebKitX1.HMI_VALUE_001 = Rnd * 1560 WebKitX1.HMI_VALUE_002 = Rnd * 1560 WebKitX1.HMI_VALUE_003 = Rnd * 1560 WebKitX1.HMI_VALUE_004 = Rnd * 1560 WebKitX1.HMI_VALUE_005 = Rnd * 1560 WebKitX1.HMI_VALUE_006 = Rnd * 1560 End Sub Private Sub WebKitX1_OnHMIControlSignal(ByVal Index As Long, ByVal Data As String) Debug.Print Format(Time, "HH:MM:SS") & " > HMI_VALUE_" & Format(Index, "000") & " = " & Data End Sub