function init() m.top.ObserveField("pucidHash", "onUpdatePucidHash") m.title = m.top.findNode("title") m.title.font.size=248 m.title.color="0x62C7FF18" title_font_size = 34 font_size = 32 m.updates = m.top.findNode("updates") m.updates.font.size=font_size m.updates.color="0x52C7F8FF" m.updates.lineSpacing = 8 m.updates_title = m.top.findNode("updates_title") m.updates_title.font.size=title_font_size m.updates_title.color="0x62E7FFFF" m.updates_title.text = "Launch Parameters" m.updates_lower = m.top.findNode("updates_lower") m.updates_lower.font.size=font_size m.updates_lower.color="0x52C7F8FF" m.updates_lower.text = "" m.updates_lower.lineSpacing = 8 m.updates_lower_title = m.top.findNode("updates_lower_title") m.updates_lower_title.font.size=title_font_size m.updates_lower_title.color="0x62E7FFFF" m.updates_lower_title.text = "Events" m.updates_right = m.top.findNode("updates_right") m.updates_right.font.size=font_size m.updates_right.color="0x52C7F8FF" m.updates_right.lineSpacing = 8 m.updates_right_title = m.top.findNode("updates_right_title") m.updates_right_title.font.size=title_font_size m.updates_right_title.color="0x62E7FFFF" m.updates_right_title.text = "Test Output (Press OK to run test)" m.title_color = "0x20204080" m.title_focus_color = "0x4060B0A0" m.tl_rect = m.top.findNode("updates_title_rect") m.tl_rect.color = m.title_color m.bl_rect = m.top.findNode("updates_lower_title_rect") m.bl_rect.color = m.title_color m.r_rect = m.top.findNode("updates_right_title_rect") m.r_rect.color = m.title_color label_color = "0x00002080" r = m.top.findNode("updates_rect") r.color = label_color r = m.top.findNode("updates_lower_rect") r.color = label_color r = m.top.findNode("updates_right_rect") r.color = label_color ' m.logger = CreateObject("roLogger") m.myTask = CreateObject("roSGNode", "MyTask") m.myTask.ObserveField("updateText", "onUpdateText") m.myTask.ObserveField("updateTextLower", "onUpdateTextLower") m.myTask.control = "RUN" m.testTask = CreateObject("roSGNode", "TestTask") m.testTask.ObserveField("updateText", "onUpdateTextRight") ' Note m.top.pucidHash is not set at this point, so we can't set it for testTask either. m.testTask.control = "RUN" texttimer = m.top.findNode("textTimer") texttimer.observeField("fire", "timerUpdate") texttimer.control = "start" m.rightLineCount = 100 m.rightVisibleLines = 21 m.rightTopVisibleLine = 0 m.updates_lower_array = CreateObject("roArray", 10, true) m.updates_right_array = CreateObject("roArray", m.rightLineCount, true) m.focus_rect = 1 m.prevLeftFocus = 0 doUpdateFocus() m.top.setFocus(true) end function function onUpdatePucidHash() as void m.testTask.setField("pucidHash", m.top.pucidHash) end function function onUpdateText() as void if m.updates.text.Len() = 0 m.updates.text = m.myTask.updateText else m.updates.text = m.updates.text + chr(10) + m.myTask.updateText end if print m.myTask.updateText ' m.logger.logConsole("upperleft", [m.myTask.updateText]) end function function onUpdateTextLower() as void updateTextLower(m.myTask.updateTextLower) end function function updateTextLower(s as String) as void while m.updates_lower_array.Count() > 9 m.updates_lower_array.Shift() end while m.updates_lower_array.Push(s) m.updates_lower.text = m.updates_lower_array.Join(chr(10)) print s ' m.logger.logConsole("lowerleft", [s]) end function function showTextRight() as void visibleWindow = [] max = m.updates_right_array.Count() - m.rightTopVisibleLine if max > m.rightVisibleLines then max = m.rightVisibleLines end if for i = 0 to max - 1 visibleWindow.Push(m.updates_right_array[m.rightTopVisibleLine + i]) end for m.updates_right.text = visibleWindow.Join(chr(10)) end function function onUpdateTextRight() as void while m.updates_right_array.Count() > m.rightLineCount - 1 m.updates_right_array.Shift() end while m.updates_right_array.Push(m.testTask.updateText) ' Jump visible window to bottom m.rightTopVisibleLine = m.updates_right_array.Count() - m.rightVisibleLines if m.rightTopVisibleLine < 0 then m.rightTopVisibleLine = 0 end if showTextRight() print m.testTask.updateText ' m.logger.logConsole("right", [m.testTask.updateText]) end function function onKeyEvent(key as String, press as Boolean) as Boolean handled = false if press then if key = "back" then handled = false else update_ui = false if key = "OK" and m.focus_rect = 1 m.testTask.control = "RUN" elseif key = "up" if m.focus_rect = 3 m.focus_rect = 0 update_ui = true elseif m.focus_rect = 1 if m.rightTopVisibleLine > 0 m.rightTopVisibleLine = m.rightTopVisibleLine - 1 showTextRight() endif endif elseif key = "right" if m.focus_rect = 0 m.prevLeftFocus = 0 m.focus_rect = 1 update_ui = true elseif m.focus_rect = 3 m.prevLeftFocus = 3 m.focus_rect = 1 update_ui = true endif elseif key = "down" if m.focus_rect = 0 m.focus_rect = 3 update_ui = true elseif m.focus_rect = 1 if m.rightTopVisibleLine < m.updates_right_array.Count() - 1 m.rightTopVisibleLine = m.rightTopVisibleLine + 1 showTextRight() endif endif elseif key = "left" if m.focus_rect = 1: m.focus_rect = m.prevLeftFocus update_ui = true endif end if if update_ui doUpdateFocus() endif dt = Mid(CreateObject("roDateTime").ToISOString(), 12, 8) updateTextLower(dt + " " + key) handled = true end if end if return handled end function sub doUpdateFocus() if m.focus_rect = 0 m.tl_rect.color = m.title_focus_color m.bl_rect.color = m.title_color m.r_rect.color = m.title_color elseif m.focus_rect = 1 or m.focus_rect = 2 m.tl_rect.color = m.title_color m.bl_rect.color = m.title_color m.r_rect.color = m.title_focus_color elseif m.focus_rect = 3 m.tl_rect.color = m.title_color m.bl_rect.color = m.title_focus_color m.r_rect.color = m.title_color end if end sub sub timerUpdate() ' Not needed, but nice to have as an example. ' print "timerUpdate called." end sub