@@ -32,6 +32,7 @@ SOFTWARE.
3232#include < thread>
3333
3434using namespace ocpp ::centralsystem;
35+ using namespace ocpp ::types;
3536
3637/* * @brief Entry point */
3738int main (int argc, char * argv[])
@@ -106,6 +107,58 @@ int main(int argc, char* argv[])
106107
107108 // From now on the stack is alive :)
108109
110+ // App loop
111+ while (true )
112+ {
113+ // Wait for at least 1 connected charge point
114+ while (event_handler.chargePoints ().size () == 0 )
115+ {
116+ std::this_thread::sleep_for (std::chrono::milliseconds (250 ));
117+ }
118+
119+ // For each connected charge point
120+ for (auto & iter_chargepoint : event_handler.chargePoints ())
121+ {
122+ auto & chargepoint = iter_chargepoint.second ;
123+
124+ std::cout << " ---------------------------------------------" << std::endl;
125+ std::cout << " Charge point : " << chargepoint->identifier () << std::endl;
126+ std::cout << " ---------------------------------------------" << std::endl;
127+
128+ std::cout << " Read whole charge point configuration..." << std::endl;
129+ std::vector<std::string> keys;
130+ std::vector<KeyValue> config_keys;
131+ std::vector<std::string> unknown_keys;
132+ if (chargepoint->getConfiguration (keys, config_keys, unknown_keys))
133+ {
134+ std::cout << " Configuration keys :" << std::endl;
135+ for (const KeyValue& key_value : config_keys)
136+ {
137+ std::cout << " - " << key_value.key .str () << " = " << (key_value.value .isSet () ? key_value.value .value ().str () : " " )
138+ << " " << (key_value.readonly ? " (read-only)" : " " ) << std::endl;
139+ }
140+ }
141+ else
142+ {
143+ std::cout << " Failed!" << std::endl;
144+ }
145+
146+ std::cout << " Configure heartbeat interval..." << std::endl;
147+ ConfigurationStatus config_status = chargepoint->changeConfiguration (" HeartbeatInterval" , " 10" );
148+ std::cout << ConfigurationStatusHelper.toString (config_status) << std::endl;
149+
150+ std::cout << " Trigger status notification..." << std::endl;
151+ TriggerMessageStatus trigger_status = chargepoint->triggerMessage (MessageTrigger::StatusNotification, Optional<unsigned int >());
152+ std::cout << TriggerMessageStatusHelper.toString (trigger_status) << std::endl;
153+
154+ std::cout << " Trigger meter values on connector 0..." << std::endl;
155+ trigger_status = chargepoint->triggerMessage (MessageTrigger::MeterValues, 0 );
156+ std::cout << TriggerMessageStatusHelper.toString (trigger_status) << std::endl;
157+
158+ std::this_thread::sleep_for (std::chrono::seconds (10 ));
159+ }
160+ }
161+
109162 std::this_thread::sleep_for (std::chrono::milliseconds (5000000 ));
110163
111164 return 0 ;
0 commit comments