PUSH BUTTON TO SEND TX MESSAGES CONTINUOUSLY
I am new to this tool, and I am trying to create a simple gui. In the instrument panel, when a button is pushed, I want to mimic what the TransmitMessage object does. Send the message every 100msec. The ValueEdit controller is able to pull all my signals from our custom symbol files that decodes the bytes into legible signals and values.
1. I have a button called Drive Mode, and its execute command property is set to btn_DriveMode_Click() (this is the sub in the vbscript that gets called on button press)
The code below blinks the LED, but does not send anything. The PCAN Explorer windows, specifically Transmit, if I check the tickbox for cycle time, it sends it repeatedly 100msec. I want to replicate that with the push of a button. When button STOP is pressed, we stop sending messages. When a different button is pressed, a different message is send continuously. The idea is press buttons and send different messages depending on which button was pressed, pressing stops, stops sending the messages.
Any idea how I can do this programmatically?
In VBscript I have started with, it does nothing other than enable an LED in Flashmode by setting its threshold greater than 5. Also, I don't know the proper way to access the controls/LED/indicators from VBscript. Sometimes I see examples using the "Signals()" command, and when I try it, the tools complains. So I am not yet clear how to access GUI objects properties etc..
Code: Select all
Sub btn_DriveMode_Click() 'Dim ObjPanel, ObjLED, ObjCtrl, SigLED, SigCtrl Dim i, SigStop, msg, TxVal 'Get the objects on the panel Set ObjPanel = Documents("TESTPANEL.ipf").ActiveWindow.Object 'Selects the active Panel Set ObjLED = ObjPanel.ActiveScene.Controls("led_DriveMode") 'Selects the LED Indicator Set ObjCtrl(0) = ObjPanel.ActiveScene.Controls("ctrl_BMS_State") 'Selects the control ctrl_BMS_State Set SigLED = Signals("LED_DM") 'Selects the Signal Name for the LED Indicator Set SigCtrl = Signals("distributed_60B1.cmd_state.cmd_00_state_trans") 'Selects the Signal in the controller Set SigStop = Signals("Stop") SigStop.Value = 0 'Set the LED threshold, flashing value, and value to greater than 5 for blinking LED ObjLED.threshold = 5 ObjLED.Flashing = True SigLED.Value = 10 ObjCtrl.CycleTime = 100 Set TxVal = Signals("TransmitValue") 'Created a sym file with ID, Len, CycleTime=100, and Var=TransmitValue unsigned 0,8 /max:254 'WaNT TO SEND THE MESSAGE 5 times i = 0 while (i < 5) or (SigStop.Value > 0) TxVal = "BMS_STATE_STANDBY" i = i + 1 wait(100) wend End Sub