Jump to content

Search the Community

Showing results for tags 'message loop'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. Dear all (and especially Martin, if available), I am working on a GUI that reads the signals from a gas flow meter (ProFLow 6000, by Restek). In the manual of the device, there are the instructions for how to read the signal using a computer via comm ports. I can do it using the CommMG.au3 UDF by Martin, it works fine. However, I am trying to make a GUI in which there are 2 buttons: start and stop, the start button starts the reading of the comm port signal, and the stop button stops it. I did this following the tutorial available on https://www.autoitscript.com/wiki/Interrupting_a_running_function , more specifically the first example for GUI message loop mode that employs GUIRegisterMsg as a way to enable a function to stop another. It works, the start function is stopped by the stop button. However, if I try to start again, it does not work. I press the start button and nothing happens. I must say that this only happens if I use a function to read the comm port. For other kinds of functions, for example, reading the computer clock, there is no problem, after stopping I can re-start again. My question is: how to make it possible to re-start the reading function for the Comm port once it was stopped using the GUIRegisterMsg? Below goes my code (sorry, it is my first time and I am not sure of the best way of pasting it here). If includes also the clock button that can be used to test the stopping process (it should work). #include "commMG.au3" #include <GUIConstantsEx.au3> #include <ColorConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Local $FlowMeterPort Local $PortError $Interrupt_flag = 0 $FlowMeter = GUICreate("Flow meter reader", 200, 160, 500, 200) $Reading = GUICtrlCreateLabel("",20,40,120,18) GUICtrlSetBkColor($Reading,$COLOR_WHITE) $Start = GUICtrlCreateButton("Start", 20, 60, 50, 20) $Stop = GUICtrlCreateButton("Stop", 20, 80, 50, 20) $Clock = GUICtrlCreateButton("Clock", 20, 100, 50, 20) $FlowMeterPort = InputBox("Flow meter reader","Welcome to the flow meter reader! Please type in the number of the COM port connecting the computer to the flow meter. If you do not know, go to Control Panel, Hardware settings, and try to find it among the listed COM ports.") GUISetState() GUIRegisterMsg($WM_COMMAND, "FlowMeter_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Start _CommSetPort($FlowMeterPort, $PortError, 115200, 8, 0, 1, 2) $Interrupt_flag = 0 While $Interrupt_flag = 0 $FlowMeterReading = _CommReadString(100) GUICtrlSetData($Reading,$FlowMeterReading) WEnd Case $Clock $Interrupt_flag = 0 While $Interrupt_flag = 0 GUICtrlSetData($Reading,@HOUR & @MIN & @SEC) WEnd EndSwitch WEnd Func FlowMeter_WM_COMMAND($hWnd, $Msg, $wParam, $lParam) If BitAND($wParam, 0x0000FFFF) = $Stop Then $Interrupt_flag = 1 EndFunc Func _CommReadString($TimeSpan) Local $Reading $Start = TimerInit() $End = 0 $ReadStep = 0 While $End < $TimeSpan $Reading = $Reading & _Commgetstring() $End = TimerDiff($Start) If $Reading <> '' Then $ReadStep = $ReadStep + 1 EndIf If $ReadStep > 100 Then $End = $TimeSpan Sleep(0) WEnd Return $Reading EndFunc ;==>_CommReadString
×
×
  • Create New...