Documentation
¶
Index ¶
- Constants
- func CreateFailResponse(description string) string
- func CreateSuccessResponse(reference string) []byte
- func GetChargerStatusAPI(chargerName string, serverConfigs *Configs, log *logging.Log, ...)
- func GetMessageStatusAPI(reference string, MQueue *SimpleMessageQueue, log *logging.Log, ...)
- func TriggerActionAPI(serverConfigs *Configs, MQueue *SimpleMessageQueue, log *logging.Log, ...)
- type APIResponse
- type Charger
- type ChargerFromFile
- type Configs
- type FileConfigs
- type Message
- type OCPPHandlers
- func (cs *OCPPHandlers) Authorisation(chargerName string, request *http.Request) bool
- func (cs *OCPPHandlers) AuthorizeRequestHandler(callMessage messages.CallMessage) (string, error, bool)
- func (cs *OCPPHandlers) AuthorizeResponseHandler(callResultMessage messages.CallResultMessage) (error, bool)
- func (cs *OCPPHandlers) BootNotificationRequestHandler(callMessage messages.CallMessage) (string, error, bool)
- func (cs *OCPPHandlers) GetActionHandler(uniqueID string) string
- func (cs *OCPPHandlers) HeartbeatRequestHandler(callMessage messages.CallMessage) (string, error, bool)
- func (cs *OCPPHandlers) OCPPErrorHandler(callErrortMessage messages.CallErrorMessage) (error, bool)
- type QueueMessageType
- type SimpleMessageQueue
- func (queue *SimpleMessageQueue) Add(uniqueID string, message Message) error
- func (queue *SimpleMessageQueue) DeleteByUniqueID(uniqueID string) error
- func (queue *SimpleMessageQueue) GetMessage(uniqueID string) (Message, bool)
- func (queue *SimpleMessageQueue) UpdateByUniqueID(uniqueID string, message Message) error
Constants ¶
const ( WEBSOCKET_KEEP_OPEN bool = true WEBSOCKET_CLOSE bool = false )
Variables ¶
This section is empty.
Functions ¶
func CreateFailResponse ¶ added in v0.3.0
***************************************************************************************
* * Function : CreateFailResponse * * Purpose : Create Failed API response in json format * * Input : description string - description of the failed status * * Return : string - json format of the APIResponse
func CreateSuccessResponse ¶ added in v0.3.0
***************************************************************************************
* * Function : CreateSuccessResponse * * Purpose : Create Successfull API response in json format * * Input : reference string - reference for the response * * Return : []byte - json format of the APIResponse
func GetChargerStatusAPI ¶ added in v0.3.0
func GetChargerStatusAPI(chargerName string, serverConfigs *Configs, log *logging.Log, w http.ResponseWriter)
***************************************************************************************
* * Function : GetMessageStatusAPI * * Purpose : Get message from the queue and send to the client by http * * Input : chargerName string - charger name * serverConfigs *Configs - pointer to the chargers arrays * log *logging.Log - pointer to the log * w http.ResponseWriter - http response * * Return : Nothing
func GetMessageStatusAPI ¶ added in v0.3.0
func GetMessageStatusAPI(reference string, MQueue *SimpleMessageQueue, log *logging.Log, w http.ResponseWriter)
***************************************************************************************
* * Function : GetMessageStatusAPI * * Purpose : Get message from the queue and send to the client by http * * Input : reference string - unique reference * MQueue *SimpleMessageQueue - pointer to the Message Queue * log *logging.Log - pointer to the log * w http.ResponseWriter - http response * * Return : Nothing
func TriggerActionAPI ¶ added in v0.3.0
func TriggerActionAPI(serverConfigs *Configs, MQueue *SimpleMessageQueue, log *logging.Log, ps httprouter.Params, w http.ResponseWriter)
***************************************************************************************
* * Function : TriggerActionAPI * * Purpose : Handles TriggerAction API request * * Input : serverConfigs *Configs - pointer to the chargers arrays * MQueue *SimpleMessageQueue - pointer to the Message Queue * log *logging.Log - pointer to the log * ps httprouter.Params - router parameters * w http.ResponseWriter - http response * * Return : Nothing
Types ¶
type APIResponse ¶ added in v0.3.0
type APIResponse struct { Status string `json:"status"` Reference string `json:"reference"` Description string `json:"description"` }
***************************************************************************************
- Struct : APIResponse *
- Purpose : Object handles API response parameters *
****************************************************************************************
type Charger ¶
type Charger struct { AuthToken string HeartBeatInterval int AuthConnection bool WebSocketConnected bool `json:"Connected"` InboundIP string `json:"RemoteIP"` WriteChannel chan string `json:"-"` }
***************************************************************************************
- Struct : Charger *
- Purpose : Struct handles charger parameters in the gorutines *
****************************************************************************************
func ChargerConstructor ¶ added in v0.3.0
func ChargerConstructor() Charger
***************************************************************************************
* * Function : ChargerConstructor (Constructor) * * Purpose : Creates a new instance of the Charger * * Input : Nothing * * Return : Charger object
func (*Charger) Disconnected ¶ added in v0.3.0
func (charger *Charger) Disconnected()
***************************************************************************************
* * Function : Charger::Disconnected * * Purpose : Clear Charger parameters when disconnected from socket * * Input : Nothing * * Return : Nothing
type ChargerFromFile ¶
type ChargerFromFile struct { Name string `json:"Name"` Authorization string `json:"Authorization"` HeartBeatInterval int `json:"HeartBeatInterval"` }
***************************************************************************************
- Struct : ChargerFromFile *
- Purpose : Struct handles charger's parameters from config file *
****************************************************************************************
type Configs ¶
type Configs struct { Chargers map[string]*Charger `json:"Chargers"` MaxQueueSize int `json:"MaxQueueSize"` }
***************************************************************************************
- Struct : Configs *
- Purpose : Object handles configurations from the file *
****************************************************************************************
func ServerConfigsConstructor ¶
func ServerConfigsConstructor() Configs
***************************************************************************************
* * Function : ServerConfigsConstructor (Constructor) * * Purpose : Creates a new instance of the Configs * * Input : Nothing * * Return : Configs object
func SetConfigsFromFile ¶
***************************************************************************************
* * Function : SetConfigsFromFile (Constructor) * * Purpose : Set configs struct from the file * * Input : fileName string - filename with settings for the test server * * Return : Configs - Configs object * error - error if happened
func (*Configs) GetChargerObj ¶
***************************************************************************************
* * Function : Configs::GetChargerObj * * Purpose : Get charger from the configuration structure * * Input : chargerName string - Name of the charger in the queue * * Return : Charger - charger object * error - error if happened
type FileConfigs ¶
type FileConfigs struct { Chargers []ChargerFromFile `json:"Chargers"` MaxQueueSize int `json:"MaxQueueSize"` }
***************************************************************************************
- Struct : FileConfigs *
- Purpose : Struct handles configurations from file *
****************************************************************************************
type Message ¶
type Message struct { Action string // Action of the message Received string // Message content Status QueueMessageType Sent string }
***************************************************************************************
- Struct : Message *
- Purpose : Struct handles message's parameters *
****************************************************************************************
type OCPPHandlers ¶
type OCPPHandlers struct { Charger *Charger // Charger struct which connected to the server Log logging.Log // Pointer to the log MQueue *SimpleMessageQueue // For example queue will be here }
***************************************************************************************
- Struct : OCPPHandlers *
- Purpose : Handles struct for each connected charger *
****************************************************************************************
func OCPPHandlersConstructor ¶
func OCPPHandlersConstructor() OCPPHandlers
***************************************************************************************
* * Function : OCPPHandlersConstructor (Constructor) * * Purpose : Creates a new instance of the OCPPHandlers * * Input : Nothing * * Return : OCPPHandlers object
func (*OCPPHandlers) Authorisation ¶
func (cs *OCPPHandlers) Authorisation(chargerName string, request *http.Request) bool
***************************************************************************************
* * Function : OCPPHandlers::Authorisation * * Purpose : Using to Authorise charger before allow websocket connection * * Input : chargerName string - charger name to be validated * request *http.Request - http request object * * Return : true - when charger is authorised, otherwise false *
func (*OCPPHandlers) AuthorizeRequestHandler ¶
func (cs *OCPPHandlers) AuthorizeRequestHandler(callMessage messages.CallMessage) (string, error, bool)
***************************************************************************************
* * Function : OCPPHandlers::AuthorizeRequestHandler * * Purpose : Handle AuthorizeRequest * * Input : callMessage messages.CallMessage - original Call message * * Return : string - response message in string format * error - if happened, nil otherwise * bool - false - when connection to charger needs to be closed, otherwise true *
func (*OCPPHandlers) AuthorizeResponseHandler ¶
func (cs *OCPPHandlers) AuthorizeResponseHandler(callResultMessage messages.CallResultMessage) (error, bool)
***************************************************************************************
* * Function : OCPPHandlers::AuthorizeResponseHandler * * Purpose : Handle AuthorizeResponse * * Input : callMessage messages.CallMessage - original Call message * * Return : string - response message in string format * error - if happened, nil otherwise * bool - false - when connection to charger needs to be closed, otherwise true *
func (*OCPPHandlers) BootNotificationRequestHandler ¶
func (cs *OCPPHandlers) BootNotificationRequestHandler(callMessage messages.CallMessage) (string, error, bool)
***************************************************************************************
* * Function : OCPPHandlers::BootNotificationRequestHandler * * Purpose : Handle BootNotificationRequest * * Input : callMessage messages.CallMessage - original Call message * * Return : string - response message in string format * error - if happened, nil otherwise * bool - false - when connection to charger needs to be closed, otherwise true *
func (*OCPPHandlers) GetActionHandler ¶
func (cs *OCPPHandlers) GetActionHandler(uniqueID string) string
***************************************************************************************
* * Function : OCPPHandlers::GetActionHandler * * Purpose : Get Action of the message from queue by unique ID * * Input : uniqueID string - message's unique ID * * Return : message's action in string format *
func (*OCPPHandlers) HeartbeatRequestHandler ¶
func (cs *OCPPHandlers) HeartbeatRequestHandler(callMessage messages.CallMessage) (string, error, bool)
***************************************************************************************
* * Function : OCPPHandlers::HeartbeatRequestHandler * * Purpose : Handle HeartbeatRequest * * Input : callMessage messages.CallMessage - original Call message * * Return : string - response message in string format * error - if happened, nil otherwise * bool - false - when connection to charger needs to be closed, otherwise true *
func (*OCPPHandlers) OCPPErrorHandler ¶
func (cs *OCPPHandlers) OCPPErrorHandler(callErrortMessage messages.CallErrorMessage) (error, bool)
***************************************************************************************
* * Function : OCPPHandlers::OCPPErrorHandler * * Purpose : Handle OCPP Error * * Input : callMessage messages.CallMessage - original Call message * * Return : string - response message in string format * error - if happened, nil otherwise * bool - false - when connection to charger needs to be closed, otherwise true *
type QueueMessageType ¶
type QueueMessageType int
const ( MESSAGE_TYPE_NEW QueueMessageType = 1 MESSAGE_TYPE_SENT QueueMessageType = 2 MESSAGE_TYPE_RECEIVED QueueMessageType = 3 MESSAGE_TYPE_COMPLETED QueueMessageType = 4 MESSAGE_TYPE_ERROR QueueMessageType = 5 )
type SimpleMessageQueue ¶
type SimpleMessageQueue struct { MaxSize int MessageQueue map[string]Message // contains filtered or unexported fields }
***************************************************************************************
- Struct : SimpleMessageQueue *
- Purpose : Struct handles messages queue routines *
****************************************************************************************
func SimpleMessageQueueConstructor ¶ added in v0.3.0
func SimpleMessageQueueConstructor() SimpleMessageQueue
***************************************************************************************
* * Function : SimpleMessageQueue (Constructor) * * Purpose : Creates a new instance of the SimpleMessageQueue * * Input : Nothing * * Return : SimpleMessageQueue object
func (*SimpleMessageQueue) Add ¶
func (queue *SimpleMessageQueue) Add(uniqueID string, message Message) error
***************************************************************************************
* * Function : SimpleMessageQueue::Add * * Purpose : Add message to the queue * * Input : uniqueID string - id of the message * message Message - raw message to parse and validate * * Return : error - if happened, nil otherwise *
func (*SimpleMessageQueue) DeleteByUniqueID ¶
func (queue *SimpleMessageQueue) DeleteByUniqueID(uniqueID string) error
***************************************************************************************
* * Function : SimpleMessageQueue::DeleteByUniqueID * * Purpose : Delete message from the queue by unique id * * Input : uniqueID string - id of the message * * Return : error - if happened, nil otherwise *
func (*SimpleMessageQueue) GetMessage ¶
func (queue *SimpleMessageQueue) GetMessage(uniqueID string) (Message, bool)
***************************************************************************************
* * Function : SimpleMessageQueue::GetMessage * * Purpose : Get message from the queue by unique id * * Input : uniqueID string - id of the message * * Return : Message * bool - true when message exists, false otherwise *
func (*SimpleMessageQueue) UpdateByUniqueID ¶ added in v0.3.0
func (queue *SimpleMessageQueue) UpdateByUniqueID(uniqueID string, message Message) error
***************************************************************************************
* * Function : SimpleMessageQueue::UpdateByUniqueID * * Purpose : Update message in the queue by unique id * * Input : uniqueID string - id of the message * message Message - message obj to update in the queue * * Return : error - if happened, nil otherwise *