Skip to content

Split variable lists for IBT and Live modes, add variable types, reformat#66

Open
BeardedBeaver wants to merge 1 commit into
kutu:masterfrom
BeardedBeaver:update-vars
Open

Split variable lists for IBT and Live modes, add variable types, reformat#66
BeardedBeaver wants to merge 1 commit into
kutu:masterfrom
BeardedBeaver:update-vars

Conversation

@BeardedBeaver
Copy link
Copy Markdown

Add separate variable lists for IBT file and Live modes. Previously there was a single list for Live mode.

Also include information about the variable type and format the rows a bit cleaner.

Dumped with the following script
import argparse

import irsdk  # type: ignore

type_map = {
    0: "irsdk_char",
    1: "irsdk_bool",
    2: "irsdk_int",
    3: "irsdk_bitField",
    4: "irsdk_float",
    5: "irsdk_double",
}


def dump(headers: list[irsdk.VarHeader]) -> None:
    for h in headers:
        t = type_map.get(h.type)
        assert t, f"Unknown type {h.type} for channel {h.name}"
        print(f"{h.name:<40} {h.unit:<20} {t:<20} {h.desc}")


def parse_args() -> argparse.Namespace:
    parser = argparse.ArgumentParser()
    sub = parser.add_subparsers(dest="mode", required=True)

    sub.add_parser("live")

    ibt = sub.add_parser("ibt")
    ibt.add_argument("--file-name", required=True)

    return parser.parse_args()


def main() -> None:
    args = parse_args()

    if args.mode == "live":
        ir = irsdk.IRSDK()
        ir.startup()
        if not ir.is_connected:
            raise RuntimeError("iRacing is not running")
        dump(ir._var_headers)

    elif args.mode == "ibt":
        ir = irsdk.IBT()
        ir.open(args.file_name)
        dump(ir._var_headers)  # type: ignore


if __name__ == "__main__":
    main()

Sorted separately to match the original sorting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant