Ejemplo n.º 1
0
    async def _on_start_transaction(
            self,
            connector_id: int,
            id_tag: str,
            meter_start: int,
            timestamp: str,
            reservation_id: int = None,
            **kwargs) -> call_result.StartTransactionPayload:
        # Check authorization on charge
        token = self._get_token(id_tag)
        if not token and not self._useage_mode == UsageMode.FREE:
            return call_result.StartTransactionPayload(
                transaction_id=0,
                id_tag_info={'status': AuthorizationStatus.blocked})

        # Get connector the charger is using
        connector = self._get_connector(connector_id)

        # Set up the in progress transaction
        transaction = InProgressTransaction(
            start_timestamp=parser.parse(timestamp),
            meter_start=meter_start,
            reservation_id=reservation_id,
            start_token=token,
            connector=connector)
        self._session.add(transaction)
        self._session.commit()

        return call_result.StartTransactionPayload(
            transaction_id=transaction.id,
            id_tag_info={'status': AuthorizationStatus.accepted})
Ejemplo n.º 2
0
 def start_transaction_notification(self, **kwargs):
     return call_result.StartTransactionPayload(
         transaction_id=111,
         id_tag_info={'expiryDate':datetime.utcnow().isoformat(),
                      'parentIdTag':'123hhh',
                      'status':AuthorizationStatus.accepted}
 )
Ejemplo n.º 3
0
 def on_start_transaction(self, connector_id, id_tag, meter_start, timestamp):
     trans_id = 987
     return call_result.StartTransactionPayload(
         transaction_id = trans_id,
         id_tag_info={
             "status" : AuthorizationStatus.accepted
         }
     )
Ejemplo n.º 4
0
 def on_start_transaction(self, connector_id, id_tag, meter_start,
                          time_stamp, reservaltion_id):
     return call_result.StartTransactionPayload(
         connectorId=connector_id,
         idTag=id_tag,
         meterStart=meter_start,
         timeStamp=time_stamp,
         reservationId=reservaltion_id)
Ejemplo n.º 5
0
    def on_start_transaction_notification(self, **kwargs):
        print("cp -> server , on_start_transaction_notification: \n", kwargs,
              "\n")
        self.export_json_file(kwargs, "./dataFromCp2Server",
                              "StartTransaction.req")

        response = call_result.StartTransactionPayload(
            transaction_id=
            11111,  # Required. This contains the transaction id supplied by the Central System.
            id_tag_info={
                'expiryDate': datetime.now().isoformat(
                ),  #Required. This contains information about authorization status, expiry and parent id.
                'parentIdTag': '123hhh',
                'status': AuthorizationStatus.accepted
            })
        self.export_json_file(response.__dict__, "./dataFromCp2Server",
                              "StartTransaction.con")
        print("server -> cp, on_start_transaction_notification: \n", response,
              "\n")

        return response
Ejemplo n.º 6
0
 def on_start_transaction(self, connector_id: int, id_tag: str,
                          meter_start: int, timestamp: str, **kwargs):
     return call_result.StartTransactionPayload(
         transaction_id=connector_id,
         id_tag_info={"status": AuthorizationStatus.accepted})
Ejemplo n.º 7
0
 def on_start_transaction ( self, **kwargs ) :
     return call_result.StartTransactionPayload(
         dict([('status', "Accepted"), ('expiryDate', "2023-09-17T10:44:33.638259"),
               ('parentIdTag', "Rajansimulator")]),
         transaction_id=1
     )