AtnActorBase

AtnActorBase

This class should not be initialized directly.

class gwatn.atn_actor_base.AtnActorBase(settings, use_algo=False)
Parameters:
  • settings (AtnSettings) –

  • use_algo (bool) –

check_for_dispatch_contract()

Upon startup, see if already party of a dispatch contract, and if so start up the dc_client and set the dc_app_id

hb_to_scada()

Checks that Atn is in Dispatch Contract, sends a HeartbeatB to Scada, and then reports to DispatchContract

heartbeat_from_scada(ping)

This is the Atn’s half of the DispatchContract Heartbeat pattern. It:

  • Checks that it has opted into a DispatchContract

  • Checks the FromGNodeInstanceId to validate Scada credentials

  • Checks that the scada correctly repeated last sent hex

  • Updates the last hex received (for use at the top of the next minute) along w time received

[more info](https://gridworks.readthedocs.io/en/latest/dispatch-contract.html)

Parameters:
  • payload (HeartbeatB) – The latest heartbeat received from its

  • partner (SCADA) –

  • ping (HeartbeatB) –

Return type:

None

in_dispatch_contract()

Checks that bootstrap 2 was completed w addition of ta_trading_rights_idx, and also that Scada is opted in

Return type:

bool

join_dispatch_contract_from_scada(payload)

Bootstraps the DispatchContract, opts in, and sends back DispatchContractConfirmed

  • ignores if already opted into a DispatchContract

  • Until World registry is in place, update g node instance id and write to .env

  • sets up ApplicationClient using the app_id sent by the scada

  • Checks that scada bootstrapping is done (contract has ta_alias and scada_cert_idx)

  • Check that our Atn acct owns the TaTradingRights for this TaAlias

Parameters:

payload (JoinDispatchContract) –

Return type:

None

local_rabbit_startup()

This should be overwritten in derived class for any additional rabbit bindings. DO NOT start queues here

Return type:

None

prepare_for_death()

Once the agent is ready for its comms to be shut down it sets actor_main_stopped to True. Write stoic code, with your agents ready for death at all times. However, if there are threads running beyond the two designed for publishing and consuming messages, shut those down in this method.

Return type:

None

route_scada_message(from_alias, message)

Routes messages from the SCADA to methods that should be overwritten in derived class

Parameters:
  • from_alias (str) –

  • message (Message) –

Return type:

None

property scada_alias

Add scada from the end of the Atn’s’s GNodeAlias

snap()

Ask SCADA for a snapshot of the current state of the TerminalAsset

property ta_alias

Add ta to the and of the Atn’s GNodeAlias

turn_off(relay_node_name)

Turn OFF a relay (i.e. closes the electrical circuit so that current can flow), using the name of the relay as represented in the hardware layout as a Spaceheat Node with role “BooleanActuator”

[SpaceheatNode](https://gridworks-protocol.readthedocs.io/en/latest/spaceheat-node.html) [BooleanActuator Role](https://gridworks-protocol.readthedocs.io/en/latest/enums.html#gwproto.enums.Role) :param relay_node_name: the name of the relay, as string in LeftRightDot format. This must be the :type relay_node_name: str :param name of a SpaceheatNode in the hardware layout with role “BooleanActuator”:

Returns:

None

Parameters:

relay_node_name (str) –

Return type:

None

turn_on(relay_node_name)

Turn ON a relay (i.e. closes the electrical circuit so that current can flow), using the name of the relay as represented in the hardware layout as a Spaceheat Node with role “BooleanActuator”

[SpaceheatNode](https://gridworks-protocol.readthedocs.io/en/latest/spaceheat-node.html) [BooleanActuator Role](https://gridworks-protocol.readthedocs.io/en/latest/enums.html#gwproto.enums.Role) :param relay_node_name: the name of the relay, as string in LeftRightDot format. This must be the :param name of a SpaceheatNode in the hardware layout with role “BooleanActuator”:

Returns:

None

Parameters:

relay_node_name (str) –

Return type:

None

update_trading_rights()

Look at address to find our trading rights

Return type:

None