Examples:
+- **Authorize**
+- Request:
+ `ProcedureName`: 'authorize'
+ `PDU`: {
+ `hashIds`: charging station unique identifier strings array (optional, default: all charging stations),
+ `idTag`: RFID tag string
+ }
+
+- Response:
+ `PDU`: {
+ `status`: 'success' | 'failure',
+ `hashIdsSucceeded`: charging station unique identifier strings array,
+ `hashIdsFailed`: charging station unique identifier strings array (optional),
+ `responsesFailed`: failed responses payload array (optional)
+ }
+
- **Start Transaction**
- Request:
`ProcedureName`: 'startTransaction'
const responsesStatus =
this.responses
.get(uuid)
- ?.responses.every(({ status }) => status === ResponseStatus.SUCCESS) === true
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+ ?.responses.every(response => response?.status === ResponseStatus.SUCCESS) === true
? ResponseStatus.SUCCESS
: ResponseStatus.FAILURE
return {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
hashIdsSucceeded: this.responses
.get(uuid)
- ?.responses.map(({ hashId, status }) => {
- if (hashId != null && status === ResponseStatus.SUCCESS) {
- return hashId
+ ?.responses.map(response => {
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+ if (response?.hashId != null && response?.status === ResponseStatus.SUCCESS) {
+ return response.hashId
}
return undefined
})
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
hashIdsFailed: this.responses
.get(uuid)
- ?.responses.map(({ hashId, status }) => {
- if (hashId != null && status === ResponseStatus.FAILURE) {
- return hashId
+ ?.responses.map(response => {
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+ if (response?.hashId != null && response?.status === ResponseStatus.FAILURE) {
+ return response.hashId
}
return undefined
})
responsesFailed: this.responses
.get(uuid)
?.responses.map(response => {
- if (response.status === ResponseStatus.FAILURE) {
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+ if (response?.status === ResponseStatus.FAILURE) {
return response
}
return undefined
export enum ProtocolVersion {
'0.0.1' = '0.0.1',
}
+
export enum ResponseStatus {
FAILURE = 'failure',
SUCCESS = 'success',
</h1>
<h2>{{ chargingStationId }}</h2>
<h3>Connector {{ connectorId }}</h3>
- <p>Scan RFID tag:</p>
- <input
- id="idtag"
- v-model.trim="state.idTag"
- name="idtag"
- placeholder="RFID tag"
- type="text"
- >
+ <p>
+ RFID tag:
+ <input
+ id="idtag"
+ v-model.trim="state.idTag"
+ name="idtag"
+ placeholder="RFID tag"
+ type="text"
+ >
+ </p>
+ <p>
+ Authorize RFID tag:
+ <input
+ v-model="state.authorizeIdTag"
+ false-value="false"
+ true-value="true"
+ type="checkbox"
+ >
+ </p>
<br>
<Button
id="action-button"
@click="
() => {
- $uiClient
- ?.startTransaction(hashId, convertToInt(connectorId), state.idTag)
- .then(() => {
- $toast.success('Transaction successfully started')
- })
- .catch((error: Error) => {
- $toast.error('Error at starting transaction')
- console.error('Error at starting transaction:', error)
- })
- .finally(() => {
- $router.push({ name: 'charging-stations' })
- })
+ state.authorizeIdTag = convertToBoolean(state.authorizeIdTag)
+ if (state.authorizeIdTag) {
+ if (state.idTag == null || state.idTag.trim().length === 0) {
+ $toast.error('Please provide an RFID tag to authorize')
+ return
+ }
+ $uiClient
+ ?.authorize(hashId, state.idTag)
+ .then(() => {
+ $uiClient
+ ?.startTransaction(hashId, convertToInt(connectorId), state.idTag)
+ .then(() => {
+ $toast.success('Transaction successfully started')
+ })
+ .catch((error: Error) => {
+ $toast.error('Error at starting transaction')
+ console.error('Error at starting transaction:', error)
+ })
+ .finally(() => {
+ $router.push({ name: 'charging-stations' })
+ })
+ })
+ .catch((error: Error) => {
+ $toast.error('Error at authorizing RFID tag')
+ console.error('Error at authorizing RFID tag:', error)
+ })
+ } else {
+ $uiClient
+ ?.startTransaction(hashId, convertToInt(connectorId), state.idTag)
+ .then(() => {
+ $toast.success('Transaction successfully started')
+ })
+ .catch((error: Error) => {
+ $toast.error('Error at starting transaction')
+ console.error('Error at starting transaction:', error)
+ })
+ .finally(() => {
+ $router.push({ name: 'charging-stations' })
+ })
+ }
}
"
>
import { ref } from 'vue'
import Button from '@/components/buttons/Button.vue'
-import { convertToInt } from '@/composables'
+import { convertToBoolean, convertToInt } from '@/composables'
defineProps<{
chargingStationId: string
hashId: string
}>()
-const state = ref<{ idTag: string }>({
+const state = ref<{ authorizeIdTag: boolean; idTag: string }>({
+ authorizeIdTag: false,
idTag: '',
})
</script>
const $toast = useToast()
const stopTransaction = (): void => {
+ if (props.connector.transactionId == null) {
+ $toast.error('No transaction to stop')
+ return
+ }
uiClient
.stopTransaction(props.hashId, props.connector.transactionId)
.then(() => {
})
}
+ public async authorize (hashId: string, idTag: string): Promise<ResponsePayload> {
+ return this.sendRequest(ProcedureName.AUTHORIZE, {
+ hashIds: [hashId],
+ idTag,
+ })
+ }
+
public async closeConnection (hashId: string): Promise<ResponsePayload> {
return this.sendRequest(ProcedureName.CLOSE_CONNECTION, {
hashIds: [hashId],
export enum ProcedureName {
ADD_CHARGING_STATIONS = 'addChargingStations',
+ AUTHORIZE = 'authorize',
CLOSE_CONNECTION = 'closeConnection',
DELETE_CHARGING_STATIONS = 'deleteChargingStations',
LIST_CHARGING_STATIONS = 'listChargingStations',
export enum ProtocolVersion {
'0.0.1' = '0.0.1',
}
+
export enum ResponseStatus {
FAILURE = 'failure',
SUCCESS = 'success',