mooncharge

    Type-safe, transport-neutral OCPP 1.6J protocol and EV charging session toolkit for MoonBit.

    ocpp
    ev-charging
    json-rpc
    protocol
    energy
    Download zip
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    11 hours ago
    Downloads
    8

    No dependencies

    #MoonCharge

    MoonCharge 是面向 MoonBit 的 OCPP 1.6J 协议核心。它把充电桩与充电站 管理系统之间的 JSON-RPC 帧、核心业务载荷、连接器交易状态机和智能充电 配置解析为可测试的纯 MoonBit API。

    MoonCharge 不绑定 WebSocket、HTTP、数据库或操作系统时钟。调用方负责传输、 持久化和时间来源,因此同一套协议逻辑可以运行在 wasm、wasm-gc、JavaScript 和 Native 后端。

    #为什么需要 MoonCharge

    MoonBit 已有 HTTP、WebSocket、MQTT、CAN、DBC 和物联网格式库,但截至 2026-11-18,MoonCakes 实时检索没有 OCPP、EVSE 或 CSMS 模块。OCPP 消息又 不能只当作普通 JSON:

    • CALL、CALLRESULT 和 CALLERROR 的数组结构、方向与错误语义不同;
    • StartTransaction、MeterValues 和 StopTransaction 共享交易但不共享载荷;
    • 连接器不能同时开启两个交易,停止后的电量不能小于启动电量;
    • 多个 ChargingProfile 还要经过用途、交易号、stack level、有效期和 充电站最大功率的共同约束。

    MoonCharge 把这些容易出错的边界集中到一个无 I/O 的协议层中,并提供稳定的 错误结果。

    #功能

    • 严格 OCPP 1.6J JSON-RPC framing:CALL、CALLRESULT、CALLERROR。
    • 字符串、数字和 null 消息 id;数字 id 保留原始文本。
    • OCPP 动作名称解析与请求/确认方向查询,未知动作在帧层保持可检查。
    • 核心载荷的类型化解析和序列化: BootNotification、Heartbeat、Authorize、StatusNotification、 StartTransaction、StopTransaction、MeterValues。
    • OCPP 注释中常见的状态、错误、停止原因和认证状态枚举。
    • 单连接器交易状态机,不依赖隐式全局状态。
    • ChargingProfile、ChargingSchedule 和周期校验。
    • 按 TxProfile > TxDefaultProfile 和最高 stack level 选择活动档位, 再应用 ChargePointMaxProfile 上限。
    • 无网络 CLI,用于帧检查、动作方向与充电档位求值。
    • 3 个可运行示例和跨后端 CI。

    #安装

    moon add ggbond44439/mooncharge@0.1.0

    #快速开始

    let frame = match
    @mooncharge.parse_frame(
    "[2,\"req-1\",\"StartTransaction\",{\"connectorId\":1,\"idTag\":\"RFID-7\",\"meterStart\":12000,\"timestamp\":\"2026-11-18T08:00:00Z\"}]",
    ) {
    Ok(frame) => frame
    Err(error) => fail(error.message())
    }

    let request = match frame {
    @mooncharge.Call(_, _, payload) =>
    match @mooncharge.StartTransactionRequest::from_json(payload) {
    Ok(request) => request
    Err(error) => fail(error.message())
    }
    _ => fail("expected CALL")
    }

    assert_eq(request.connector_id, 1)
    assert_eq(request.meter_start, 12000)

    #交易状态机

    let available = match @mooncharge.ConnectorSession::new(1) {
    Ok(value) => value
    Err(_) => fail("invalid connector")
    }
    let preparing = match available.begin_transaction(
    99,
    "RFID-7",
    12000,
    "2026-11-18T08:00:00Z",
    ) {
    Ok(value) => value
    Err(_) => fail("transaction did not start")
    }
    let charging = match preparing.begin_charging() {
    Ok(value) => value
    Err(_) => fail("charging did not start")
    }
    let finishing = match charging.finish_transaction(
    99,
    21000,
    "2026-11-18T09:00:00Z",
    Some(@mooncharge.StopReason::Local),
    ) {
    Ok(value) => value
    Err(_) => fail("transaction did not stop")
    }

    #充电档位

    evaluate_charging_profiles 使用调用方提供的 elapsed_seconds,按每个档位 自己的 startPeriod 计算。这样协议层不会隐式读取时钟,也不会绑定某个 IANA 时区实现。

    选择顺序:

    1. 优先匹配当前交易的 TxProfile;
    2. 否则选择 TxDefaultProfile;
    3. 同用途选择最高 stackLevel;
    4. 最后用 ChargePointMaxProfile 截断结果;
    5. A 与 W 不自动换算,单位不一致时返回 RateUnitMismatch。

    #CLI

    moon run cmd/main -- frame '[2,"req-1","Heartbeat",{}]' # kind=call id=req-1 action=Heartbeat moon run cmd/main -- action SetChargingProfile request # central-system-to-charge-point moon run cmd/main -- dispatch cp '[2,"auth-1","Authorize",{"idTag":"RFID-1"}]' # typed=Authorize direction=charge-point-to-central-system moon run cmd/main -- profile '<profile-json>' 120 42 # limit=22000 unit=W profile=8 capped=false

    #示例

    moon run examples/frame_roundtrip moon run examples/session_walkthrough moon run examples/profile_eval

    #明确不做

    • 不实现 WebSocket 握手、TLS、证书供应或网络重连。
    • 不实现 OCPP 2.0.1 的完整消息集合;当前版本固定为 1.6J 核心。
    • 不实现 Plug & Charge、PKI 信任链或计费结算。
    • 不持久化交易与配置,不替调用方决定数据库事务边界。
    • 不把 A 与 W 静默换算成同一单位。

    这些边界使 MoonCharge 可以复用于 CSMS、充电桩固件模拟器、协议一致性测试 和离线数据集处理,而不会成为一个隐藏 I/O 的“大而全”网关。

    #构建与测试

    moon fmt --check moon check --target all moon test --target all moon build moon run examples/frame_roundtrip moon run examples/session_walkthrough moon run examples/profile_eval moon package --list

    当前测试覆盖 framing、错误码、动作方向、交易载荷、充电档位选择、连接器生命 周期和 CLI。

    #生态定位

    MoonCharge 与以下作品功能不重合:

    • ggbond44439/moonloom:Multiformats 内容寻址、CID 与 Multiaddr;
    • ggbond44439/moon_geocodec:WKT/WKB/GeoJSON 几何交换;
    • ggbond44439/xbrlens:XBRL 财报事实与计算关系;
    • MoonCakes 当前已有的 HTTP、MQTT、CAN/DBC 和智能充电无关的通用 JSON 库。

    MoonCharge 关注的是 OCPP 的充电域消息语义、交易不变量和功率策略。

    更细的动作覆盖矩阵与边界见 docs/coverage.md,版本变更见 CHANGELOG.md。

    #License

    Apache-2.0

    ProtocolFailure

    pub(all) suberror ProtocolFailure {
    Failure(ProtocolError)
    }

    Internal typed parsing failure used to keep payload codec code linear.

    AuthorizationStatus

    pub(all) enum AuthorizationStatus {
    Accepted
    Blocked
    Expired
    Invalid
    ConcurrentTx
    } derive(Eq,
    Debug
    )

    AuthorizationStatus::equal

    AuthorizationStatus::not_equal

    AuthorizeRequest

    pub(all) struct AuthorizeRequest {
    id_tag : String
    } derive(Eq,
    Debug
    )

    AuthorizeRequest::equal

    AuthorizeRequest::from_json

    AuthorizeRequest::not_equal

    fn AuthorizeRequest::not_equal(x : AuthorizeRequest, y : AuthorizeRequest) -> Bool

    AuthorizeRequest::to_json

    AuthorizeResponse

    pub(all) struct AuthorizeResponse {
    id_tag_info : IdTagInfo
    } derive(Eq,
    Debug
    )

    AuthorizeResponse::equal

    AuthorizeResponse::from_json

    AuthorizeResponse::not_equal

    fn AuthorizeResponse::not_equal(x : AuthorizeResponse, y : AuthorizeResponse) -> Bool

    AuthorizeResponse::to_json

    AvailabilityType

    pub(all) enum AvailabilityType {
    Operative
    Inoperative
    } derive(Eq,
    Debug
    )

    AvailabilityType::equal

    AvailabilityType::not_equal

    fn AvailabilityType::not_equal(x : AvailabilityType, y : AvailabilityType) -> Bool

    BootNotificationRequest

    pub(all) struct BootNotificationRequest {
    charge_point_vendor : String
    charge_point_model : String
    charge_point_serial_number : String?
    charge_point_firmware_version : String?
    meter_type : String?
    meter_serial_number : String?
    iccid : String?
    imsi : String?
    } derive(Eq,
    Debug
    )

    BootNotificationRequest::equal

    BootNotificationRequest::not_equal

    BootNotificationRequest::to_json

    BootNotificationResponse

    pub(all) struct BootNotificationResponse {
    status : RegistrationStatus
    current_time : String
    heartbeat_interval : Int
    } derive(Eq,
    Debug
    )

    BootNotificationResponse::equal

    BootNotificationResponse::not_equal

    BootNotificationResponse::to_json

    ChangeAvailabilityRequest

    pub(all) struct ChangeAvailabilityRequest {
    connector_id : Int
    kind : AvailabilityType
    } derive(Eq,
    Debug
    )

    ChangeAvailabilityRequest::equal

    ChangeAvailabilityRequest::not_equal

    ChangeAvailabilityRequest::to_json

    ChangeAvailabilityResponse

    pub(all) struct ChangeAvailabilityResponse {
    status : RemoteCommandStatus
    } derive(Eq,
    Debug
    )

    ChangeAvailabilityResponse::equal

    ChangeAvailabilityResponse::not_equal

    ChangeAvailabilityResponse::to_json

    ChangeConfigurationRequest

    pub(all) struct ChangeConfigurationRequest {
    key : String
    value : String
    } derive(Eq,
    Debug
    )

    ChangeConfigurationRequest::equal

    ChangeConfigurationRequest::not_equal

    ChangeConfigurationRequest::to_json

    ChangeConfigurationResponse

    pub(all) struct ChangeConfigurationResponse {
    status : ConfigurationStatus
    } derive(Eq,
    Debug
    )

    ChangeConfigurationResponse::not_equal

    ChangeConfigurationResponse::to_json

    ChargePointErrorCode

    pub(all) enum ChargePointErrorCode {
    NoError
    ConnectorLockFailure
    EVCommunicationError
    GroundFailure
    HighTemperature
    InternalError
    LocalListConflict
    OtherError
    OverCurrentFailure
    PowerMeterFailure
    PowerSwitchFailure
    ReaderFailure
    ResetFailure
    UnderVoltage
    WeakSignal
    } derive(Eq,
    Debug
    )

    ChargePointErrorCode::equal

    ChargePointErrorCode::not_equal

    ChargePointStatus

    pub(all) enum ChargePointStatus {
    Available
    Preparing
    Charging
    SuspendedEV
    SuspendedEVSE
    Finishing
    Reserved
    Unavailable
    Faulted
    } derive(Eq,
    Debug
    )

    ChargePointStatus::equal

    ChargePointStatus::name

    fn ChargePointStatus::name(self : ChargePointStatus) -> String

    ChargePointStatus::not_equal

    fn ChargePointStatus::not_equal(x : ChargePointStatus, y : ChargePointStatus) -> Bool

    ChargePointStatus::parse

    fn ChargePointStatus::parse(value : String) -> ChargePointStatus?

    ChargingDecision

    pub(all) struct ChargingDecision {
    limit : Double
    unit : ChargingRateUnit
    profile_id : Int
    capped_by_charge_point_max : Bool
    } derive(Eq,
    Debug
    )

    ChargingDecision::equal

    ChargingDecision::not_equal

    fn ChargingDecision::not_equal(x : ChargingDecision, y : ChargingDecision) -> Bool

    ChargingProfile

    pub(all) struct ChargingProfile {
    charging_profile_id : Int
    transaction_id : Int?
    stack_level : Int
    charging_profile_purpose : ChargingProfilePurpose
    charging_profile_kind : ChargingProfileKind
    recurrency_kind : String?
    valid_from : String?
    valid_to : String?
    charging_schedule : ChargingSchedule
    } derive(Eq,
    Debug
    )

    ChargingProfile::equal

    ChargingProfile::from_json

    ChargingProfile::not_equal

    fn ChargingProfile::not_equal(x : ChargingProfile, y : ChargingProfile) -> Bool

    ChargingProfile::to_json

    ChargingProfileError

    pub(all) enum ChargingProfileError {
    NoActiveProfile
    RateUnitMismatch
    InvalidElapsedTime
    } derive(Eq,
    Debug
    )

    ChargingProfileError::equal

    ChargingProfileError::not_equal

    ChargingProfileKind

    pub(all) enum ChargingProfileKind {
    Absolute
    Recurring
    Relative
    } derive(Eq,
    Debug
    )

    ChargingProfileKind::equal

    ChargingProfileKind::not_equal

    ChargingProfilePurpose

    pub(all) enum ChargingProfilePurpose {
    ChargePointMaxProfile
    TxDefaultProfile
    TxProfile
    } derive(Eq,
    Debug
    )

    ChargingProfilePurpose::equal

    ChargingProfilePurpose::not_equal

    ChargingProfileStatus

    pub(all) enum ChargingProfileStatus {
    Accepted
    Rejected
    NotSupported
    } derive(Eq,
    Debug
    )

    ChargingProfileStatus::equal

    ChargingProfileStatus::not_equal

    ChargingRateUnit

    pub(all) enum ChargingRateUnit {
    Amps
    Watts
    } derive(Eq,
    Debug
    )

    ChargingRateUnit::equal

    ChargingRateUnit::not_equal

    fn ChargingRateUnit::not_equal(x : ChargingRateUnit, y : ChargingRateUnit) -> Bool

    ChargingSchedule

    pub(all) struct ChargingSchedule {
    start_schedule : String?
    duration : Int?
    min_charging_rate : Double?
    charging_rate_unit : ChargingRateUnit
    periods : Array[ChargingSchedulePeriod]
    } derive(Eq,
    Debug
    )

    ChargingSchedule::equal

    ChargingSchedule::from_json

    ChargingSchedule::not_equal

    fn ChargingSchedule::not_equal(x : ChargingSchedule, y : ChargingSchedule) -> Bool

    ChargingSchedule::to_json

    ChargingSchedulePeriod

    pub(all) struct ChargingSchedulePeriod {
    start_period : Int
    limit : Double
    number_phases : Int?
    } derive(Eq,
    Debug
    )

    ChargingSchedulePeriod::equal

    ChargingSchedulePeriod::not_equal

    ChargingSchedulePeriod::to_json

    ChargingTransaction

    pub(all) struct ChargingTransaction {
    transaction_id : Int
    id_tag : String
    meter_start : Int
    start_timestamp : String
    meter_stop : Int?
    stop_timestamp : String?
    stop_reason : StopReason?
    } derive(Eq,
    Debug
    )

    ChargingTransaction::equal

    ChargingTransaction::not_equal

    ClearChargingProfileRequest

    pub(all) struct ClearChargingProfileRequest {
    id : Int?
    connector_id : Int?
    charging_profile_purpose : ChargingProfilePurpose?
    stack_level : Int?
    } derive(Eq,
    Debug
    )

    ClearChargingProfileRequest::not_equal

    ClearChargingProfileRequest::to_json

    ClearChargingProfileResponse

    pub(all) struct ClearChargingProfileResponse {
    status : ClearChargingProfileStatus
    } derive(Eq,
    Debug
    )

    ClearChargingProfileResponse::not_equal

    ClearChargingProfileResponse::to_json

    ClearChargingProfileStatus

    pub(all) enum ClearChargingProfileStatus {
    Accepted
    Unknown
    } derive(Eq,
    Debug
    )

    ClearChargingProfileStatus::equal

    ClearChargingProfileStatus::not_equal

    CliOutput

    pub(all) struct CliOutput {
    stdout : String
    stderr : String
    exit_code : Int
    }

    ConfigurationKey

    pub(all) struct ConfigurationKey {
    key : String
    is_readonly : Bool
    value : String?
    } derive(Eq,
    Debug
    )

    ConfigurationKey::equal

    ConfigurationKey::from_json

    ConfigurationKey::not_equal

    fn ConfigurationKey::not_equal(x : ConfigurationKey, y : ConfigurationKey) -> Bool

    ConfigurationKey::to_json

    ConfigurationStatus

    pub(all) enum ConfigurationStatus {
    Accepted
    Rejected
    RebootRequired
    NotSupported
    } derive(Eq,
    Debug
    )

    ConfigurationStatus::equal

    ConfigurationStatus::not_equal

    ConnectorSession

    pub(all) struct ConnectorSession {
    connector_id : Int
    status : ChargePointStatus
    transaction : ChargingTransaction?
    } derive(Eq,
    Debug
    )

    ConnectorSession::apply_status

    ConnectorSession::begin_charging

    ConnectorSession::begin_transaction

    fn ConnectorSession::begin_transaction(self : ConnectorSession, transaction_id : Int, id_tag : String, meter_start : Int, timestamp : String) -> Result[ConnectorSession, SessionError]

    ConnectorSession::equal

    ConnectorSession::finish_transaction

    fn ConnectorSession::finish_transaction(self : ConnectorSession, transaction_id : Int, meter_stop : Int, timestamp : String, reason : StopReason?) -> Result[ConnectorSession, SessionError]

    ConnectorSession::mark_faulted

    ConnectorSession::new

    fn ConnectorSession::new(connector_id : Int) -> Result[ConnectorSession, SessionError]

    ConnectorSession::not_equal

    fn ConnectorSession::not_equal(x : ConnectorSession, y : ConnectorSession) -> Bool

    ConnectorSession::release_transaction

    fn ConnectorSession::release_transaction(self : ConnectorSession, transaction_id : Int) -> Result[ConnectorSession, SessionError]

    DataTransferRequest

    pub(all) struct DataTransferRequest {
    vendor_id : String
    message_id : String?
    data : String?
    } derive(Eq,
    Debug
    )

    DataTransferRequest::equal

    DataTransferRequest::from_json

    DataTransferRequest::not_equal

    DataTransferRequest::to_json

    DataTransferResponse

    pub(all) struct DataTransferResponse {
    status : DataTransferStatus
    data : String?
    } derive(Eq,
    Debug
    )

    DataTransferResponse::equal

    DataTransferResponse::from_json

    DataTransferResponse::not_equal

    DataTransferResponse::to_json

    DataTransferStatus

    pub(all) enum DataTransferStatus {
    Accepted
    Rejected
    UnknownMessageId
    UnknownVendorId
    } derive(Eq,
    Debug
    )

    DataTransferStatus::equal

    DataTransferStatus::not_equal

    DispatchError

    pub(all) enum DispatchError {
    NotACall
    InvalidAction(ProtocolError)
    WrongDirection(MessageDirection, MessageDirection)
    InvalidPayload(ProtocolError)
    } derive(Eq,
    Debug
    )

    DispatchError::equal

    DispatchError::not_equal

    fn DispatchError::not_equal(x : DispatchError, y : DispatchError) -> Bool

    Frame

    A decoded OCPP 1.6J WebSocket frame.

    Frame::encode

    fn Frame::encode(self : Frame) -> String

    Frame::equal

    fn Frame::equal(Frame, Frame) -> Bool

    Frame::not_equal

    fn Frame::not_equal(x : Frame, y : Frame) -> Bool

    Frame::to_json

    Frame::to_repr

    GetConfigurationRequest

    pub(all) struct GetConfigurationRequest {
    keys : Array[String]
    } derive(Eq,
    Debug
    )

    GetConfigurationRequest::equal

    GetConfigurationRequest::not_equal

    GetConfigurationRequest::to_json

    GetConfigurationResponse

    pub(all) struct GetConfigurationResponse {
    configuration_key : Array[ConfigurationKey]
    unknown_key : Array[String]
    } derive(Eq,
    Debug
    )

    GetConfigurationResponse::equal

    GetConfigurationResponse::not_equal

    GetConfigurationResponse::to_json

    HeartbeatResponse

    pub(all) struct HeartbeatResponse {
    current_time : String
    } derive(Eq,
    Debug
    )

    HeartbeatResponse::equal

    HeartbeatResponse::from_json

    HeartbeatResponse::not_equal

    fn HeartbeatResponse::not_equal(x : HeartbeatResponse, y : HeartbeatResponse) -> Bool

    HeartbeatResponse::to_json

    IdTagInfo

    pub(all) struct IdTagInfo {
    status : AuthorizationStatus
    expiry_date : String?
    parent_id_tag : String?
    } derive(Eq,
    Debug
    )

    IdTagInfo::equal

    fn IdTagInfo::equal(IdTagInfo, IdTagInfo) -> Bool

    IdTagInfo::from_json

    IdTagInfo::not_equal

    fn IdTagInfo::not_equal(x : IdTagInfo, y : IdTagInfo) -> Bool

    IdTagInfo::to_json

    MessageDirection

    pub(all) enum MessageDirection {
    ChargePointToCentralSystem
    CentralSystemToChargePoint
    } derive(Eq,
    Debug
    )

    Direction of an OCPP 1.6J action.

    MessageDirection::equal

    MessageDirection::not_equal

    fn MessageDirection::not_equal(x : MessageDirection, y : MessageDirection) -> Bool

    MessageId

    pub(all) enum MessageId {
    Text(String)
    Number(String)
    Null
    } derive(Eq,
    Debug
    )

    A JSON-RPC id. Numeric ids keep their exact source spelling.

    MessageId::equal

    fn MessageId::equal(MessageId, MessageId) -> Bool

    MessageId::not_equal

    fn MessageId::not_equal(x : MessageId, y : MessageId) -> Bool

    MessageId::to_json

    MeterValue

    pub(all) struct MeterValue {
    timestamp : String
    sampled_value : Array[SampledValue]
    } derive(Eq,
    Debug
    )

    MeterValue::equal

    fn MeterValue::equal(MeterValue, MeterValue) -> Bool

    MeterValue::from_json

    MeterValue::not_equal

    fn MeterValue::not_equal(x : MeterValue, y : MeterValue) -> Bool

    MeterValue::to_json

    MeterValuesRequest

    pub(all) struct MeterValuesRequest {
    connector_id : Int
    transaction_id : Int?
    meter_value : Array[MeterValue]
    } derive(Eq,
    Debug
    )

    MeterValuesRequest::equal

    MeterValuesRequest::from_json

    MeterValuesRequest::not_equal

    MeterValuesRequest::to_json

    OcppAction

    pub(all) enum OcppAction {
    Authorize
    BootNotification
    DataTransfer
    DiagnosticsStatusNotification
    FirmwareStatusNotification
    Heartbeat
    MeterValues
    StartTransaction
    StatusNotification
    StopTransaction
    CancelReservation
    ChangeAvailability
    ChangeConfiguration
    ClearCache
    GetConfiguration
    RemoteStartTransaction
    RemoteStopTransaction
    Reset
    SetChargingProfile
    UnlockConnector
    } derive(Eq,
    Debug
    )

    Supported OCPP 1.6J action names. Requests and confirmations share an action name but travel in opposite directions.

    OcppAction::equal

    fn OcppAction::equal(OcppAction, OcppAction) -> Bool

    OcppAction::name

    fn OcppAction::name(self : OcppAction) -> String

    OcppAction::not_equal

    fn OcppAction::not_equal(x : OcppAction, y : OcppAction) -> Bool

    OcppAction::parse

    fn OcppAction::parse(value : String) -> OcppAction?

    OcppAction::request_direction

    fn OcppAction::request_direction(self : OcppAction) -> MessageDirection

    ProtocolError

    pub(all) enum ProtocolError {
    InvalidJson
    FrameMustBeArray
    UnsupportedFrameType(Int)
    InvalidFrameLength(Int)
    InvalidMessageId
    InvalidAction
    InvalidPayload
    MissingField(String)
    InvalidField(String)
    UnsupportedValue(String, String)
    } derive(Eq,
    Debug
    )

    Faults detected while decoding an OCPP JSON-RPC frame or payload.

    ProtocolError::equal

    ProtocolError::message

    fn ProtocolError::message(self : ProtocolError) -> String

    ProtocolError::not_equal

    fn ProtocolError::not_equal(x : ProtocolError, y : ProtocolError) -> Bool

    ProtocolError::output

    fn ProtocolError::output(self : ProtocolError, logger : &Logger) -> Unit

    ProtocolError::to_string

    fn ProtocolError::to_string(self : ProtocolError) -> String

    RegistrationStatus

    pub(all) enum RegistrationStatus {
    Accepted
    Pending
    Rejected
    } derive(Eq,
    Debug
    )

    RegistrationStatus::equal

    RegistrationStatus::not_equal

    RemoteCommandStatus

    pub(all) enum RemoteCommandStatus {
    Accepted
    Rejected
    } derive(Eq,
    Debug
    )

    RemoteCommandStatus::equal

    RemoteCommandStatus::not_equal

    RemoteStartTransactionRequest

    pub(all) struct RemoteStartTransactionRequest {
    id_tag : String
    connector_id : Int?
    charging_profile : ChargingProfile?
    } derive(Eq,
    Debug
    )

    RemoteStartTransactionRequest::not_equal

    RemoteStartTransactionRequest::to_json

    RemoteStartTransactionResponse

    pub(all) struct RemoteStartTransactionResponse {
    status : RemoteCommandStatus
    } derive(Eq,
    Debug
    )

    RemoteStopTransactionRequest

    pub(all) struct RemoteStopTransactionRequest {
    transaction_id : Int
    } derive(Eq,
    Debug
    )

    RemoteStopTransactionRequest::not_equal

    RemoteStopTransactionRequest::to_json

    RemoteStopTransactionResponse

    pub(all) struct RemoteStopTransactionResponse {
    status : RemoteCommandStatus
    } derive(Eq,
    Debug
    )

    RemoteStopTransactionResponse::not_equal

    RemoteStopTransactionResponse::to_json

    ResetRequest

    pub(all) struct ResetRequest {
    kind : ResetType
    } derive(Eq,
    Debug
    )

    ResetRequest::equal

    ResetRequest::from_json

    ResetRequest::not_equal

    fn ResetRequest::not_equal(x : ResetRequest, y : ResetRequest) -> Bool

    ResetRequest::to_json

    ResetResponse

    pub(all) struct ResetResponse {
    status : RemoteCommandStatus
    } derive(Eq,
    Debug
    )

    ResetResponse::equal

    ResetResponse::from_json

    ResetResponse::not_equal

    fn ResetResponse::not_equal(x : ResetResponse, y : ResetResponse) -> Bool

    ResetResponse::to_json

    ResetType

    pub(all) enum ResetType {
    Hard
    Soft
    } derive(Eq,
    Debug
    )

    ResetType::equal

    fn ResetType::equal(ResetType, ResetType) -> Bool

    ResetType::not_equal

    fn ResetType::not_equal(x : ResetType, y : ResetType) -> Bool

    RpcError

    pub(all) struct RpcError {
    code : RpcErrorCode
    description : String
    details :
    Json

    } derive(Eq,
    Debug
    )

    RpcError::equal

    fn RpcError::equal(RpcError, RpcError) -> Bool

    RpcError::not_equal

    fn RpcError::not_equal(x : RpcError, y : RpcError) -> Bool

    RpcError::to_repr

    RpcErrorCode

    pub(all) enum RpcErrorCode {
    NotImplemented
    NotSupported
    InternalError
    ProtocolError
    SecurityError
    FormationViolation
    PropertyConstraintViolation
    OccurrenceConstraintViolation
    TypeConstraintViolation
    GenericError
    Unknown(String)
    } derive(Eq,
    Debug
    )

    OCPP-defined JSON-RPC error codes plus forward-compatible unknown codes.

    RpcErrorCode::equal

    RpcErrorCode::not_equal

    fn RpcErrorCode::not_equal(x : RpcErrorCode, y : RpcErrorCode) -> Bool

    RpcErrorCode::parse

    fn RpcErrorCode::parse(value : String) -> RpcErrorCode

    RpcErrorCode::to_string

    fn RpcErrorCode::to_string(self : RpcErrorCode) -> String

    SampledValue

    pub(all) struct SampledValue {
    value : String
    context : String?
    format : String?
    measurand : String?
    phase : String?
    location : String?
    unit : String?
    } derive(Eq,
    Debug
    )

    SampledValue::equal

    SampledValue::from_json

    SampledValue::not_equal

    fn SampledValue::not_equal(x : SampledValue, y : SampledValue) -> Bool

    SampledValue::to_json

    SessionError

    pub(all) enum SessionError {
    InvalidConnectorId(Int)
    TransactionAlreadyActive(Int)
    NoActiveTransaction(Int)
    TransactionMismatch(Int, Int)
    TransactionIdAlreadyUsed(Int)
    MeterRegression(Int, Int)
    InvalidIdTag
    } derive(Eq,
    Debug
    )

    SessionError::equal

    SessionError::not_equal

    fn SessionError::not_equal(x : SessionError, y : SessionError) -> Bool

    SetChargingProfileRequest

    pub(all) struct SetChargingProfileRequest {
    connector_id : Int
    cs_charging_profiles : ChargingProfile
    } derive(Eq,
    Debug
    )

    SetChargingProfileRequest::equal

    SetChargingProfileRequest::not_equal

    SetChargingProfileRequest::to_json

    SetChargingProfileResponse

    pub(all) struct SetChargingProfileResponse {
    status : ChargingProfileStatus
    } derive(Eq,
    Debug
    )

    SetChargingProfileResponse::equal

    SetChargingProfileResponse::not_equal

    SetChargingProfileResponse::to_json

    StartTransactionRequest

    pub(all) struct StartTransactionRequest {
    connector_id : Int
    id_tag : String
    meter_start : Int
    reservation_id : Int?
    timestamp : String
    } derive(Eq,
    Debug
    )

    StartTransactionRequest::equal

    StartTransactionRequest::not_equal

    StartTransactionRequest::to_json

    StartTransactionResponse

    pub(all) struct StartTransactionResponse {
    transaction_id : Int
    id_tag_info : IdTagInfo
    } derive(Eq,
    Debug
    )

    StartTransactionResponse::equal

    StartTransactionResponse::not_equal

    StartTransactionResponse::to_json

    StatusNotificationRequest

    pub(all) struct StatusNotificationRequest {
    connector_id : Int
    error_code : ChargePointErrorCode
    status : ChargePointStatus
    timestamp : String?
    info : String?
    vendor_id : String?
    vendor_error_code : String?
    } derive(Eq,
    Debug
    )

    StatusNotificationRequest::equal

    StatusNotificationRequest::not_equal

    StatusNotificationRequest::to_json

    StopReason

    pub(all) enum StopReason {
    EmergencyStop
    EVDisconnected
    HardReset
    Local
    Other
    PowerLoss
    Reboot
    Remote
    SoftReset
    UnlockCommand
    DeAuthorized
    } derive(Eq,
    Debug
    )

    StopReason::equal

    fn StopReason::equal(StopReason, StopReason) -> Bool

    StopReason::not_equal

    fn StopReason::not_equal(x : StopReason, y : StopReason) -> Bool

    StopTransactionRequest

    pub(all) struct StopTransactionRequest {
    transaction_id : Int
    meter_stop : Int
    timestamp : String
    reason : StopReason?
    id_tag : String?
    } derive(Eq,
    Debug
    )

    StopTransactionRequest::equal

    StopTransactionRequest::not_equal

    StopTransactionRequest::to_json

    TypedCall

    pub(all) enum TypedCall {
    Authorize(AuthorizeRequest)
    BootNotification(BootNotificationRequest)
    DataTransfer(DataTransferRequest)
    StatusNotification(StatusNotificationRequest)
    StartTransaction(StartTransactionRequest)
    StopTransaction(StopTransactionRequest)
    MeterValues(MeterValuesRequest)
    RemoteStartTransaction(RemoteStartTransactionRequest)
    RemoteStopTransaction(RemoteStopTransactionRequest)
    Reset(ResetRequest)
    ChangeAvailability(ChangeAvailabilityRequest)
    ChangeConfiguration(ChangeConfigurationRequest)
    GetConfiguration(GetConfigurationRequest)
    SetChargingProfile(SetChargingProfileRequest)
    ClearChargingProfile(ClearChargingProfileRequest)
    UnsupportedAction(String,
    Json
    )
    } derive(Eq,
    Debug
    )

    TypedCall::action_name

    fn TypedCall::action_name(self : TypedCall) -> String

    TypedCall::equal

    fn TypedCall::equal(TypedCall, TypedCall) -> Bool

    TypedCall::not_equal

    fn TypedCall::not_equal(x : TypedCall, y : TypedCall) -> Bool

    action_direction

    fn action_direction(action : String, is_request : Bool) -> Result[MessageDirection, ProtocolError]

    dispatch_call

    fn dispatch_call(frame : Frame, received_at : MessageDirection) -> Result[TypedCall, DispatchError]

    Decodes a CALL into a typed request after checking that it arrived from the direction defined by OCPP 1.6J. Unknown but well-formed actions are returned as UnsupportedAction so gateways can implement extensions without silently dropping the payload.

    evaluate_charging_profiles

    fn evaluate_charging_profiles(profiles : Array[ChargingProfile], transaction_id : Int?, elapsed_seconds : Int) -> Result[ChargingDecision, ChargingProfileError]

    Selects the active transaction profile and applies the active charge-point maximum profile as a cap. elapsed_seconds is measured from each profile's own schedule start; the caller owns wall-clock and time-zone handling.

    parse_frame

    fn parse_frame(text : String) -> Result[Frame, ProtocolError]

    Parses one OCPP WebSocket text frame with strict structural validation.

    run_cli

    fn run_cli(args : Array[String]) -> CliOutput