import os 
import redis
import json 
from kedong.utils import parse_config_new


BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
CONFIG = parse_config_new(BASE_DIR)

class DeviceConfig:
    CBD_PUBLICS = "/yfkj/cbd/pub/#"
    CBD_OFFLINE_PUBLICS = "/yfkj/cbd/offline/#"
    CBD_TYPE = 3

    XCT_PUBLICS = "/yfkj/xct/pub/#"
    XCT_TYPE = 12

    COLOR_PUBLICS = "yfkj/color/c2s/#"
    COLOR_OFFLINE_PUBLICS = "yfkj/color/offline/#"
    COLOR_TYPE = 14

    SCD_PUBLICS = "/yfkj/scd/pub/#"
    SCD_OFFLINE_PUBLICS = "/yfkj/scd/offline/#"
    SCD_TYPE = 2

    XYV3_PUBLICS = "/yfkj/xyv3/c2s/#"
    XYV3_OFFLINE_PUBLICS = "/yfkj/xyv3/offline/#"
    XYV3_TYPE = 8

    QXZ_PUBLICS = "/yfkj/qxz/pub/#"
    QXZ_OFFLINE_PUBLICS = "/yfkj/qxz/offline/#"
    QXZ_TYPE = 5

    BZY_PUBLICS = "/yfkj/bzy/c2s/#"
    BZY_OFFLINE_PUBLICS = "/yfkj/bzy/offline/#"
    BZY_TYPE = 7

    XPH_QXZ_PUBLICS = "/xph/qxz/pub/#"
    XPH_QXZ_OFFLINE_PUBLICS = "/xph/qxz/offline/#"
    XPH_TYPE = 5

    XYCB_PUBLICS = "/yfkj/xycb/c2s/#"
    XYCB_OFFLINE_PUBLICS = "/yfkj/xycb/offline/#"
    XYCB_TYPE = 4

    WS_PUBLICS = "/yfkj/ws/pub/#"
    WS_OFFLINE_PUBLICS = "/yfkj/ws/offline/#"
    WS_TYPE = 16

    TRANSPOND_TEST_PUBLICS = "/TranspondData/test"


def dashuju_pub_mqtt(topic, payload):
    msg_info = json.dumps(payload, ensure_ascii=False)
    temp_data = {
        'topic': topic,
        'payload': msg_info
    }
    # mqtt_redis_tools.push("dashuju_pub_mqtt", temp_data)
