0a6f57c2716089f84e783498fe1e8384e5a66d9b
David Blume first commit

David Blume authored 4 years ago

1) sub init()
2)     m.top.functionName = "executeTask"
3) end sub
4) 
David Blume Add some invariant info to...

David Blume authored 4 years ago

5) function getDeviceInfo(deviceInfo as object) as Object
6)     ' Try to get various info from an ECP call
7)     aa = {}
David Blume first commit

David Blume authored 4 years ago

8)     request = CreateObject("roUrlTransfer")
9)     request.SetUrl("http://localhost:8060/query/device-info")
10)     root = CreateObject("roXMLElement")
11)     if root.Parse(request.GetToString()) then
David Blume Add some invariant info to...

David Blume authored 4 years ago

12)         elements = root.GetNamedElements("serial-number")
13)         if elements.Count() > 0
14)             aa["serial number"] = elements[0].GetText()
David Blume first commit

David Blume authored 4 years ago

15)         end if
David Blume Add some invariant info to...

David Blume authored 4 years ago

16)         elements = root.GetNamedElements("device-id")
17)         if elements.Count() > 0
18)             aa["device ID"] = elements[0].GetText()
19)         end if
20)         elements = root.GetNamedElements("model-number")
21)         if elements.Count() > 0
22)             aa.["model"] = elements[0].GetText()
23)         end if
24)         elements = root.GetNamedElements("build-number")
25)         if elements.Count() > 0
David Blume Add an easier-to-read versi...

David Blume authored 4 years ago

26)             fv =  elements[0].GetText()
27)             elements = root.GetNamedElements("software-version")
28)             if elements.Count() > 0
29)                 aa.["firmware version"] = fv + " (" + elements[0].GetText() + " " + mid(fv, 9, 4) + ")"
30)             else
31)                 aa.["firmware version"] = fv
32)             end if
David Blume Add some invariant info to...

David Blume authored 4 years ago

33)         end if
34)         return aa
David Blume first commit

David Blume authored 4 years ago

35)     end if
36)     ' That did not work, so make a custom one.
37)     clientID = Right(deviceInfo.GetChannelClientId(), 6)
38)     modelID = deviceInfo.GetModel()
David Blume Add some invariant info to...

David Blume authored 4 years ago

39)     return { "client ID": clientID, "model": modelID }
David Blume first commit

David Blume authored 4 years ago

40) end function
41) 
42) function executeTask() as void
43) 
44)     am = CreateObject("roAppManager")
45)     aaRunParams = am.GetRunParams()
46)     for each key in aaRunParams
47)         val = aaRunParams[key]
48)         m.top.updateText = key + " = " + val.ToStr()
David Blume Fix static analysis problem...

David Blume authored 4 years ago

49)     end for
David Blume Add some invariant info to...

David Blume authored 4 years ago

50)     ' m.top.updateText = "devID " + CreateObject("roAppInfo").GetDevID()
David Blume first commit

David Blume authored 4 years ago

51) 
52)     deviceInfo = CreateObject("roDeviceInfo")
David Blume Add some invariant info to...

David Blume authored 4 years ago

53)     infoaa = getDeviceInfo(deviceInfo)
54)     if infoaa <> invalid:
55)         for each key in infoaa
56)             val = infoaa[key]
57)             m.top.updateText = key + " = " + val.ToStr()
David Blume Fix static analysis problem...

David Blume authored 4 years ago

58)         end for
David Blume Add some invariant info to...

David Blume authored 4 years ago

59)     else
60)         m.top.updateText = "(Could not get device info.)"
61)     end if
David Blume first commit

David Blume authored 4 years ago

62)     port = CreateObject("roMessagePort")
63)     deviceInfo.SetMessagePort(port)
David Blume Fix static analysis problem...

David Blume authored 4 years ago

64)     input = CreateObject("roInput")
65)     input.SetMessagePort(port)
David Blume first commit

