def acMain(ac_version): global version, appName, mainApp, x_app_size, y_app_size, backgroundOpacity, customFontName try: debug("starting version " + version) mainApp = ac.newApp(appName) ac.setTitle(mainApp, "") ac.drawBorder(mainApp, 0) ac.setIconPosition(mainApp, 0, -10000) ac.setBackgroundOpacity(mainApp, backgroundOpacity) # ac.initFont(0, customFontName, 0, 0) ac.setSize(mainApp, x_app_size, y_app_size) ac.addOnAppActivatedListener(mainApp, onMainAppActivatedListener) ac.addOnAppDismissedListener(mainApp, onMainAppDismissedListener) ac.addRenderCallback(mainApp, onMainAppFormRender) getSettings() createUI() return appName except exception: debug(repr(traceback.format_exception(exc_type, exc_value, exc_traceback))) showMessage("Error: " + traceback.format_exc())
def acMain(ac_version): global appWindow, label1, logPrefix, appName, splitsRenderer ac.console(logPrefix + "acMain") try: appWindow = ac.newApp(appName) ac.setTitle(appWindow, "") ac.setSize(appWindow, 300, 300) ac.drawBorder(appWindow, 0) ac.setBackgroundOpacity(appWindow, 0.3) resetBtn = ac.addButton(appWindow, "R") ac.setPosition(resetBtn, 5, 30) ac.setSize(resetBtn, 30, 30) ac.addOnClickedListener(resetBtn, onResetClicked) newSplitBtn = ac.addButton(appWindow, "N") ac.setPosition(newSplitBtn, 40, 30) ac.setSize(newSplitBtn, 30, 30) ac.addOnClickedListener(newSplitBtn, onNewSplitClicked) #label1 = ac.addLabel(appWindow, "____") #ac.setPosition(label1, 0, 70) splitsRenderer = SplitsRenderer(2, 62, 10, 10) ac.addRenderCallback(appWindow, onRender) ac.addOnAppActivatedListener(appWindow, onActivate) ac.addOnAppDismissedListener(appWindow, onDismiss) ac.console(logPrefix + "Initialized") except: printExceptionInfo("acMain") return appName
def acMain(ac_version): global appWindow, CamberIndicators, CheckBoxes, Buttons, Options, Labels, UIData loadOptions() appWindow = ac.newApp("CamberExtravaganza") ac.setSize(appWindow, 200, 200) ac.drawBorder(appWindow, 0) ac.setBackgroundOpacity(appWindow, 0) ac.setIconPosition(appWindow, 0, -10000) # Only enable rendering if app is activated ac.addOnAppActivatedListener(appWindow, onAppActivated) ac.addOnAppDismissedListener(appWindow, onAppDismissed) # Target Camber Labels Labels["target"] = ac.addLabel(appWindow, "Target:") ac.setPosition(Labels["target"], 85, 100) ac.setFontSize(Labels["target"], 10) Labels["targetCamberF"] = ac.addLabel(appWindow, "") ac.setPosition(Labels["targetCamberF"], 75, 76) ac.setFontSize(Labels["targetCamberF"], 24) Labels["targetCamberR"] = ac.addLabel(appWindow, "") ac.setPosition(Labels["targetCamberR"], 75, 105) ac.setFontSize(Labels["targetCamberR"], 24) # Options Checkbox CheckBoxes["options"] = ac.addCheckBox(appWindow, "Options") ac.setPosition(CheckBoxes["options"], 50, 225) ac.addOnCheckBoxChanged(CheckBoxes["options"], checkboxHandler) # Option Buttons uidata = [ ["drawGraphs", "Draw Graphs", drawGraphsHandler], ["normalize", "Normalize", normalizeHandler], ["useSpectrum", "Use Spectrum", useSpectrumHandler] ] x = 50 y = 255 dy = 30 for d in uidata: Buttons[d[0]] = ac.addButton(appWindow, d[1]) ac.setPosition(Buttons[d[0]], x, y) ac.setSize(Buttons[d[0]], 100, 25) ac.addOnClickedListener(Buttons[d[0]], d[2]) ac.setVisible(Buttons[d[0]], 0) y += dy # Get optimal camber from files loadTireData() CamberIndicators["FL"] = CamberIndicator(appWindow, 25, 75) CamberIndicators["FR"] = CamberIndicator(appWindow,125, 75) CamberIndicators["RL"] = CamberIndicator(appWindow, 25,175) CamberIndicators["RR"] = CamberIndicator(appWindow,125,175) ac.addRenderCallback(appWindow, onFormRender) return "CamberExtravaganza"
def acMain(ac_version): global appWindow, Labels, gearSpacing, fontSize, gears, PxPer1000RPM, RPMdivs appWindow = ac.newApp("Reventach") ac.setSize(appWindow, appWidth, appHeight) ac.drawBorder(appWindow, 0) ac.setBackgroundOpacity(appWindow, 0) ac.setIconPosition(appWindow, 0, -10000) ac.setTitle(appWindow, "") # Only enable rendering if app is activated ac.addOnAppActivatedListener(appWindow, onAppActivated) ac.addOnAppDismissedListener(appWindow, onAppDismissed) loadCarData() PxPer1000RPM = 1000 * appHeight / CarData["maxRPM"] RPMdivs = CarData["maxRPM"] // 10000 + 1 #~ fontSize = PxPer1000RPM * 0.5 * RPMdivs fontSize = appHeight / 15 y = appHeight - PxPer1000RPM * RPMdivs count = RPMdivs while y > -1: dx = (appHeight - y) / lineSlope Labels["rpmL" + str(count)] = ac.addLabel(appWindow, str(count)) ac.setPosition(Labels["rpmL" + str(count)], dx - fontSize, y - fontSize / 2) ac.setFontSize(Labels["rpmL" + str(count)], fontSize) ac.setFontAlignment(Labels["rpmL" + str(count)], "center") Labels["rpmR" + str(count)] = ac.addLabel(appWindow, str(count)) ac.setPosition(Labels["rpmR" + str(count)], appWidth - dx + fontSize, y - fontSize / 2) ac.setFontSize(Labels["rpmR" + str(count)], fontSize) ac.setFontAlignment(Labels["rpmR" + str(count)], "center") if y < PxPer1000RPM * RPMdivs - 1: ac.setFontColor(Labels["rpmL" + str(count)], 0.7, 0.0, 0.0, 0.9) ac.setFontColor(Labels["rpmR" + str(count)], 0.7, 0.0, 0.0, 0.9) y -= (PxPer1000RPM * RPMdivs) count += RPMdivs for n in range(CarData["totalGears"]): gears.insert(0, str(n + 1)) gearSpacing = appHeight / (CarData["totalGears"] + 2) fontSize = gearSpacing * 0.8 for n, c in enumerate(gears): Labels["gear" + c] = ac.addLabel(appWindow, c) ac.setPosition(Labels["gear" + c], appWidth / 2, (n * gearSpacing)) ac.setFontSize(Labels["gear" + c], fontSize) ac.setFontAlignment(Labels["gear" + c], "center") ac.addRenderCallback(appWindow, onFormRender) return "Reventach"
def acMain(ac_version): global DRIVER, TRACK, CAR, WINDOW, LAP_LABELS, LAP_VALID_INDICATOR DRIVER = ac.getDriverName(DRIVER_ID_SELF) TRACK = '%s-%s' % (ac.getTrackName(DRIVER_ID_SELF), ac.getTrackConfiguration(DRIVER_ID_SELF)) CAR = ac.getCarName(DRIVER_ID_SELF) ac.console('Initialize %s: driver %s on %s in %s' % (NAME, DRIVER, TRACK, CAR)) WINDOW = ac.newApp(NAME) ac.setSize(WINDOW, *SIZE) ac.setTitle(NAME) if ac.addOnAppActivatedListener(WINDOW, onActivate) == -1: ac.console('Failed to add listener activate') if ac.addOnAppDismissedListener(WINDOW, onDeactivate) == -1: ac.console('Failed to add listener deactivate') i = 0 while i < LAP_COUNT: label = ac.addLabel(WINDOW, 'Waiting for lap time...') LAP_LABELS.append(label) i += 1 LAP_VALID_INDICATOR = ac.addLabel(WINDOW, 'Clean') refreshLapDisplay() return NAME
def acMain(ac_version): global tracking app = ac.newApp("MhwkRacingAssettoApp") ac.setTitle(app, 'MHWK racing') ac.setSize(app, 300, 200) ac.addOnAppActivatedListener(app, on_app_activated) ac.addOnAppDismissedListener(app, on_app_dismissed) tracking = track.TrackerManager() tracking.track('OnNewSession', track.OnNewSession()) tracking.track('OnNewLap', track.OnNewLap()) tracking.track('OnNewSector', track.OnNewSector()) gateway = LoggingGateway(HttpGateway('racing.mhwk.nl')) tracking.listen('OnNewSession', dispatch.StartLapDispatcher(gateway)) tracking.listen('OnNewLap', dispatch.CompleteLapDispatcher(gateway)) tracking.listen('OnNewSector', dispatch.CompleteSectorDispatcher(gateway)) return "MhwkRacingAssettoApp"
def _on_id(self): super()._on_id() if self.has_id: if ac.addOnAppActivatedListener( self.id, ACWidget._event_function(ACWidget.EVENT.ACTIVATED, self)) == -1: console('Failed to add activation listener for {}.'.format( self.title)) if ac.addOnAppDismissedListener( self.id, ACWidget._event_function(ACWidget.EVENT.DISMISSED, self)) == -1: console('Failed to add dismissed listener for {}.'.format( self.title))
def acMain(ac_version: str) -> None: """ Initiates the program. """ global ACD_OBJ global CONFIGS global LT_VERSION log("Starting Live Telemetry {} on AC Python API version {}...".format( LT_VERSION, ac_version)) log("Loading configs...") CONFIGS = Config(LT_VERSION) log("Loading {} info...".format(ac.getCarName(0))) ACD_OBJ = ACD("content/cars/{}".format(ac.getCarName(0))) log("Loaded correctly") log("Loading options window...") global OPTIONS_INFO OPTIONS_INFO = OptionsInfo(CONFIGS) ac.addOnClickedListener( OPTIONS_INFO.get_button_id("Camber"), on_click_camber) ac.addOnClickedListener(OPTIONS_INFO.get_button_id("Dirt"), on_click_dirt) ac.addOnClickedListener( OPTIONS_INFO.get_button_id("Height"), on_click_height) ac.addOnClickedListener(OPTIONS_INFO.get_button_id("Load"), on_click_load) ac.addOnClickedListener(OPTIONS_INFO.get_button_id("Lock"), on_click_lock) ac.addOnClickedListener( OPTIONS_INFO.get_button_id("Logging"), on_click_logging) ac.addOnClickedListener(OPTIONS_INFO.get_button_id( "Pressure"), on_click_pressure) ac.addOnClickedListener( OPTIONS_INFO.get_button_id("RPMPower"), on_click_rpm) ac.addOnClickedListener(OPTIONS_INFO.get_button_id("Size"), on_click_size) ac.addOnClickedListener(OPTIONS_INFO.get_button_id( "Suspension"), on_click_suspension) ac.addOnClickedListener( OPTIONS_INFO.get_button_id("Temps"), on_click_temps) ac.addOnClickedListener(OPTIONS_INFO.get_button_id("Tire"), on_click_tire) ac.addOnClickedListener(OPTIONS_INFO.get_button_id("Wear"), on_click_wear) log("Loading engine window...") global ENGINE_INFO ENGINE_INFO = EngineInfo(ACD_OBJ, CONFIGS) window_id = ENGINE_INFO.get_window_id() ac.addOnAppActivatedListener(window_id, on_activation) ac.addOnAppDismissedListener(window_id, on_dismiss) ac.addRenderCallback(ENGINE_INFO.get_window_id(), on_render_engine) log("Loading wheel windows...") global WHEEL_INFOS for index in range(4): info = WheelInfo(ACD_OBJ, CONFIGS, index) window_id = info.get_window_id() ac.addOnAppActivatedListener(window_id, on_activation) ac.addOnAppDismissedListener(window_id, on_dismiss) WHEEL_INFOS[info.get_id()] = info ac.addRenderCallback(WHEEL_INFOS["FL"].get_window_id(), on_render_fl) ac.addRenderCallback(WHEEL_INFOS["FR"].get_window_id(), on_render_fr) ac.addRenderCallback(WHEEL_INFOS["RL"].get_window_id(), on_render_rl) ac.addRenderCallback(WHEEL_INFOS["RR"].get_window_id(), on_render_rr) log("Live Telemetry started.") return "Live Telemetry"
def acMain(ac_version): global label_lapcount, label_ERSRecovery, label_ERSDelivery, label_ERSHeatCharging, label_ERSCurrentKJ, label_ERSMaxJ, label_KersCharge, label_KersInput, label_SpeedMS, button_ChangeUnit, energy_unit_counter, current_energy_unit, label_BarCharge appWindow = ac.newApp(APP_NAME) ac.setSize(appWindow, 600, 500) ac_log("Testando a função de log") ac_console("Testando a função de console") ac.addOnAppActivatedListener(appWindow, on_activation) ac.addOnAppDismissedListener(appWindow, on_desactivation) button_ChangeUnit = ac.addButton(appWindow, "Change energy unit") ac.setSize(button_ChangeUnit, 150, 30) ac.setPosition(button_ChangeUnit, 300, 30) ac.addOnClickedListener(button_ChangeUnit, changeEnergyUnit) label_SpeedMS = ac.addLabel( appWindow, "Speed: {:.1f}m/s".format(ac.getCarState(0, acsys.CS.SpeedMS))) ac.setPosition(label_SpeedMS, 3, 300) label_ERSRecovery = ac.addLabel( appWindow, "MGU-K recovery mode: {}".format( ac.getCarState(0, acsys.CS.ERSRecovery))) ac.setPosition(label_ERSRecovery, 3, 90) label_ERSDelivery = ac.addLabel( appWindow, "MGU-K deploy mode: {}".format(ac.getCarState(0, acsys.CS.ERSDelivery))) ac.setPosition(label_ERSDelivery, 3, 120) label_ERSHeatCharging = ac.addLabel( appWindow, "MGU-H mode: {}".format(ac.getCarState(0, acsys.CS.ERSHeatCharging))) ac.setPosition(label_ERSHeatCharging, 3, 150) label_ERSCurrentKJ = ac.addLabel( appWindow, "Energy consumed in this lap: {:03.3f}{}".format( getErsCurrent(), current_energy_unit[energy_unit_counter])) ac.setPosition(label_ERSCurrentKJ, 3, 180) label_ERSMaxJ = ac.addLabel( appWindow, "Maximum energy allowed per lap: {:03.3f}{}".format( getERSMax(), current_energy_unit[energy_unit_counter])) ac.setPosition(label_ERSMaxJ, 3, 210) label_KersCharge = ac.addLabel( appWindow, "Stored energy: {:.2f}%".format( ac.getCarState(0, acsys.CS.KersCharge) * 100)) ac.setPosition(label_KersCharge, 3, 240) label_KersInput = ac.addLabel( appWindow, "MGU-K power level: {}".format( ac.getCarState(0, acsys.CS.KersInput) * 100)) ac.setPosition(label_KersInput, 3, 270) label_BarCharge = ac.addLabel( appWindow, "{}%".format(ac.getCarState(0, acsys.CS.KersCharge))) ac.setPosition(label_BarCharge, 341, 130) ac.addRenderCallback(appWindow, onFormRender) return "ERS Info"