从 OCPP CMS 服务器接收 TriggerMessage 时出错
Getting Error while receiving TriggerMessage from OCPP CMS server
我正在设计一个基于 PyPi OCPP v1.6J 的 OCPP 模拟器。我成功地向 OCPP CMS 服务器发送了 Bootnotification、HeartBeat 和 Status 通知。但是当我从 CMS 服务器接收任何消息时,我的控制台出现错误。
我试图从 CMS 服务器提供 TriggerMessage (Heartbeat),但我的模拟充电点不接受请求。它通过一些错误。下面附上代码片段
class ChargePoint(cp):
@on(Action.TriggerMessage)
def on_trigger_message(self, requestedMessage, conectorId, **kwargs):
return call.TriggerMessagePayload(
connector_id = 1,
requested_message = "Heartbeat"
)
return call_result.TriggerMessagePayload(
status = TriggerMessageStatus.accepted
)
下面附上错误信息
C:\Python38>python ocppclientsteve.py
Connected to SteVe CMS server.
Error while handling request '<Call - unique_id=f95390e4-a751-4bbb-8a41-abed33b29ca8, action=TriggerMessage, payload={'requestedMessage': 'Heartbeat', 'connectorId': 1}>'
Traceback (most recent call last):
File "C:\Python38\lib\site-packages\ocpp\charge_point.py", line 185, in _handle_call
response = handler(**snake_case_payload)
File "C:\Python38\lib\site-packages\ocpp\routing.py", line 33, in inner
return func(*args, **kwargs)
TypeError: on_trigger_message() missing 2 required positional arguments: 'requestedMessage' and 'conectorId'
Error while handling request '<Call - unique_id=d12e5c40-f155-4d49-bd68-38f9c9fd074b, action=TriggerMessage, payload={'requestedMessage': 'Heartbeat', 'connectorId': 1}>'
Traceback (most recent call last):
File "C:\Python38\lib\site-packages\ocpp\charge_point.py", line 185, in _handle_call
response = handler(**snake_case_payload)
File "C:\Python38\lib\site-packages\ocpp\routing.py", line 33, in inner
return func(*args, **kwargs)
TypeError: on_trigger_message() missing 2 required positional arguments: 'requestedMessage' and 'conectorId'
这里是图书馆的作者。
库对所有属性使用 snake_case。像这样:
class ChargePoint(cp):
@on(Action.TriggerMessage)
def on_trigger_message(self, requested_message, connector_id, **kwargs):
return call.TriggerMessagePayload(
connector_id = 1,
requested_message = "Heartbeat"
)
return call_result.TriggerMessagePayload(
status = TriggerMessageStatus.accepted
)
我正在设计一个基于 PyPi OCPP v1.6J 的 OCPP 模拟器。我成功地向 OCPP CMS 服务器发送了 Bootnotification、HeartBeat 和 Status 通知。但是当我从 CMS 服务器接收任何消息时,我的控制台出现错误。
我试图从 CMS 服务器提供 TriggerMessage (Heartbeat),但我的模拟充电点不接受请求。它通过一些错误。下面附上代码片段
class ChargePoint(cp):
@on(Action.TriggerMessage)
def on_trigger_message(self, requestedMessage, conectorId, **kwargs):
return call.TriggerMessagePayload(
connector_id = 1,
requested_message = "Heartbeat"
)
return call_result.TriggerMessagePayload(
status = TriggerMessageStatus.accepted
)
下面附上错误信息
C:\Python38>python ocppclientsteve.py
Connected to SteVe CMS server.
Error while handling request '<Call - unique_id=f95390e4-a751-4bbb-8a41-abed33b29ca8, action=TriggerMessage, payload={'requestedMessage': 'Heartbeat', 'connectorId': 1}>'
Traceback (most recent call last):
File "C:\Python38\lib\site-packages\ocpp\charge_point.py", line 185, in _handle_call
response = handler(**snake_case_payload)
File "C:\Python38\lib\site-packages\ocpp\routing.py", line 33, in inner
return func(*args, **kwargs)
TypeError: on_trigger_message() missing 2 required positional arguments: 'requestedMessage' and 'conectorId'
Error while handling request '<Call - unique_id=d12e5c40-f155-4d49-bd68-38f9c9fd074b, action=TriggerMessage, payload={'requestedMessage': 'Heartbeat', 'connectorId': 1}>'
Traceback (most recent call last):
File "C:\Python38\lib\site-packages\ocpp\charge_point.py", line 185, in _handle_call
response = handler(**snake_case_payload)
File "C:\Python38\lib\site-packages\ocpp\routing.py", line 33, in inner
return func(*args, **kwargs)
TypeError: on_trigger_message() missing 2 required positional arguments: 'requestedMessage' and 'conectorId'
这里是图书馆的作者。
库对所有属性使用 snake_case。像这样:
class ChargePoint(cp):
@on(Action.TriggerMessage)
def on_trigger_message(self, requested_message, connector_id, **kwargs):
return call.TriggerMessagePayload(
connector_id = 1,
requested_message = "Heartbeat"
)
return call_result.TriggerMessagePayload(
status = TriggerMessageStatus.accepted
)