-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from Nasar165/stop-transaction
add stop transaction
- Loading branch information
Showing
6 changed files
with
95 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
interface IStopTransactionRes {} | ||
|
||
interface IStopTransaction { | ||
idTag: string; | ||
transactionId: number; | ||
meterStop: number; | ||
timestamp: Date; | ||
} | ||
|
||
export type { IStopTransaction, IStopTransactionRes }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { IWriter } from '../../websocket/websocket.model'; | ||
import { StatusNotification } from '../command/status-notification/status.notification'; | ||
import { Action, CreateRequestFrame, GetRequestFrame } from '../ocpp.action'; | ||
import { ChangeState } from '../ocpp.handler'; | ||
import { CreateTransaction } from '../transaction/transaction.handler'; | ||
import { ResetSession } from './start.transaction'; | ||
import { IStopTransaction } from './stop.transaction.model'; | ||
|
||
function SendStopTransaction( | ||
w: IWriter, | ||
transactionId: number, | ||
idTag: string, | ||
meterStop: number, | ||
changeState: ChangeState | ||
): void { | ||
const transaction: IStopTransaction = { | ||
idTag, | ||
transactionId, | ||
meterStop: meterStop, | ||
timestamp: new Date(), | ||
}; | ||
|
||
const frame = CreateRequestFrame(Action.STOP_TRANSACTION, transaction); | ||
w.Write(frame); | ||
CreateTransaction(GetRequestFrame(frame), StopTransaction); | ||
changeState(StatusNotification.AVAILABLE); | ||
ResetSession(); | ||
} | ||
|
||
function StopTransaction(): void { | ||
console.log('stop transaction was received'); | ||
} | ||
|
||
export { SendStopTransaction, StopTransaction }; |