from systools import sys_log_error
from msgbus import TK_POS_GETPOSLIST, TK_SYS_ACK

pos_list = None


def get_pos_list(mb_context):
    global pos_list

    if pos_list is None:
        msg = mb_context.MB_EasySendMessage("PosController", TK_POS_GETPOSLIST)
        if msg.token != TK_SYS_ACK:
            sys_log_error("Could not retrieve PosList")
            raise Exception("Could not retrieve PosList")

        pos_list = sorted(map(int, msg.data.split("\0")))

    return pos_list
