mobileFX WebKitX CEF3 ActiveX 4.x
WebKitXCEF3Lib ActiveX Control / Settings Object / hmi_input_clock_frequency_hz Property
In This Topic
    hmi_input_clock_frequency_hz Property
    In This Topic

    HMI input signals latch frequency in Hz.

    Property type
    Read-write property
    Visual Basic
    Public Property hmi_input_clock_frequency_hz As Double

    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.

    It is important to understand that input signals travel over Interprocess Communication (IPC) from the ActiveX to Chromium Engine which are the processed by JavaScript and eventually alter the DOM of the HTML HMI user interface. This is a time-consuming process and therefore you must limit the hmi_input_clock_frequency between 0.1 Hz and 60 Hz. The upper limit of 60 Hz is equivalent to screen refresh rate of 60 fps (frames per second) or screen refresh every 16.7 milliseconds. Even though Chromium supports 60 fps rendering for Hardware Accelerated Graphics (WebGL), you should not push beyond 60 Hz. 

    Option Explicit
    Private Sub Form_Resize()
        On Error Resume Next
        WebKitX1.Move 0, 0, ScaleWidth, ScaleHeight
    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
    See Also