David Blume authored 4 years ago

66) 
67)     success = deviceInfo.EnableLinkStatusEvent(true)
68)     if not success m.top.updateTextLower = "EnableLinkStatusEvent failure"
69)     success = deviceInfo.EnableAudioDestinationEvent(true)
70)     if not success then m.top.updateTextLower = "EnableAudioDestinationEvent failure"
71)     success = deviceInfo.EnableAudioGuideChangedEvent(true)
72)     if not success then m.top.updateTextLower = "EnableAudioGuideChangedEvent failure"
73)     success = deviceInfo.EnableAppFocusEvent(true)
74)     if not success then m.top.updateTextLower = "EnableAppFocusEvent failure"
75)     success = deviceInfo.EnableCodecCapChangedEvent(true)
76)     if not success then m.top.updateTextLower = "EnableCodecCapChangedEvent failure"
77) 
78)     while(true)
79)         msg = wait(0, port)
80)         msgType = type(msg)
81) 
82)         dt = Mid(CreateObject("roDateTime").ToISOString(), 15, 5)
83) 
84)         if msgType = "roHdmiStatusEvent"
85)             aa = msg.GetInfo()
86)             v = aa.LookupCI("Plugged")
David Blume Remove unused QR images; Ad...

David Blume authored 4 years ago

87)             if v <> invalid then m.top.updateTextLower = dt + " HDMI plugged " + v.toStr()
David Blume first commit

David Blume authored 4 years ago

88)         elseif msgType = "roCECStatusEvent"
89)             aa = msg.GetInfo()
90)             v = aa.LookupCI("Active")
David Blume Remove unused QR images; Ad...

David Blume authored 4 years ago

91)             if v <> invalid then m.top.updateTextLower = dt + " CEC Status " + v.toStr()
David Blume first commit

David Blume authored 4 years ago

92)         elseif msgType = "roDeviceInfoEvent"
93)             aa = msg.GetInfo()
94)             v = aa.LookupCI("Mute")
David Blume Remove unused QR images; Ad...

David Blume authored 4 years ago

95)             if v <> invalid then  m.top.updateTextLower = dt + " Mute " + v.toStr()
David Blume first commit

David Blume authored 4 years ago

96)             v = aa.LookupCI("Mode")
David Blume Remove unused QR images; Ad...

David Blume authored 4 years ago

97)             if v <> invalid then m.top.updateTextLower = dt + " Mode " + v.toStr()
David Blume first commit

David Blume authored 4 years ago

98)             v = aa.LookupCI("linkStatus")
David Blume Remove unused QR images; Ad...

David Blume authored 4 years ago

99)             if v <> invalid then m.top.updateTextLower = dt + " LinkStatus " + v.toStr()
David Blume first commit

David Blume authored 4 years ago

100)             v = aa.LookupCI("audioGuideEnabled")
David Blume Remove unused QR images; Ad...

David Blume authored 4 years ago

101)             if v <> invalid then m.top.updateTextLower = dt + " AudioGuide " + v.toStr()
David Blume first commit

David Blume authored 4 years ago

102)             v = aa.LookupCI("appFocused")
David Blume Remove unused QR images; Ad...

David Blume authored 4 years ago

103)             if v <> invalid then m.top.updateTextLower = dt + " appFocused " + v.toStr()
David Blume first commit

David Blume authored 4 years ago

104)             v = aa.LookupCI("audioCodecCapabilityChanged")
David Blume Remove unused QR images; Ad...

David Blume authored 4 years ago

105)             if v <> invalid then m.top.updateTextLower = dt + " audioCodecCapabilityChanged " + v.toStr()
David Blume Fix static analysis problem...

David Blume authored 4 years ago

106)         elseif msgType = "roInputEvent"
107)             info = msg.GetInfo()
108)             m.top.updateTextLower = dt + " Input " + FormatJSON(info)