Пример #1
0
async def on_connect(websocket, path):  # 等待client 链接 传来的参数是charge point传来的
    """ For every new charge point that connects, create a ChargePoint instance
    and start listening for messages.

    """

    charge_point_id = path.strip('/')  #

    cp = ChargePoint(charge_point_id, websocket)  #
    # create_gui(cp)

    # 将每个cp添加到字典里
    EVSE_dict[charge_point_id] = cp

    # print(cp)
    # print(EVSE_dict)

    def which_function_1():
        fun2 = cp.send_remote_start_transaction()

    fun1 = cp.start()
    fun2 = cp.send_remote_start_transaction()

    await asyncio.gather(
        fun1,
        fun2,
        # cp.send_remote_stop_transaction(),
        #                      # cp.send_clear_cache_request()
    )
async def main():
    async with websockets.connect('ws://localhost:9000/CP_1',
                                  subprotocols=['ocpp1.6']) as ws:

        cp = ChargePoint('CP_1', ws)

        await asyncio.gather(cp.start(), cp.send_boot_notification())
Пример #3
0
async def main():
    async with websockets.connect('ws://149.56.47.168:8080/PCremote',
                                  subprotocols=['ocpp1.6']) as ws:

        cp = ChargePoint('CP_1', ws)

        await asyncio.gather(cp.start(), cp.send_boot_notification(),
                             cp.send_authorize(), cp.send_start_transaction())
Пример #4
0
async def main():
    async with websockets.connect(
        'wss://ocpp16.therevproject.com/ocpp/1_6/plswork',
        subprotocols=['ocpp1.6']
    ) as ws:

        cp = ChargePoint('test1', ws)
        await asyncio.gather(cp.start(), cp.execute())
        await ws.close()
Пример #5
0
async def main():
    async with websockets.connect('%s/serial123' % config.CS_URL,
                                  subprotocols=['ocpp1.6']) as ws:

        cp = ChargePoint('serial123', ws)

        await asyncio.gather(cp.start(), cp.send_boot_notification(),
                             cp.send_heartbeat(), cp.send_start_transaction(),
                             cp.send_stop_transaction())
Пример #6
0
async def main():
    async with websockets.connect(  # 链接
            'ws://localhost:9000/CP_1',  # 目的地址  +  序号 
            subprotocols=['ocpp1.6']) as ws:

        cp = ChargePoint('CP_1', ws)  #  实例化cp 包含名字和 ws 协议

        await asyncio.gather(
            cp.start(),
            cp.send_boot_notification(),
            # cp.clear_cache_notification()
        )  #先start ,在发送
Пример #7
0
async def on_connect ( websocket, path ) :
    """ For every new charge point that connects, create a ChargePoint instance
   and start listening for messages.

   """
    charge_point_id = path.strip('/')
    cp = ChargePoint(charge_point_id, websocket)
    print("Client Connected")
    
    
    

    await asyncio.gather(cp.start(),cp.send_trigger_message())
Пример #8
0
async def on_connect(
        websocket, path):  # 等待client 链接   websocket 和 path 是client传来的参数,(变量名)
    """ For every new charge point that connects, create a ChargePoint instance
    and start listening for messages.

    """

    charge_point_id = path.strip('/')  # 获得client 编号
    # charge_point_id = '12345'
    # print(charge_point_id)

    print("path from client is : %s" % path)
    # message_from_gui = await websocket.recv()

    # if charge_point_id.startswith("***",0,3):
    #     # print ("this message is from gui")
    #     print("charge point id is : %s" %charge_point_id)
    #     # message_from_gui = await websocket.recv()
    #     print("message from client is : %s" %message_from_gui)
    #
    #     return
    # else

    cp = ChargePoint(charge_point_id, websocket)  #创建ChargerPoint 实例化 记为 cp

    # 将每个cp添加到全局字典里
    EVSE_dict[charge_point_id] = cp

    await asyncio.gather(
        cp.start(),
        # cp.send_clear_cache_request(),
        # cp.send_remote_start_transaction(),
        # cp.send_remote_stop_transaction(),
        # cp.set_charging_profile()
        # cp.clear_charging_profile()
        # cp.cancel_reservation()
        # cp.change_availability()
        # cp.get_configuration()
        # cp.change_configuration()
        # cp.data_transfer()
        # cp.get_local_list_version()
        # cp.send_local_list()
        # cp.reset()
        # cp.unlock_connector()
        # cp.update_firmware()
    )
Пример #9
0
async def main():
    async with websockets.connect(  #
            'ws://10.1.60.19:9000/CP_1',  #
            subprotocols=['ocpp1.6']) as ws:

        cp = ChargePoint('CP_1', ws)  #

        await asyncio.gather(
            cp.start(),
            # cp.boot_notification(),
            # cp.authorize(),
            # cp.heart_beat(),
            # cp.start_transaction(),
            # cp.stop_transaction(),
            # cp.meter_value(),
            # cp.status_notification(),
            cp.data_transfer(),
        )