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
Beispiel #2
0
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())
Beispiel #3
0
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"
Beispiel #4
0
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"
Beispiel #5
0
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
Beispiel #6
0
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"
Beispiel #7
0
def acMain(ac_version):
    import time

    global appWindow, hSession, dbgLabel, texture_radar, texture_indicator_left, texture_indicator_right, z
    ac.log("helipicapew::acMain Start {}".format(time.localtime(time.time())))
    try:
        import helipicapewconfig
        helipicapewconfig.handleIni('helipicapew')

        z = helipicapewcar.guiZoomFactor

        appWindow = ac.newApp("helipicapew")
        ac.setSize(appWindow, 200 * z, 200 * z)
        ac.drawBorder(appWindow, 0)
        ac.setBackgroundOpacity(appWindow, 0)
        ac.setTitle(appWindow, "helipicapew v{}".format(version))

        ac.addRenderCallback(appWindow, onFormRender)
        ac.addOnAppActivatedListener(appWindow, onAppActivated)
        appWindowActivated = time.clock()
        showWindowTitle = True

        dbgLabel = ac.addLabel(appWindow, "")
        ac.setPosition(dbgLabel, 15, 405)

        texture_radar = ac.newTexture("apps/python/helipicapew/img/radar.png")
        texture_indicator_left = ac.newTexture(
            "apps/python/helipicapew/img/indicatorL.png")
        texture_indicator_right = ac.newTexture(
            "apps/python/helipicapew/img/indicatorR.png")

        hSession = helipicapewsession.HeliPicaPewSession()

        ac.log("helipicapew::acMain finished")

    except Exception as e:
        ac.log("helipicapew::acMain() %s" % e)
    return "helipicapew"
Beispiel #8
0
    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))
Beispiel #9
0
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 appWindow, dbgLabel
    global xyro_dev
    global DebugInput, DebugInput2, DebugInput3
    global BtnStart, BtnStop

    try:
        import sam_secondz_xyro_config
        sam_secondz_xyro_config.handleIni('3secondz_xyro')

        ac.log("3secondz_xyro:: xyro created")
        xyro_dev = xyrodevice.XyroDevice(UDP_IP, UDP_PORT, DEVICE_ID,
                                         FW_VERSION, STEERING_ANGLE_RANGE,
                                         ALIVE_PACKET_PERIOD,
                                         CAN_PACKET_PERIOD, NAV_PACKET_PERIOD,
                                         MEAS_PACKET_PERIOD)

        appWindow = ac.newApp("3secondz_xyro")
        ac.setSize(appWindow, 300, 100)
        ac.drawBorder(appWindow, 0)
        ac.setBackgroundOpacity(appWindow, 0)
        ac.setTitle(appWindow, '3secondz_xyro')

        IPAddrInput = ac.addTextInput(appWindow, "TEXT_INPUT")
        ac.setPosition(IPAddrInput, 10, 30)
        ac.setSize(IPAddrInput, 120, 20)
        ac.setText(IPAddrInput, str(UDP_IP))

        PortInput = ac.addTextInput(appWindow, "TEXT_INPUT")
        ac.setPosition(PortInput, 140, 30)
        ac.setSize(PortInput, 50, 20)
        ac.setText(PortInput, str(UDP_PORT))

        DebugInput = ac.addTextInput(appWindow, "TEXT_INPUT")
        ac.setPosition(DebugInput, 10, 60)
        ac.setSize(DebugInput, 280, 20)
        ac.setText(DebugInput, "")

        DebugInput2 = ac.addTextInput(appWindow, "TEXT_INPUT")
        ac.setPosition(DebugInput2, 10, 90)
        ac.setSize(DebugInput2, 280, 20)
        ac.setText(DebugInput2, "")

        DebugInput3 = ac.addTextInput(appWindow, "TEXT_INPUT")
        ac.setPosition(DebugInput3, 10, 120)
        ac.setSize(DebugInput3, 280, 20)
        ac.setText(DebugInput3, "")

        BtnStart = ac.addButton(appWindow, "Start")
        ac.setPosition(BtnStart, 10, 150)
        ac.setSize(BtnStart, 90, 20)
        ac.addOnClickedListener(BtnStart, onClickBtnStart)

        BtnStop = ac.addButton(appWindow, "Stop")
        ac.setPosition(BtnStop, 110, 150)
        ac.setSize(BtnStop, 90, 20)
        ac.addOnClickedListener(BtnStop, onClickBtnStop)

        ac.addRenderCallback(appWindow, onFormRender)
        ac.addOnAppActivatedListener(appWindow, onAppActivated)
        appWindowActivated = time.clock()
        showWindowTitle = True

        dbgLabel = ac.addLabel(appWindow, "")
        ac.setPosition(dbgLabel, 15, 405)

        #xyro_dev.turnOn()

        ac.log("3secondz_xyro::acMain finished")
    except Exception as e:
        ac.log("3secondz_xyro::acMain() %s" % e)
    return "3secondz_xyro"
Beispiel #11
0
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"