telemetrypanel.py (4034B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\devtools\script\telemetrypanel.py 2 from __future__ import print_function 3 import blue 4 import uthread 5 from carbonui import uiconst 6 from carbonui.control.singlelineedits.singleLineEditFloat import SingleLineEditFloat 7 from carbonui.primitives.layoutGrid import LayoutGrid 8 from carbonui.control.button import Button 9 from carbonui.control.checkbox import Checkbox 10 from eve.client.script.ui.control.eveLabel import Label 11 from carbonui.control.window import Window 12 from pytelemetry import StartTimedTelemetry, StartTelemetry 13 14 class TelemetryPanel(Window): 15 __guid__ = 'form.TelemetryPanel' 16 default_caption = 'Telemetry Panel' 17 default_minSize = (500, 265) 18 default_windowID = 'telemetrypanel' 19 20 def ApplyAttributes(self, attributes): 21 Window.ApplyAttributes(self, attributes) 22 optionsContainer = LayoutGrid(parent=self.sr.main, align=uiconst.TOTOP, height=60, padding=10, columns=3, cellPadding=10) 23 self.cppCaptureChk = Checkbox(parent=optionsContainer, align=uiconst.TOPLEFT, text='C++ capture', width=120, checked=blue.statistics.isCppCaptureEnabled, callback=self._OnCppCaptureChk) 24 self.pythonCaptureChk = Checkbox(parent=optionsContainer, align=uiconst.TOPLEFT, text='Python capture', width=120, checked=blue.statistics.isPythonCaptureEnabled, callback=self._OnPythonCaptureChk) 25 self.taskletTimersChk = Checkbox(parent=optionsContainer, align=uiconst.TOPLEFT, text='Tasklet timers', width=120, checked=True) 26 self.timedCaptureChk = Checkbox(parent=optionsContainer, align=uiconst.TOPLEFT, text='Timed capture', width=120, checked=False, callback=self._OnTimedCaptureChk) 27 self.durationEdit = SingleLineEditFloat(parent=optionsContainer, label='Duration:', minValue=0.1, maxValue=10.0) 28 self.durationEdit.Disable() 29 if blue.pyos.markupZonesInPython: 30 msg = 'Python Telemetry markup enabled' 31 else: 32 msg = 'Python Telemetry markup is NOT enabled' 33 Label(parent=self.sr.main, align=uiconst.TOBOTTOM, text=msg, padding=10) 34 buttonContainer = LayoutGrid(parent=self.sr.main, align=uiconst.TOALL, columns=2, cellPadding=4, cellSpacing=10, padding=10) 35 self.startBtn = Button(parent=buttonContainer, label='Start', func=self._Start, fixedwidth=80, fixedheight=60) 36 self.stopBtn = Button(parent=buttonContainer, label='Stop', func=self._Stop, fixedwidth=80, fixedheight=60) 37 uthread.new(self._CheckStatus) 38 39 def _OnCppCaptureChk(self, checkbox): 40 blue.statistics.isCppCaptureEnabled = checkbox.GetValue() 41 42 def _OnPythonCaptureChk(self, checkbox): 43 blue.statistics.isPythonCaptureEnabled = checkbox.GetValue() 44 45 def _OnTimedCaptureChk(self, checkbox): 46 if checkbox.GetValue(): 47 self.durationEdit.Enable() 48 else: 49 self.durationEdit.Disable() 50 51 def _Start(self, args): 52 if self.taskletTimersChk.GetValue(): 53 blue.pyos.taskletTimer.telemetryOn = True 54 if self.timedCaptureChk.GetValue(): 55 duration = float(self.durationEdit.text) 56 print('Starting Telemetry timed capture (%4.2f seconds)' % duration) 57 StartTimedTelemetry(duration) 58 else: 59 print('Starting Telemetry') 60 StartTelemetry() 61 62 def _Stop(self, args): 63 print('Stopping Telemetry') 64 blue.statistics.StopTelemetry() 65 blue.pyos.taskletTimer.telemetryOn = False 66 67 def _CheckStatus(self): 68 while not self.destroyed: 69 self.cppCaptureChk.SetChecked(blue.statistics.isCppCaptureEnabled, report=False) 70 if blue.statistics.isTelemetryConnectionRequested or blue.statistics.isTelemetryStarted: 71 self.startBtn.Disable() 72 self.stopBtn.Enable() 73 else: 74 self.startBtn.Enable() 75 self.stopBtn.Disable() 76 blue.pyos.taskletTimer.telemetryOn = False 77 blue.synchro.SleepWallclock(500)