#tag Window Begin Window Window1 BackColor = &hFFFFFF Backdrop = "" CloseButton = True Composite = False Frame = 0 FullScreen = False HasBackColor = False Height = 394 ImplicitInstance= True LiveResize = True MacProcID = 0 MaxHeight = 32000 MaximizeButton = False MaxWidth = 32000 MenuBar = 838682623 MenuBarVisible = True MinHeight = 64 MinimizeButton = True MinWidth = 64 Placement = 0 Resizeable = False Title = "Untitled" Visible = True Width = 536 Begin PushButton PushButton1 AutoDeactivate = True Bold = "" Cancel = "" Caption = "LANC On" Default = "" Enabled = True Height = 22 HelpTag = "" Index = 2147483648 InitialParent = "" Italic = "" Left = 241 LockBottom = "" LockedInPosition= False LockLeft = "" LockRight = "" LockTop = "" Scope = 0 TabIndex = 1 TabPanelIndex = 0 TabStop = True TextFont = "System" TextSize = 0 Top = 13 Underline = "" Visible = True Width = 120 BehaviorIndex = 0 End Begin PushButton PushButton2 AutoDeactivate = True Bold = "" Cancel = "" Caption = "LANC Off" Default = "" Enabled = True Height = 22 HelpTag = "" Index = 2147483648 InitialParent = "" Italic = "" Left = 241 LockBottom = "" LockedInPosition= False LockLeft = "" LockRight = "" LockTop = "" Scope = 0 TabIndex = 2 TabPanelIndex = 0 TabStop = True TextFont = "System" TextSize = 0 Top = 47 Underline = "" Visible = True Width = 120 BehaviorIndex = 1 End Begin PushButton PushButton3 AutoDeactivate = True Bold = "" Cancel = "" Caption = "Power On" Default = "" Enabled = True Height = 22 HelpTag = "" Index = 2147483648 InitialParent = "" Italic = "" Left = 396 LockBottom = "" LockedInPosition= False LockLeft = "" LockRight = "" LockTop = "" Scope = 0 TabIndex = 3 TabPanelIndex = 0 TabStop = True TextFont = "System" TextSize = 0 Top = 13 Underline = "" Visible = True Width = 120 BehaviorIndex = 2 End Begin PushButton PushButton4 AutoDeactivate = True Bold = "" Cancel = "" Caption = "Power Off" Default = "" Enabled = True Height = 22 HelpTag = "" Index = 2147483648 InitialParent = "" Italic = "" Left = 396 LockBottom = "" LockedInPosition= False LockLeft = "" LockRight = "" LockTop = "" Scope = 0 TabIndex = 4 TabPanelIndex = 0 TabStop = True TextFont = "System" TextSize = 0 Top = 47 Underline = "" Visible = True Width = 120 BehaviorIndex = 3 End Begin Serial Serial1 Baud = 8 Bits = 3 CTS = "" DTR = "" Height = 32 Index = 2147483648 InitialParent = "" Left = 483 LockedInPosition= False Parity = 0 Scope = 0 Stop = 0 TabPanelIndex = 0 Top = 225 Width = 32 XON = "" BehaviorIndex = 4 End Begin EditField EditField1 AcceptTabs = "" Alignment = 0 AutoDeactivate = True BackColor = &hFFFFFF Bold = "" Border = True DataField = "" DataSource = "" Enabled = True Format = "" Height = 105 HelpTag = "" Index = 2147483648 InitialParent = "" Italic = "" Left = 19 LimitText = 0 LockBottom = "" LockedInPosition= False LockLeft = "" LockRight = "" LockTop = "" Mask = "" Multiline = True Password = "" ReadOnly = "" Scope = 0 ScrollbarHorizontal= "" ScrollbarVertical= True Styled = "" TabIndex = 5 TabPanelIndex = 0 TabStop = True Text = "" TextColor = &h000000 TextFont = "System" TextSize = 0 Top = 269 Underline = "" UseFocusRing = True Visible = True Width = 496 BehaviorIndex = 5 End Begin PushButton PushButton5 AutoDeactivate = True Bold = "" Cancel = "" Caption = "Get Prompt" Default = "" Enabled = True Height = 22 HelpTag = "" Index = 2147483648 InitialParent = "" Italic = "" Left = 396 LockBottom = "" LockedInPosition= False LockLeft = "" LockRight = "" LockTop = "" Scope = 0 TabIndex = 6 TabPanelIndex = 0 TabStop = True TextFont = "System" TextSize = 0 Top = 81 Underline = "" Visible = True Width = 120 BehaviorIndex = 6 End Begin PushButton PushButton6 AutoDeactivate = True Bold = "" Cancel = "" Caption = "AT?" Default = "" Enabled = True Height = 22 HelpTag = "" Index = 2147483648 InitialParent = "" Italic = "" Left = 396 LockBottom = "" LockedInPosition= False LockLeft = "" LockRight = "" LockTop = "" Scope = 0 TabIndex = 7 TabPanelIndex = 0 TabStop = True TextFont = "System" TextSize = 0 Top = 115 Underline = "" Visible = True Width = 120 BehaviorIndex = 7 End Begin PushButton PushButton7 AutoDeactivate = True Bold = "" Cancel = "" Caption = "Tick Age" Default = "" Enabled = True Height = 22 HelpTag = "" Index = 2147483648 InitialParent = "" Italic = "" Left = 396 LockBottom = "" LockedInPosition= False LockLeft = "" LockRight = "" LockTop = "" Scope = 0 TabIndex = 8 TabPanelIndex = 0 TabStop = True TextFont = "System" TextSize = 0 Top = 149 Underline = "" Visible = True Width = 120 BehaviorIndex = 8 End Begin Timer Timer1 Height = 32 Index = 2147483648 Left = 440 LockedInPosition= False Mode = 2 Period = 1000 Scope = 0 TabPanelIndex = 0 Top = 225 Width = 32 BehaviorIndex = 9 End Begin EditField EditField2 AcceptTabs = "" Alignment = 0 AutoDeactivate = True BackColor = &hFFFFFF Bold = "" Border = True DataField = "" DataSource = "" Enabled = True Format = "" Height = 23 HelpTag = "" Index = 2147483648 InitialParent = "" Italic = "" Left = 62 LimitText = 0 LockBottom = "" LockedInPosition= False LockLeft = "" LockRight = "" LockTop = "" Mask = "" Multiline = "" Password = "" ReadOnly = "" Scope = 0 ScrollbarHorizontal= "" ScrollbarVertical= True Styled = "" TabIndex = 9 TabPanelIndex = 0 TabStop = True Text = "" TextColor = &h000000 TextFont = "System" TextSize = 0 Top = 231 Underline = "" UseFocusRing = True Visible = True Width = 117 BehaviorIndex = 10 End Begin StaticText StaticText1 AutoDeactivate = True Bold = "" DataField = "" DataSource = "" Enabled = True Height = 17 HelpTag = "" Index = 2147483648 InitialParent = "" Italic = "" Left = 19 LockBottom = "" LockedInPosition= False LockLeft = "" LockRight = "" LockTop = "" Multiline = "" Scope = 0 TabIndex = 10 TabPanelIndex = 0 Text = "Shorty" TextAlign = 0 TextColor = &h000000 TextFont = "System" TextSize = 0 Top = 233 Underline = "" Visible = True Width = 32 BehaviorIndex = 11 End Begin PushButton PushButton8 AutoDeactivate = True Bold = "" Cancel = "" Caption = "menu" Default = "" Enabled = True Height = 22 HelpTag = "" Index = 2147483648 InitialParent = "" Italic = "" Left = 241 LockBottom = "" LockedInPosition= False LockLeft = "" LockRight = "" LockTop = "" Scope = 0 TabIndex = 11 TabPanelIndex = 0 TabStop = True TextFont = "System" TextSize = 0 Top = 81 Underline = "" Visible = True Width = 120 BehaviorIndex = 12 End Begin PushButton PushButton9 AutoDeactivate = True Bold = "" Cancel = "" Caption = "execute" Default = "" Enabled = True Height = 22 HelpTag = "" Index = 2147483648 InitialParent = "" Italic = "" Left = 81 LockBottom = "" LockedInPosition= False LockLeft = "" LockRight = "" LockTop = "" Scope = 0 TabIndex = 12 TabPanelIndex = 0 TabStop = True TextFont = "System" TextSize = 0 Top = 115 Underline = "" Visible = True Width = 50 BehaviorIndex = 13 End Begin PushButton PushButton10 AutoDeactivate = True Bold = "" Cancel = "" Caption = "up" Default = "" Enabled = True Height = 22 HelpTag = "" Index = 2147483648 InitialParent = "" Italic = "" Left = 81 LockBottom = "" LockedInPosition= False LockLeft = "" LockRight = "" LockTop = "" Scope = 0 TabIndex = 13 TabPanelIndex = 0 TabStop = True TextFont = "System" TextSize = 0 Top = 81 Underline = "" Visible = True Width = 50 BehaviorIndex = 14 End Begin PushButton PushButton11 AutoDeactivate = True Bold = "" Cancel = "" Caption = "down" Default = "" Enabled = True Height = 22 HelpTag = "" Index = 2147483648 InitialParent = "" Italic = "" Left = 81 LockBottom = "" LockedInPosition= False LockLeft = "" LockRight = "" LockTop = "" Scope = 0 TabIndex = 14 TabPanelIndex = 0 TabStop = True TextFont = "System" TextSize = 0 Top = 149 Underline = "" Visible = True Width = 50 BehaviorIndex = 15 End Begin PushButton PushButton12 AutoDeactivate = True Bold = "" Cancel = "" Caption = "left" Default = "" Enabled = True Height = 22 HelpTag = "" Index = 2147483648 InitialParent = "" Italic = "" Left = 19 LockBottom = "" LockedInPosition= False LockLeft = "" LockRight = "" LockTop = "" Scope = 0 TabIndex = 15 TabPanelIndex = 0 TabStop = True TextFont = "System" TextSize = 0 Top = 115 Underline = "" Visible = True Width = 50 BehaviorIndex = 16 End Begin PushButton PushButton13 AutoDeactivate = True Bold = "" Cancel = "" Caption = "right" Default = "" Enabled = True Height = 22 HelpTag = "" Index = 2147483648 InitialParent = "" Italic = "" Left = 143 LockBottom = "" LockedInPosition= False LockLeft = "" LockRight = "" LockTop = "" Scope = 0 TabIndex = 16 TabPanelIndex = 0 TabStop = True TextFont = "System" TextSize = 0 Top = 115 Underline = "" Visible = True Width = 50 BehaviorIndex = 17 End End #tag EndWindow #tag WindowCode #tag Event Sub Open() Dim s as String Dim d as Double Dim i as Integer EditField1.Text = "" if getConfigString("port", s, "COM1") then EditField1.AppendText "found port: " + s else EditField1.AppendText "didn't find port, using default: " + s end if EditField1.AppendText Chr(13) + Chr(10) if getConfigDouble("double", d, 0.0) then EditField1.AppendText "found double: " + Str(d) else EditField1.AppendText "didn't find double, using default: " + Str(d) end if EditField1.AppendText Chr(13) + Chr(10) if getConfigInteger("integer", i, 0) then EditField1.AppendText "found integer: " + Str(i) else EditField1.AppendText "didn't find integer, using default: " + Str(i) end if EditField1.AppendText Chr(13) + Chr(10) 'init serial port Serial1.SerialPort = System.SerialPort(s) if not Serial1.Open then MsgBox "Couldn't open the device: " + s + " Err " + Str( Serial1.LastErrorCode ) else try EditField1.AppendText "Successfully opened port: " + Serial1.SerialPort.Name catch err as NilObjectException EditField1.AppendText "Serial1.SerialPort.Name is Nil" End Try end if End Sub #tag EndEvent #tag Method, Flags = &h0 Sub Delay(cnt as Integer) Dim i as integer i = Ticks() 'now do If Ticks() - i > cnt then Exit End If Loop End Sub #tag EndMethod #tag Method, Flags = &h0 Sub GetPrompt() 'Send a single CR to grab the console back Serial1.Write Chr(13) 'Wait for the CR to go out Serial1.XmitWait 'Delay 10 ticks Delay(10) End Sub #tag EndMethod #tag Method, Flags = &h0 Function GetLancTickAge() As Integer return (Ticks - lancTickCount) End Function #tag EndMethod #tag Property, Flags = &h0 lancTickCount As Integer = 0 #tag EndProperty #tag Property, Flags = &h0 ShortyCount As Integer = 0 #tag EndProperty #tag EndWindowCode #tag Events PushButton1 #tag Event Sub Action() Serial1.Write Chr(12) End Sub #tag EndEvent #tag EndEvents #tag Events PushButton2 #tag Event Sub Action() Serial1.Write Chr(24) End Sub #tag EndEvent #tag EndEvents #tag Events PushButton3 #tag Event Sub Action() 'Grab the prompt GetPrompt() 'Send the short pulse command Serial1.Write "ATSP" + Chr(13) 'Wait for the cmd to go out Serial1.XmitWait End Sub #tag EndEvent #tag EndEvents #tag Events PushButton4 #tag Event Sub Action() 'Grab the prompt GetPrompt() 'Send the power off command Serial1.Write "105E" + Chr(13) 'Wait for the cmd to go out Serial1.XmitWait End Sub #tag EndEvent #tag EndEvents #tag Events Serial1 #tag Event Sub DataAvailable() Static result As String = "" Static reply As String = "" 'Wait for any pending chars to xmit 'Serial1.XmitWait 'result = Serial1.ReadAll 'EditField1.AppendText result EditField1.Text = "" While Serial1.BytesAvailable > 0 result = Serial1.Read(1) If result = Chr(10) Then 'EditField1.AppendText "******" + Chr(13) + Chr(10) If Len(reply) <> 8 Then ShortyCount = ShortyCount + 1 EditField2.Text = reply + "(" + Str(ShortyCount) + ")" End If EditField1.AppendText reply + Chr(13) + Chr(10) reply = "" 'EditField1.AppendText reply Else If result <> Chr(13) Then reply = reply + result End If End If Wend 'Time stamp it lancTickCount = Ticks End Sub #tag EndEvent #tag EndEvents #tag Events PushButton5 #tag Event Sub Action() 'Send a single CR to grab the console back Serial1.Write Chr(13) 'Wait for the CR to go out Serial1.XmitWait 'Delay 10 ticks Delay(10) End Sub #tag EndEvent #tag EndEvents #tag Events PushButton6 #tag Event Sub Action() 'Grab the prompt GetPrompt() 'Send the power off command Serial1.Write "AT?" + Chr(13) 'Wait for the cmd to go out Serial1.XmitWait End Sub #tag EndEvent #tag EndEvents #tag Events PushButton7 #tag Event Sub Action() MsgBox "Last LANC msg was received " + Str(GetLancTickAge) + " ticks ago." End Sub #tag EndEvent #tag EndEvents #tag Events PushButton8 #tag Event Sub Action() 'Grab the prompt GetPrompt() 'Send the menu command Serial1.Write "109A" + Chr(13) 'Wait for the cmd to go out Serial1.XmitWait End Sub #tag EndEvent #tag EndEvents #tag Events PushButton9 #tag Event Sub Action() 'Grab the prompt GetPrompt() 'Send the menu command Serial1.Write "10A2" + Chr(13) 'Wait for the cmd to go out Serial1.XmitWait End Sub #tag EndEvent #tag EndEvents #tag Events PushButton10 #tag Event Sub Action() 'Grab the prompt GetPrompt() 'Send the menu up Serial1.Write "1084" + Chr(13) 'Wait for the cmd to go out Serial1.XmitWait End Sub #tag EndEvent #tag EndEvents #tag Events PushButton11 #tag Event Sub Action() 'Grab the prompt GetPrompt() 'Send the menu down Serial1.Write "1086" + Chr(13) 'Wait for the cmd to go out Serial1.XmitWait End Sub #tag EndEvent #tag EndEvents #tag Events PushButton12 #tag Event Sub Action() 'Grab the prompt GetPrompt() 'Send the menu left Serial1.Write "10C4" + Chr(13) 'Wait for the cmd to go out Serial1.XmitWait End Sub #tag EndEvent #tag EndEvents #tag Events PushButton13 #tag Event Sub Action() 'Grab the prompt GetPrompt() 'Send the menu right Serial1.Write "10C2" + Chr(13) 'Wait for the cmd to go out Serial1.XmitWait End Sub #tag EndEvent #tag EndEvents