# -*- coding: utf-8 -*-

import pyscripts
import sysactions
from bustoken import (
    TK_SLCTRL_PMGR_GET_NAVIGATION,
)
from msgbus import (
    FM_PARAM,
    TK_SYS_ACK,
    MBEasyContext,
)
from posot import OrderTakerException

mb_context = pyscripts.mbcontext  # type: MBEasyContext


@sysactions.action
def get_navigation_data(
    pos_id,     # type: str
):
    # type: (...) -> str

    message_response = mb_context.MB_EasySendMessage(
        dest_name='ORDERMGR{}'.format(
            pos_id
        ),
        token=TK_SLCTRL_PMGR_GET_NAVIGATION,
        format=FM_PARAM,
        data=pos_id,
    )

    if message_response.token != TK_SYS_ACK:
        raise OrderTakerException(
            code=-1,
            descr=message_response.data,
        )
    return message_response.data
