From 7fd6bcb5603d828737169e7a901e4d5d0806e750 Mon Sep 17 00:00:00 2001 From: Tylores Date: Wed, 21 Dec 2022 14:46:18 -0800 Subject: [PATCH 001/108] still need to finish up the waterheater systems using a target temps and gallon usage. --- resources/sep_xml/sep_wadl.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/sep_xml/sep_wadl.xml b/resources/sep_xml/sep_wadl.xml index fcd92a6b..887c3cf1 100644 --- a/resources/sep_xml/sep_wadl.xml +++ b/resources/sep_xml/sep_wadl.xml @@ -36,7 +36,7 @@ - The device that is providing the services being accessed. + The dev`ice that is providing the services being accessed. From b9dd3d1e0085c2aeec452429c20bd0edcab3727a Mon Sep 17 00:00:00 2001 From: Tylores Date: Wed, 21 Dec 2022 14:47:05 -0800 Subject: [PATCH 002/108] System stubs done for water heater simulator --- dtm/scripts/client_test.py | 103 +++++++++++++++++++++++++ ecs/include/world/meter.hpp | 23 ++++++ ecs/include/world/water_heater_sim.hpp | 52 +++++++++++++ ecs/meter.cpp | 14 ++++ ecs/water_heater_sim.cpp | 51 ++++++++++++ 5 files changed, 243 insertions(+) create mode 100644 dtm/scripts/client_test.py create mode 100644 ecs/include/world/meter.hpp create mode 100644 ecs/include/world/water_heater_sim.hpp create mode 100644 ecs/meter.cpp create mode 100644 ecs/water_heater_sim.cpp diff --git a/dtm/scripts/client_test.py b/dtm/scripts/client_test.py new file mode 100644 index 00000000..c6945cef --- /dev/null +++ b/dtm/scripts/client_test.py @@ -0,0 +1,103 @@ +import http.client +import urllib.request +import urllib.parse +import os +import sys +import random +import xml.etree.ElementTree as ET +from time import sleep +import datetime + +host_name = '192.168.0.178' # loopback DTM server address +host_port = 8889 +host_address = '192.168.0.178:8889' + +def makeCTACommandMsg(type): + msg = ET.Element('message') # creating an xml element structure + frm_tag = ET.SubElement(msg, 'from') # subelement + frm_tag.text = 'DCM' + to_tag = ET.SubElement(msg, 'to') # subelement + to_tag.text = 'DER' + content_tag = ET.SubElement(msg, 'content') # subelement + cmd_tag = ET.SubElement(content_tag, 'command') # subelement + type_tag = ET.SubElement(cmd_tag, 'type') + type_tag.text = str(type) + start_tag = ET.SubElement(cmd_tag, 'start') + start_tag.text = 'This afternoon' + duration_tag = ET.SubElement(cmd_tag, 'duration') + duration_tag.text = 'like half an hour?' + expect_resp = ET.SubElement(cmd_tag, 'expect_response') + expect_resp.text = 'vibes' + logged = ET.SubElement(msg, 'DCM_timestamp') + ct = datetime.datetime.now() + logged.text = str(ct) + print(ET.tostring(msg)) + return ET.tostring(msg) + +def isMsgComplete(xml_string): + tag1 = 'loopback_random_data' + tag2 = 'timestamp' + return ( tag1 in xml_string and tag2 in xml_string) + +def isBitMsgComplete(xml_bitstring): + xml_string = xml_bitstring.decode('ascii') + tag1 = 'loopback_random_data' + tag2 = 'timestamp' + return ( tag1 in xml_string and tag2 in xml_string) + +def getTemp(): + """get temp from operating system with an os.popen call + """ + traw = os.popen("/opt/vc/bin/vcgencmd measure_temp").read() + traw = traw.replace('temp=', '') + traw = traw.replace('\n', '') + traw = traw[:-2] + temp = str(traw) + return temp + +def randomStr(): + return str(round(random.uniform(0.01, 10.00), 2)) + +def make_old_temp_msg(): + ct = datetime.datetime.now() + tStamp = str(ct) + data = ET.Element('TrustLog') #creating an xml element structure + el1 = ET.SubElement(data, 'DCMContact') #subelement + el1.set('timestamp', tStamp) # timestamp is an attribute, attrib + el1.set('loopback_random_data', randomStr()) #temp is an attribute + el1.text = 'CONNECTION SUCCESSFUL' #just kinda filler + + obj_xml = ET.tostring(data) #converts xml object into a string + print(obj_xml.decode('ascii')) + print(isMsgComplete(obj_xml.decode('ascii'))) + print(isBitMsgComplete(obj_xml)) + return obj_xml + +headers = {"Content-type": "text/xml", "Accept": "text/plain"} #headers for the request + +while True: + + print("Attempting POST's") + print(" Enter sc to send complete message, si to send incomplete, f to send fake (non xml), ^ C to quit") + + try: + choice = str(input()) + if choice == 'sc': + sendDTM = http.client.HTTPConnection(host_name, host_port) + sendDTM.request('POST', host_address, makeCTACommandMsg("TEST"), headers) + sleep(1) + elif choice == 'si': + sendDTM = http.client.HTTPConnection(host_name, host_port) + sendDTM.request('POST', host_address, make_old_temp_msg(), headers) + sleep(1) + elif choice == 'f': + sendDTM = http.client.HTTPConnection(host_name, host_port) + sendDTM.request('POST', host_address, 'this is a fake non-xml message', headers) + + else: + print("incorrect choice") + + except KeyboardInterrupt: + quit() + + diff --git a/ecs/include/world/meter.hpp b/ecs/include/world/meter.hpp new file mode 100644 index 00000000..6d4b59cb --- /dev/null +++ b/ecs/include/world/meter.hpp @@ -0,0 +1,23 @@ +#ifndef __METER_H__ +#define __METER_H__ + +#include + +namespace meter +{ + struct Power { + float watts; + float vars; + }; + + struct Energy { + float watt_hours; + }; + + struct Module + { + Module(flecs::world& ecs); + }; +} // namespace meter + +#endif // __METER_H__ \ No newline at end of file diff --git a/ecs/include/world/water_heater_sim.hpp b/ecs/include/world/water_heater_sim.hpp new file mode 100644 index 00000000..6e21f290 --- /dev/null +++ b/ecs/include/world/water_heater_sim.hpp @@ -0,0 +1,52 @@ +#ifndef __WATER_HEATER_SIM_H__ +#define __WATER_HEATER_SIM_H__ + +#include +#include +#include + +namespace waterheater +{ + enum class Status { + normal, + loadup, + advanced_loadup, + shed, + critical, + emergency, + }; + + struct Threshold { + uint32_t minimum; + uint32_t maximum; + }; + + struct Nameplate { + uint32_t power; + uint32_t gallons; + uint32_t max_temperature; + Threshold normal; + Threshold loadup; + Threshold advanced_loadup; + Threshold shed; + Threshold critical; + Threshold emergency; + }; + + struct Properties { + float power; + float capacity; + }; + + struct Usage { + std::unordered_map gallons; + }; + + struct Module + { + Module(flecs::world& ecs); + }; + +} // namespace waterheater + +#endif // __WATER_HEATER_SIM_H__ \ No newline at end of file diff --git a/ecs/meter.cpp b/ecs/meter.cpp new file mode 100644 index 00000000..5365928c --- /dev/null +++ b/ecs/meter.cpp @@ -0,0 +1,14 @@ +#include "include/world/meter.hpp" + +using namespace meter; + +Module::Module (flecs::world &ecs){ + /* Register module with world */ + ecs.module(); + + /* Register components */ + ecs.component(); + ecs.component(); + + /* Register system */ +} \ No newline at end of file diff --git a/ecs/water_heater_sim.cpp b/ecs/water_heater_sim.cpp new file mode 100644 index 00000000..1ec8113d --- /dev/null +++ b/ecs/water_heater_sim.cpp @@ -0,0 +1,51 @@ +#include "include/world/water_heater_sim.hpp" +#include "include/world/meter.hpp" + +using namespace waterheater; + +float INLET_WATER_TEMP = 10; // degrees C +float AMBIENT_AIR_TEMP = 21; // degrees C +float SPECIFIC_HEAT = 4.187; // kJ/kgK +float KG_PER_GALLON = 3.79; // kg/gallon + +float fahrenheit2Celcius(const float &temperature) +{ + return (32.0 - temperature) * 5 / 9; +} + +float gallon2Kilogram(const float &gallons) +{ + return KG_PER_GALLON * gallons; +} + +float energy(const float &mass) +{ + float dt = AMBIENT_AIR_TEMP - INLET_WATER_TEMP; + return SPECIFIC_HEAT * dt * mass; +} + +Module::Module(flecs::world &ecs) +{ + /* Register module with world */ + ecs.module(); + ecs.import (); + + /* Register components */ + ecs.component(); + ecs.component(); + ecs.component(); + ecs.component(); + + /* Register system */ + ecs.system("Usage") + .term(Status::normal) + .each([](flecs::entity e, Nameplate &rating, meter::Power *power, meter::Energy *energy) { + + }); + + ecs.system("Normal") + .term(Status::normal) + .each([](flecs::entity e, Nameplate &rating, meter::Power *power, meter::Energy *energy) { + + }); +} \ No newline at end of file From 6671e4d2613a14f5c1e56726f7c9e7cf894eda2e Mon Sep 17 00:00:00 2001 From: Tylores Date: Thu, 22 Dec 2022 15:52:50 -0800 Subject: [PATCH 003/108] nearly done with the updated demo. Need to add the metering resource and then that will be most of it. --- dtm/tests/demo.cpp | 180 ++++++++++-------- dtm/trust_https/trust_https.cpp | 9 +- dtm/trust_xml/trust_xml.cpp | 10 +- ecs/include/world/uri.hpp | 4 +- ecs/world.cpp | 31 +-- resources/sep_xml/sep.xsd | 6 +- .../ieee-2030.5/tests/xml/dcap_tests.cpp | 2 + standards/ieee-2030.5/tests/xml/frp_tests.cpp | 2 +- standards/ieee-2030.5/tests/xml/frq_tests.cpp | 2 +- .../xml/device_capability_adapter.cpp | 6 +- .../ieee-2030.5/xml/response_adapter.cpp | 2 - 11 files changed, 130 insertions(+), 124 deletions(-) diff --git a/dtm/tests/demo.cpp b/dtm/tests/demo.cpp index 31734ae8..9bd1b48a 100644 --- a/dtm/tests/demo.cpp +++ b/dtm/tests/demo.cpp @@ -22,33 +22,33 @@ bool isClientCertification(const boost::filesystem::directory_entry &entry) entry.path().extension() == ".crt"; } -void generateDeviceCapabilities () +void generateDeviceCapabilities() { sep::DeviceCapability dcap; dcap.poll_rate = 900; dcap.href = "/dcap"; - dcap.customer_account_list_link.all = 0; + dcap.customer_account_list_link.all = 1; dcap.customer_account_list_link.href = "/bill"; - dcap.demand_response_program_list_link.all = 0; + dcap.demand_response_program_list_link.all = 1; dcap.demand_response_program_list_link.href = "/dr"; - dcap.der_program_list_link.all = 0; + dcap.der_program_list_link.all = 1; dcap.der_program_list_link.href = "/derp"; - dcap.file_list_link.all = 0; + dcap.file_list_link.all = 1; dcap.file_list_link.href = "/file"; - dcap.messaging_program_list_link.all = 0; + dcap.messaging_program_list_link.all = 1; dcap.messaging_program_list_link.href = "/msg"; - dcap.prepayment_list_link.all = 0; + dcap.prepayment_list_link.all = 1; dcap.prepayment_list_link.href = "/ppy"; - dcap.response_set_list_link.all = 0; + dcap.response_set_list_link.all = 1; dcap.response_set_list_link.href = "/rsps"; - dcap.tariff_profile_list_link.all = 0; + dcap.tariff_profile_list_link.all = 1; dcap.tariff_profile_list_link.href = "/tp"; dcap.time_link.href = "/tm"; - dcap.usage_point_list_link.all = 0; + dcap.usage_point_list_link.all = 1; dcap.usage_point_list_link.href = "/upt"; - dcap.end_device_list_link.all = 0; + dcap.end_device_list_link.all = 1; dcap.end_device_list_link.href = "/edev"; - dcap.mirror_usage_point_list_link.all = 0; + dcap.mirror_usage_point_list_link.all = 1; dcap.mirror_usage_point_list_link.href = "/mup"; dcap.self_device_link.href = "/sdev"; @@ -95,44 +95,7 @@ void generateEndDevice(const std::string &lfdi) AccessModule::Subject subject; subject.value = lfdi; - World::getInstance().world.entity() - .set(edev) - .set(fingerprint) - .set(subject); -}; - -void generateSelfDevice (const std::string& lfdi) -{ - sep::SelfDevice sdev; - sdev.subscribable = sep::SubscribableType::kNone; - sdev.href = "/sdev/" + lfdi; - sdev.configuration_link.href = "/cfg"; - sdev.der_list_link.all = 0; - sdev.der_list_link.href = "/der"; - sdev.device_category = sep::DeviceCategoryType::kSmartAppliance; - sdev.device_information_link.href = "/di"; - sdev.device_status_link.href = "/ds"; - sdev.file_status_link.href = "/fs"; - sdev.ip_interface_list_link.all = 0; - sdev.ip_interface_list_link.href = "/ns"; - sdev.lfdi = xml::util::Dehexify(lfdi); - sdev.load_shed_availability_list_link.all = 0; - sdev.load_shed_availability_list_link.href = "/lsl"; - sdev.log_event_list_link.all = 0; - sdev.log_event_list_link.href = "/lel"; - sdev.power_status_link.href = "/ps"; - sdev.sfdi = xml::util::getSFDI(lfdi); - - AccessModule::Fingerprint fingerprint; - fingerprint.value = lfdi; - - AccessModule::Subject subject; - subject.value = lfdi; - - World::getInstance().world.entity() - .set(sdev) - .set(fingerprint) - .set(subject); + World::getInstance().world.entity().set(edev).set(fingerprint).set(subject); }; void generateRegistration(const std::string &lfdi) @@ -149,20 +112,17 @@ void generateRegistration(const std::string &lfdi) AccessModule::Subject subject; subject.value = lfdi; - World::getInstance().world.entity() - .set(rg) - .set(fingerprint) - .set(subject); + World::getInstance().world.entity().set(rg).set(fingerprint).set(subject); }; void generateTime() { boost::posix_time::ptime local(boost::posix_time::second_clock::local_time()); boost::posix_time::ptime universal(boost::posix_time::second_clock::universal_time()); - + boost::local_time::tz_database tz_db; tz_db.load_from_file(g_program_path + "/timezone/date_time_zonespec.csv"); - + boost::local_time::time_zone_ptr tz_ptr = tz_db.time_zone_from_region("America/Los_Angeles"); boost::local_time::local_date_time ldt(local, tz_ptr); @@ -184,7 +144,7 @@ void Initialize(const std::string &doc_root) { generateDeviceCapabilities(); generateTime(); - + boost::filesystem::path p = doc_root + "/root-ca"; if (boost::filesystem::exists(p)) // does path p actually exist? { @@ -209,12 +169,11 @@ void Initialize(const std::string &doc_root) oss << std::hex << (int)md[i]; }; std::string lfdi = oss.str().substr(0, 40); - std::cout << "Registered : " << lfdi << std::endl; + std::cout << "Registered : " << lfdi << std::endl; generateEndDevice(lfdi); - generateSelfDevice(lfdi); generateRegistration(lfdi); - + X509_free(cert); fclose(fp); } @@ -241,7 +200,7 @@ void spawnGSP() { std::cout << "\tSpawning GSP...\n"; Initialize(g_program_path); - + HttpsServer server("0.0.0.0", 8080, g_program_path, 8); }; @@ -251,24 +210,91 @@ int main(int argc, char **argv) g_program_path = psu::utilities::getProgramPath(argv); std::cout << "Parent Path : " << g_program_path << std::endl; - std::thread gsp (spawnGSP); - std::thread dtm (spawnDTM, argc, argv); + std::thread gsp(spawnGSP); + std::thread dtm(spawnDTM, argc, argv); - std::this_thread::sleep_for (std::chrono::seconds(1)); + std::this_thread::sleep_for(std::chrono::seconds(1)); std::cout << "\tSpawning DCM...\n"; - https::Context gsp_ctx = {"1", g_program_path, "0.0.0.0", "8080"}; - https::Context dtm_ctx = {"1", g_program_path, "0.0.0.0", "8090"}; - auto rsp = trust::HttpsClient::getInstance(gsp_ctx, dtm_ctx).Get("/dcap"); - std::cout << rsp << std::endl; - rsp = trust::HttpsClient::getInstance().Get("/edev"); - std::cout << rsp << std::endl; - rsp = trust::HttpsClient::getInstance().Get("/sdev/"+xml::util::Hexify(trust::HttpsClient::getInstance().getLFDI())); - std::cout << rsp << std::endl; - rsp = trust::HttpsClient::getInstance().Get("/tm"); - - gsp.detach(); + https::Context gsp_ctx = {"1", g_program_path, "0.0.0.0", "8080"}; + https::Context dtm_ctx = {"1", g_program_path, "0.0.0.0", "8090"}; + + auto resp = trust::HttpsClient::getInstance(gsp_ctx, dtm_ctx).Get("/dcap"); + std::string msg = boost::beast::buffers_to_string(resp.body().data()); + sep::DeviceCapability dcap; + xml::Parse(msg, &dcap); + + resp = trust::HttpsClient::getInstance().Get(dcap.time_link.href); + msg = boost::beast::buffers_to_string(resp.body().data()); + sep::Time tm; + xml::Parse(msg, &tm); + + resp = trust::HttpsClient::getInstance().Get(dcap.end_device_list_link.href); + msg = boost::beast::buffers_to_string(resp.body().data()); + std::vector edev_list; + xml::Parse(msg, &edev_list); + + resp = trust::HttpsClient::getInstance().Get(edev_list[0].href); + msg = boost::beast::buffers_to_string(resp.body().data()); + sep::EndDevice edev; + xml::Parse(msg, &edev); + + resp = trust::HttpsClient::getInstance().Get(edev.registration_link.href); + msg = boost::beast::buffers_to_string(resp.body().data()); + sep::Registration rg; + xml::Parse(msg, &rg); + + sep::FlowReservationRequest frq; + frq.creation_time = psu::utilities::getTime(); + frq.description = "DTM DEMO Flow Reservation Request"; + frq.duration_requested = 60 * 60; + frq.energy_requested.value = 1000; + frq.energy_requested.multiplier = 1; + frq.power_requested.value = 1000; + frq.power_requested.multiplier = 1; + frq.href = "/frq"; + frq.inherited_poll_rate = 900; + frq.interval_requested.start = frq.creation_time; + frq.interval_requested.duration = frq.duration_requested * 3; + frq.mrid = 0x9999; + frq.request_status.datetime = frq.creation_time; + frq.request_status.status = sep::RequestStatus::Status::kRequested; + + resp = trust::HttpsClient::getInstance() + .Post(edev.flow_reservation_request_list_link.href, xml::Serialize(frq)); + + resp = trust::HttpsClient::getInstance().Get(edev.flow_reservation_request_list_link.href); + msg = boost::beast::buffers_to_string(resp.body().data()); + std::vector frq_list; + xml::Parse(msg, &frq_list); + + resp = trust::HttpsClient::getInstance().Get(frq_list[0].href); + msg = boost::beast::buffers_to_string(resp.body().data()); + sep::FlowReservationRequest frq_posted; + xml::Parse(msg, &frq_posted); + + resp = trust::HttpsClient::getInstance().Get(edev.flow_reservation_response_list_link.href); + msg = boost::beast::buffers_to_string(resp.body().data()); + std::vector frp_list; + xml::Parse(msg, &frp_list); + + resp = trust::HttpsClient::getInstance().Get(frp_list[0].href); + msg = boost::beast::buffers_to_string(resp.body().data()); + sep::FlowReservationResponse frp; + xml::Parse(msg, &frp); + + sep::Response rsp; + rsp.href = dcap.response_set_list_link.href; + rsp.end_device_lfdi = edev.lfdi; + rsp.status = sep::Response::Status::kEventAcknowledged; + rsp.subject = frp.mrid; + rsp.created_date_time = psu::utilities::getTime(); + + resp = trust::HttpsClient::getInstance() + .Post(frp.reply_to, xml::Serialize(rsp)); + + gsp.detach(); dtm.detach(); - - return 0; + + return 0; } \ No newline at end of file diff --git a/dtm/trust_https/trust_https.cpp b/dtm/trust_https/trust_https.cpp index aadd4f90..eec5d875 100644 --- a/dtm/trust_https/trust_https.cpp +++ b/dtm/trust_https/trust_https.cpp @@ -56,11 +56,12 @@ namespace trust { dtm_client_.Post("/na", packGetRequest(target, query)); rsp = gsp_client_.Get(target, query); + std::cout << "TrustHTTP response: " << rsp << std::endl; dtm_client_.Post("/na", packResponse(rsp)); } catch(const std::exception& e) { - std::cout << "Trust DCM : " << target + std::cout << "TrustHTTP Error : " << target << "\n\t" << e.what() << '\n'; } @@ -79,7 +80,7 @@ namespace trust } catch(const std::exception& e) { - std::cout << "Trust DCM : " << target + std::cout << "TrustHTTP Error : " << target << "\n\t" << e.what() << '\n'; } @@ -98,7 +99,7 @@ namespace trust } catch(const std::exception& e) { - std::cout << "Trust DCM : " << target + std::cout << "TrustHTTP Error : " << target << "\n\t" << e.what() << '\n'; } @@ -117,7 +118,7 @@ namespace trust } catch(const std::exception& e) { - std::cout << "Trust DCM : " << target + std::cout << "TrustHTTP Error : " << target << "\n\t" << e.what() << '\n'; } diff --git a/dtm/trust_xml/trust_xml.cpp b/dtm/trust_xml/trust_xml.cpp index b757b07e..0c044324 100644 --- a/dtm/trust_xml/trust_xml.cpp +++ b/dtm/trust_xml/trust_xml.cpp @@ -19,12 +19,16 @@ namespace trust pt::ptree tree; tree.put("message.to", message.to); tree.put("message.from", message.from); - + for (const auto& arg : message.contents) { if (arg.first == "body"){ - pt::ptree body = Treeify(arg.second); - tree.put_child("message.contents."+arg.first, body); + try { + pt::ptree body = Treeify(arg.second); + tree.put_child("message.contents."+arg.first, body); + } catch (...){ + tree.put("message.contents."+arg.first, arg.second); + } } else { tree.put("message.contents."+arg.first, arg.second); diff --git a/ecs/include/world/uri.hpp b/ecs/include/world/uri.hpp index 3308bc0b..79579540 100644 --- a/ecs/include/world/uri.hpp +++ b/ecs/include/world/uri.hpp @@ -8,7 +8,6 @@ enum class Uri { dcap, sdev, - sdev_list, edev, edev_list, rg, @@ -138,8 +137,7 @@ enum class Uri static std::unordered_map uri_map = { {"/dcap", Uri::dcap}, - {"/sdev/*", Uri::sdev}, - {"/sdev", Uri::sdev_list}, + {"/sdev", Uri::sdev}, {"/edev/*", Uri::edev}, {"/edev", Uri::edev_list}, {"/rg", Uri::rg}, diff --git a/ecs/world.cpp b/ecs/world.cpp index 3adc8358..818d2a6f 100644 --- a/ecs/world.cpp +++ b/ecs/world.cpp @@ -83,34 +83,6 @@ std::string World::Get(const Href &href) }); }; break; - case (Uri::sdev_list): - { - std::vector sdev_list; - sep::List list; - //auto e = world.lookup(prependLFDI(href).c_str()); - - // More complex filters can first be created, then iterated - auto f = world.filter(); - - f.iter([&sdev_list,href](flecs::iter& it, sep::SelfDevice* sdev, AccessModule::Fingerprint *lfdi) - { - for (auto i : it) - { - if (accessMatch(lfdi[i], href)) - { - sdev_list.emplace_back(sdev[i]); - } - } - }); - - list.href = href.uri; - list.all = sdev_list.size(); - list.results = sdev_list.size(); - - response = xml::Serialize(sdev_list, list); - std::cout << "ECS World : " << response << std::endl; - }; - break; case (Uri::edev): { // More complex filters can first be created, then iterated @@ -711,6 +683,7 @@ std::string World::Post(const Href &href, const std::string& message) e.set(subject); sep::FlowReservationResponse frp; + frp.href = href.uri + "/" + subject.value; frp.energy_available = frq.energy_requested; frp.power_available = frq.power_requested; frp.subject = xml::util::Hexify(frq.mrid); @@ -734,7 +707,7 @@ std::string World::Post(const Href &href, const std::string& message) e2.set(fingerprint); e2.set(subject); - return href.uri + "/" + subject.value; + return frp.href; }; break; default: diff --git a/resources/sep_xml/sep.xsd b/resources/sep_xml/sep.xsd index 0ddad99f..5a15b5cf 100644 --- a/resources/sep_xml/sep.xsd +++ b/resources/sep_xml/sep.xsd @@ -4018,7 +4018,7 @@ All other values reserved. All other values reserved. - + @@ -5966,7 +5966,7 @@ Bit positions SHALL be defined as follows: All other values reserved. - + @@ -6197,7 +6197,7 @@ Bit 6 - isSubmeter - SHALL be set if the usage point is not a premises aggregati Bit 7-15 - Reserved - + diff --git a/standards/ieee-2030.5/tests/xml/dcap_tests.cpp b/standards/ieee-2030.5/tests/xml/dcap_tests.cpp index 63ab5bbe..a528bba6 100644 --- a/standards/ieee-2030.5/tests/xml/dcap_tests.cpp +++ b/standards/ieee-2030.5/tests/xml/dcap_tests.cpp @@ -70,6 +70,8 @@ TEST_F(TestDeviceCapabilityXML, IsAdapterTranslationAccurate) EXPECT_EQ(dcap->time_link.href, "http://uri1"); EXPECT_EQ(dcap->usage_point_list_link.href, "http://uri1"); EXPECT_EQ(dcap->usage_point_list_link.all, 0); + EXPECT_EQ(dcap->end_device_list_link.href, "http://uri1"); + EXPECT_EQ(dcap->end_device_list_link.all, 0); EXPECT_EQ(dcap->mirror_usage_point_list_link.href, "http://uri1"); EXPECT_EQ(dcap->mirror_usage_point_list_link.all, 0); EXPECT_EQ(dcap->self_device_link.href, "http://uri1"); diff --git a/standards/ieee-2030.5/tests/xml/frp_tests.cpp b/standards/ieee-2030.5/tests/xml/frp_tests.cpp index fff7f737..4dd3718e 100644 --- a/standards/ieee-2030.5/tests/xml/frp_tests.cpp +++ b/standards/ieee-2030.5/tests/xml/frp_tests.cpp @@ -55,7 +55,7 @@ TEST_F(TestFlowReservationResponseXML, IsAdapterTranslationAccurate) EXPECT_EQ(fr_response->reply_to, "http://uri1"); EXPECT_EQ(xml::util::Hexify(xml::util::ToUnderlyingType(fr_response->response_required)), "00"); EXPECT_EQ(fr_response->href, "http://uri1"); - EXPECT_EQ(fr_response->mrid,0); + EXPECT_EQ(fr_response->mrid,0x0FB7); EXPECT_EQ(fr_response->description, "description1"); EXPECT_EQ(fr_response->version, 0); EXPECT_EQ(fr_response->creation_time, 1); diff --git a/standards/ieee-2030.5/tests/xml/frq_tests.cpp b/standards/ieee-2030.5/tests/xml/frq_tests.cpp index efa33331..f1b279ec 100644 --- a/standards/ieee-2030.5/tests/xml/frq_tests.cpp +++ b/standards/ieee-2030.5/tests/xml/frq_tests.cpp @@ -52,7 +52,7 @@ TEST_F(TestFlowReservationRequestXML, IsAdapterTranslationAccurate) { sep::FlowReservationRequest *fr_request = new sep::FlowReservationRequest; xml::Parse(xml_str, fr_request); - EXPECT_EQ(fr_request->mrid, 0); + EXPECT_EQ(fr_request->mrid, 0x0FB7); EXPECT_EQ(fr_request->description, "description1"); EXPECT_EQ(fr_request->version, 0); EXPECT_EQ(fr_request->creation_time, 1); diff --git a/standards/ieee-2030.5/xml/device_capability_adapter.cpp b/standards/ieee-2030.5/xml/device_capability_adapter.cpp index e61d94dc..f55713d2 100644 --- a/standards/ieee-2030.5/xml/device_capability_adapter.cpp +++ b/standards/ieee-2030.5/xml/device_capability_adapter.cpp @@ -26,6 +26,8 @@ namespace xml dcap->time_link.href = pt.get("DeviceCapability.TimeLink..href", ""); dcap->usage_point_list_link.href = pt.get("DeviceCapability.UsagePointListLink..href", ""); dcap->usage_point_list_link.all = pt.get("DeviceCapability.UsagePointListLink..all", 0); + dcap->end_device_list_link.href = pt.get("DeviceCapability.EndDeviceListLink..href", ""); + dcap->end_device_list_link.all = pt.get("DeviceCapability.EndDeviceListLink..all", 0); dcap->mirror_usage_point_list_link.href = pt.get("DeviceCapability.MirrorUsagePointListLink..href", ""); dcap->mirror_usage_point_list_link.all = pt.get("DeviceCapability.MirrorUsagePointListLink..all", 0); dcap->self_device_link.href = pt.get("DeviceCapability.SelfDeviceLink..href", ""); @@ -54,9 +56,11 @@ namespace xml pt->put("DeviceCapability.TimeLink..href", dcap.time_link.href); pt->put("DeviceCapability.UsagePointListLink..href", dcap.usage_point_list_link.href); pt->put("DeviceCapability.UsagePointListLink..all", dcap.usage_point_list_link.all); + pt->put("DeviceCapability.EndDeviceListLink..href", dcap.end_device_list_link.href); + pt->put("DeviceCapability.EndDeviceListLink..all", dcap.end_device_list_link.all); pt->put("DeviceCapability.MirrorUsagePointListLink..href", dcap.mirror_usage_point_list_link.href); pt->put("DeviceCapability.MirrorUsagePointListLink..all", dcap.mirror_usage_point_list_link.all); - pt->put("DeviceCapability.SelfDeviceLink..href", dcap.demand_response_program_list_link.href); + pt->put("DeviceCapability.SelfDeviceLink..href", dcap.self_device_link.href); }; std::string Serialize(const sep::DeviceCapability &dcap) diff --git a/standards/ieee-2030.5/xml/response_adapter.cpp b/standards/ieee-2030.5/xml/response_adapter.cpp index 40034b9b..0c3a2aaf 100644 --- a/standards/ieee-2030.5/xml/response_adapter.cpp +++ b/standards/ieee-2030.5/xml/response_adapter.cpp @@ -43,7 +43,6 @@ namespace xml pt.put("ResponseList..all", list.all); pt.put("ResponseList..results", list.results); pt.put("ResponseList..href", list.href); - pt.put("ResponseList..pollRate", list.inherited_poll_rate); for (const auto& rsp : rsp_list) { @@ -68,7 +67,6 @@ namespace xml sep::Response rsp; ObjectMap(subtree.second, &rsp); - rsp.inherited_poll_rate = pt.get("ResponseList..pollRate", 900); rsp_list->emplace_back(rsp); } From 62b621829a7091b5d8e5ba148c099e71679fa60a Mon Sep 17 00:00:00 2001 From: Tylores Date: Tue, 24 Jan 2023 15:54:03 -0800 Subject: [PATCH 004/108] Updated the remaining resources we will be using for the trust demo. Updated the trust xml to include timestamp and changed status code element name. --- dtm/tests/demo.cpp | 22 ++++++ dtm/trust_https/trust_https.cpp | 3 +- dtm/trust_xml/include/trust_xml/trust_xml.hpp | 2 +- dtm/trust_xml/trust_xml.cpp | 3 +- ecs/include/world/uri.hpp | 1 + ecs/world.cpp | 15 ++++ interfaces/https/client/client.cpp | 1 + resources/sep_xml/PowerStatus.xml | 2 +- .../ieee-2030.5/mirror_meter_reading.hpp | 7 +- .../ieee-2030.5/mirror_usage_point.hpp | 4 +- .../include/ieee-2030.5/models.hpp | 1 + .../ieee-2030.5/tests/xml/CMakeLists.txt | 1 + standards/ieee-2030.5/tests/xml/ps_tests.cpp | 71 +++++++++++++++++++ standards/ieee-2030.5/xml/CMakeLists.txt | 1 + .../ieee-2030.5/xml/include/xml/adapter.hpp | 1 + .../xml/mirror_usage_point_adapter.hpp | 20 ++++++ .../xml/include/xml/power_status_adapter.hpp | 18 +++++ .../xml/mirror_usage_point_adapter.cpp | 39 ++++++++++ .../ieee-2030.5/xml/power_status_adapter.cpp | 67 +++++++++++++++++ 19 files changed, 272 insertions(+), 7 deletions(-) create mode 100644 standards/ieee-2030.5/tests/xml/ps_tests.cpp create mode 100644 standards/ieee-2030.5/xml/include/xml/mirror_usage_point_adapter.hpp create mode 100644 standards/ieee-2030.5/xml/include/xml/power_status_adapter.hpp create mode 100644 standards/ieee-2030.5/xml/mirror_usage_point_adapter.cpp create mode 100644 standards/ieee-2030.5/xml/power_status_adapter.cpp diff --git a/dtm/tests/demo.cpp b/dtm/tests/demo.cpp index 9bd1b48a..3c1f8aeb 100644 --- a/dtm/tests/demo.cpp +++ b/dtm/tests/demo.cpp @@ -293,6 +293,28 @@ int main(int argc, char **argv) resp = trust::HttpsClient::getInstance() .Post(frp.reply_to, xml::Serialize(rsp)); + sep::PowerStatus ps; + ps.battery_status = sep::BatteryStatus::kNormal; + ps.changed_time = 10; + ps.current_power_source = sep::PowerSourceType::kMains; + ps.estimated_charge_remaining = 1; + ps.estimated_time_remaining = frq.interval_requested.duration; + ps.pev_info.charging_power_now.multiplier = frq.power_requested.multiplier; + ps.pev_info.charging_power_now.value = frq.power_requested.value; + ps.pev_info.energy_request_now.multiplier = frq.energy_requested.multiplier; + ps.pev_info.energy_request_now.value = frq.energy_requested.value; + ps.pev_info.max_forward_power.multiplier = 1; + ps.pev_info.max_forward_power.value = 0; + ps.pev_info.minimum_charging_duration = frq.interval_requested.duration; + ps.pev_info.target_state_of_charge = 100; + ps.pev_info.time_charge_is_needed = frq.interval_requested.start + frq.interval_requested.duration; + ps.pev_info.time_charging_status_pev = psu::utilities::getTime(); + ps.session_time_on_battery = 0; + ps.total_time_on_battery = 0; + + resp = trust::HttpsClient::getInstance() + .Put(edev.power_status_link.href, xml::Serialize(ps)); + gsp.detach(); dtm.detach(); diff --git a/dtm/trust_https/trust_https.cpp b/dtm/trust_https/trust_https.cpp index eec5d875..841d435a 100644 --- a/dtm/trust_https/trust_https.cpp +++ b/dtm/trust_https/trust_https.cpp @@ -56,7 +56,6 @@ namespace trust { dtm_client_.Post("/na", packGetRequest(target, query)); rsp = gsp_client_.Get(target, query); - std::cout << "TrustHTTP response: " << rsp << std::endl; dtm_client_.Post("/na", packResponse(rsp)); } catch(const std::exception& e) @@ -187,7 +186,7 @@ namespace trust msg.from = "GSP"; msg.timestamp = psu::utilities::getTime(); msg.contents["version"] = std::to_string(rsp.version()); - msg.contents["status code"] = std::to_string(rsp.result_int()); + msg.contents["statusCode"] = std::to_string(rsp.result_int()); msg.contents["body"] = boost::beast::buffers_to_string(rsp.body().data()); for (const auto &key : rsp) diff --git a/dtm/trust_xml/include/trust_xml/trust_xml.hpp b/dtm/trust_xml/include/trust_xml/trust_xml.hpp index ed3552d0..57c29e57 100644 --- a/dtm/trust_xml/include/trust_xml/trust_xml.hpp +++ b/dtm/trust_xml/include/trust_xml/trust_xml.hpp @@ -11,7 +11,7 @@ namespace trust { std::string to; std::string from; - std::string timestamp; + uint64_t timestamp; std::map contents; }; diff --git a/dtm/trust_xml/trust_xml.cpp b/dtm/trust_xml/trust_xml.cpp index 0c044324..6ac786c2 100644 --- a/dtm/trust_xml/trust_xml.cpp +++ b/dtm/trust_xml/trust_xml.cpp @@ -19,7 +19,8 @@ namespace trust pt::ptree tree; tree.put("message.to", message.to); tree.put("message.from", message.from); - + tree.put("message.timestamp", message.timestamp); + for (const auto& arg : message.contents) { if (arg.first == "body"){ diff --git a/ecs/include/world/uri.hpp b/ecs/include/world/uri.hpp index 79579540..11bd9cef 100644 --- a/ecs/include/world/uri.hpp +++ b/ecs/include/world/uri.hpp @@ -140,6 +140,7 @@ static std::unordered_map uri_map = {"/sdev", Uri::sdev}, {"/edev/*", Uri::edev}, {"/edev", Uri::edev_list}, + {"/ps", Uri::ps}, {"/rg", Uri::rg}, {"/dstat", Uri::dstat}, {"/fsa/*", Uri::fsa}, diff --git a/ecs/world.cpp b/ecs/world.cpp index 818d2a6f..e9529a95 100644 --- a/ecs/world.cpp +++ b/ecs/world.cpp @@ -786,6 +786,21 @@ std::string World::Put(const Href &href, const std::string& message) } }; break; + case (Uri::ps): + { + auto e = world.entity(); + + sep::PowerStatus ps; + xml::Parse(message, &ps); + e.set(ps); + + AccessModule::Fingerprint fingerprint; + fingerprint.value = href.lfdi; + e.set(fingerprint); + + return ""; + }; + break; default: return ""; break; diff --git a/interfaces/https/client/client.cpp b/interfaces/https/client/client.cpp index 73b24535..7fd892ff 100644 --- a/interfaces/https/client/client.cpp +++ b/interfaces/https/client/client.cpp @@ -72,6 +72,7 @@ Client::Put(const std::string& target, const std::string& resource) }; req.set(bb::http::field::host, context_.host); + req.set(bb::http::field::content_type, "application/sep+xml"); req.body() = resource; req.prepare_payload(); return Client::Send (req); diff --git a/resources/sep_xml/PowerStatus.xml b/resources/sep_xml/PowerStatus.xml index d8b3467d..02905af4 100644 --- a/resources/sep_xml/PowerStatus.xml +++ b/resources/sep_xml/PowerStatus.xml @@ -15,7 +15,7 @@ 0 - -128 + 1 1 0 diff --git a/standards/ieee-2030.5/include/ieee-2030.5/mirror_meter_reading.hpp b/standards/ieee-2030.5/include/ieee-2030.5/mirror_meter_reading.hpp index 6882fda4..1f0270c9 100644 --- a/standards/ieee-2030.5/include/ieee-2030.5/mirror_meter_reading.hpp +++ b/standards/ieee-2030.5/include/ieee-2030.5/mirror_meter_reading.hpp @@ -3,6 +3,8 @@ #include "meter_reading_base.hpp" #include "time_type.hpp" #include "mirror_reading_set.hpp" +#include "reading.hpp" +#include "reading_type.hpp" namespace sep { @@ -10,7 +12,10 @@ namespace sep struct MirrorMeterReading : MeterReadingBase { TimeType last_update_time; - + MirrorReadingSet mirror_reading_set; + TimeType next_update_time; + Reading reading; + ReadingType reading_type; }; } // namespace sep diff --git a/standards/ieee-2030.5/include/ieee-2030.5/mirror_usage_point.hpp b/standards/ieee-2030.5/include/ieee-2030.5/mirror_usage_point.hpp index a2d34db0..59b02213 100644 --- a/standards/ieee-2030.5/include/ieee-2030.5/mirror_usage_point.hpp +++ b/standards/ieee-2030.5/include/ieee-2030.5/mirror_usage_point.hpp @@ -1,15 +1,17 @@ #ifndef __MIRROR_USAGE_POINT_H__ #define __MIRROR_USAGE_POINT_H__ #include +#include #include "usage_point_base.hpp" #include "mirror_meter_reading.hpp" +#include "lfdi_type.hpp" namespace sep { // A parallel to UsagePoint to support mirroring struct MirrorUsagePoint : UsagePointBase { - boost::multiprecision::uint256_t lfdi; + LFDIType device_lfdi; MirrorMeterReading mirror_meter_reading; uint32_t post_rate; }; diff --git a/standards/ieee-2030.5/include/ieee-2030.5/models.hpp b/standards/ieee-2030.5/include/ieee-2030.5/models.hpp index 2274757a..71d6106b 100644 --- a/standards/ieee-2030.5/include/ieee-2030.5/models.hpp +++ b/standards/ieee-2030.5/include/ieee-2030.5/models.hpp @@ -12,5 +12,6 @@ #include "response.hpp" #include "response_set.hpp" #include "list.hpp" +#include "power_status.hpp" #endif // __MODELS_H__ \ No newline at end of file diff --git a/standards/ieee-2030.5/tests/xml/CMakeLists.txt b/standards/ieee-2030.5/tests/xml/CMakeLists.txt index ebd8bdab..a638c723 100644 --- a/standards/ieee-2030.5/tests/xml/CMakeLists.txt +++ b/standards/ieee-2030.5/tests/xml/CMakeLists.txt @@ -15,6 +15,7 @@ add_executable (xml_tests rsps_tests.cpp rsp_tests.cpp tm_tests.cpp + ps_tests.cpp ) target_link_libraries(xml_tests gtest gtest_main SEP_Models XML_Validator Boost::boost utilities pthread) diff --git a/standards/ieee-2030.5/tests/xml/ps_tests.cpp b/standards/ieee-2030.5/tests/xml/ps_tests.cpp new file mode 100644 index 00000000..5410385a --- /dev/null +++ b/standards/ieee-2030.5/tests/xml/ps_tests.cpp @@ -0,0 +1,71 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern std::string g_program_path; + +class TestPowerStatusXML : public ::testing::Test +{ +protected: + void SetUp() override + { + validator = new XmlValidator(g_program_path + "/sep_xml/sep.xsd"); + + xml_str = psu::utilities::readFile(g_program_path + "/sep_xml/PowerStatus.xml"); + } + + void TearDown() override + { + delete validator; + } + +protected: + std::string xml_str; + XmlValidator *validator; +}; + +TEST_F(TestPowerStatusXML, IsSampleValid) +{ + EXPECT_TRUE(validator->ValidateXml(xml_str)); +} + +TEST_F(TestPowerStatusXML, IsAdapterValid) +{ + sep::PowerStatus ps; + xml::Parse(xml_str, &ps); + EXPECT_TRUE(validator->ValidateXml(xml::Serialize(ps))); +} + + +TEST_F(TestPowerStatusXML, IsAdapterTranslationAccurate) +{ + sep::PowerStatus ps; + xml::Parse(xml_str, &ps); + EXPECT_EQ(ps.poll_rate, 900); + EXPECT_EQ(ps.href, "http://uri1"); + EXPECT_EQ(xml::util::ToUnderlyingType(ps.battery_status), 0); + EXPECT_EQ(ps.changed_time, 1); + EXPECT_EQ(xml::util::ToUnderlyingType(ps.current_power_source), 0); + EXPECT_EQ(ps.estimated_charge_remaining, 0); + EXPECT_EQ(ps.estimated_time_remaining, 0); + EXPECT_EQ(ps.pev_info.charging_power_now.multiplier, 1); + EXPECT_EQ(ps.pev_info.charging_power_now.value, 1); + EXPECT_EQ(ps.pev_info.energy_request_now.multiplier, 1); + EXPECT_EQ(ps.pev_info.energy_request_now.value, 0); + EXPECT_EQ(ps.pev_info.max_forward_power.multiplier, 1); + EXPECT_EQ(ps.pev_info.max_forward_power.value, 1); + EXPECT_EQ(ps.pev_info.minimum_charging_duration, 0); + EXPECT_EQ(ps.pev_info.target_state_of_charge, 0); + EXPECT_EQ(ps.pev_info.time_charge_is_needed, 1); + EXPECT_EQ(ps.pev_info.time_charging_status_pev, 1); + EXPECT_EQ(ps.session_time_on_battery, 0); + EXPECT_EQ(ps.total_time_on_battery, 0); +} \ No newline at end of file diff --git a/standards/ieee-2030.5/xml/CMakeLists.txt b/standards/ieee-2030.5/xml/CMakeLists.txt index 36b331f4..9c139bd2 100644 --- a/standards/ieee-2030.5/xml/CMakeLists.txt +++ b/standards/ieee-2030.5/xml/CMakeLists.txt @@ -8,6 +8,7 @@ add_library(${COMPONENT_NAME} STATIC end_device_adapter.cpp flow_reservation_response_adapter.cpp flow_reservation_request_adapter.cpp + power_status_adapter.cpp registration_adapter.cpp response_adapter.cpp response_set_adapter.cpp diff --git a/standards/ieee-2030.5/xml/include/xml/adapter.hpp b/standards/ieee-2030.5/xml/include/xml/adapter.hpp index 6adaf414..d70a756f 100644 --- a/standards/ieee-2030.5/xml/include/xml/adapter.hpp +++ b/standards/ieee-2030.5/xml/include/xml/adapter.hpp @@ -10,6 +10,7 @@ #include "response_set_adapter.hpp" #include "self_device_adapter.hpp" #include "time_adapter.hpp" +#include "power_status_adapter.hpp" #include "utilities.hpp" #endif // __XML_ADAPTER_H__ \ No newline at end of file diff --git a/standards/ieee-2030.5/xml/include/xml/mirror_usage_point_adapter.hpp b/standards/ieee-2030.5/xml/include/xml/mirror_usage_point_adapter.hpp new file mode 100644 index 00000000..4bb334d9 --- /dev/null +++ b/standards/ieee-2030.5/xml/include/xml/mirror_usage_point_adapter.hpp @@ -0,0 +1,20 @@ +#ifndef __MIRROR_USAGE_POINT_ADAPTER_H__ +#define __MIRROR_USAGE_POINT_ADAPTER_H__ +#include +#include +#include +#include + +namespace xml +{ + void ObjectMap(const boost::property_tree::ptree &pt, sep::MirrorUsagePoint *mup); + void TreeMap(const sep::MirrorUsagePoint &mup, boost::property_tree::ptree *pt); + + std::string Serialize(const sep::MirrorUsagePoint &mup); + void Parse(const std::string &xml_str, sep::MirrorUsagePoint *mup); + + std::string Serialize(const std::vector &mup_list, const sep::List& list); + void Parse(const std::string &xml_str, std::vector *mups); +} // namespace xml + +#endif // __MIRROR_USAGE_POINT_ADAPTER_H__ \ No newline at end of file diff --git a/standards/ieee-2030.5/xml/include/xml/power_status_adapter.hpp b/standards/ieee-2030.5/xml/include/xml/power_status_adapter.hpp new file mode 100644 index 00000000..747f4c34 --- /dev/null +++ b/standards/ieee-2030.5/xml/include/xml/power_status_adapter.hpp @@ -0,0 +1,18 @@ +#ifndef __POWER_STATUS_ADAPTER_H__ +#define __POWER_STATUS_ADAPTER_H__ + + +#include +#include +#include + +namespace xml +{ + void ObjectMap (const boost::property_tree::ptree &pt, sep::PowerStatus *ps); + void TreeMap (const sep::PowerStatus &ps, boost::property_tree::ptree *pt); + + std::string Serialize(const sep::PowerStatus &ps); + void Parse(const std::string &xml_str, sep::PowerStatus *ps); +} // namespace xml + +#endif // __POWER_STATUS_ADAPTER_H__ \ No newline at end of file diff --git a/standards/ieee-2030.5/xml/mirror_usage_point_adapter.cpp b/standards/ieee-2030.5/xml/mirror_usage_point_adapter.cpp new file mode 100644 index 00000000..74bb50ff --- /dev/null +++ b/standards/ieee-2030.5/xml/mirror_usage_point_adapter.cpp @@ -0,0 +1,39 @@ +#include "include/xml/mirror_usage_point_adapter.hpp" +#include "include/xml/utilities.hpp" +#include + +using namespace xml; + +void ObjectMap(const boost::property_tree::ptree &pt, sep::MirrorUsagePoint *mup) +{ + mup->device_lfdi = xml::util::Dehexify(pt.get("MirrorUsagePoint.deviceLFDI", "")); + mup->mirror_meter_reading.last_update_time = pt.get("MirrorUsagePoint.MirrorMeterReading.lastUpdateTime",0); + mup->mirror_meter_reading.mirror_reading_set. + mup->post_rate = pt.get("MirrorUsagePoint.postRate",900); +} + +void TreeMap(const sep::MirrorUsagePoint &mup, boost::property_tree::ptree *pt) +{ + +} + +std::string Serialize(const sep::MirrorUsagePoint *mup) +{ + +} + +void Parse (const std::string &xml_str, sep::MirrorUsagePoint *mup) +{ + +} + +std::string Serialize(const std::vector &mup_list, const sep::List& list) +{ + +} + + +void Parse(const std::string &xml_str, std::vector *mups) +{ + +} diff --git a/standards/ieee-2030.5/xml/power_status_adapter.cpp b/standards/ieee-2030.5/xml/power_status_adapter.cpp new file mode 100644 index 00000000..8e41d40b --- /dev/null +++ b/standards/ieee-2030.5/xml/power_status_adapter.cpp @@ -0,0 +1,67 @@ +#include "include/xml/power_status_adapter.hpp" +#include "include/xml/utilities.hpp" + +namespace xml +{ + void ObjectMap (const boost::property_tree::ptree &pt, sep::PowerStatus *ps) + { + ps->battery_status = static_cast(pt.get("PowerStatus.batteryStatus", 0)); + ps->changed_time = pt.get("PowerStatus.changedTime", 0); + ps->current_power_source = static_cast(pt.get("PowerStatus.currentPowerSource", 0)); + ps->estimated_charge_remaining = pt.get("PowerStatus.estimatedChargeRemaining", 0); + ps->estimated_time_remaining = pt.get("PowerStatus.estimatedTimeRemaining", 0); + ps->href = pt.get("PowerStatus..href", ""); + ps->poll_rate = pt.get("PowerStatus..pollRate", 0); + ps->inherited_poll_rate = ps->poll_rate; + ps->pev_info.charging_power_now.multiplier = pt.get("PowerStatus.PEVInfo.chargingPowerNow.multiplier", 0); + ps->pev_info.charging_power_now.value = pt.get("PowerStatus.PEVInfo.chargingPowerNow.value", 0); + ps->pev_info.energy_request_now.multiplier = pt.get("PowerStatus.PEVInfo.energyRequestNow.multiplier", 0); + ps->pev_info.energy_request_now.value = pt.get("PowerStatus.PEVInfo.energyRequestNow.value", 0); + ps->pev_info.max_forward_power.multiplier = pt.get("PowerStatus.PEVInfo.maxForwardPower.multiplier", 0); + ps->pev_info.max_forward_power.value = pt.get("PowerStatus.PEVInfo.maxForwardPower.multiplier", 0); + ps->pev_info.minimum_charging_duration = pt.get("PowerStatus.PEVInfo.minimumChargingDuration", 0); + ps->pev_info.target_state_of_charge = pt.get("PowerStatus.PEVInfo.targetStateOfCharge", 0); + ps->pev_info.time_charge_is_needed = pt.get("PowerStatus.PEVInfo.timeChargeIsNeeded", 0); + ps->pev_info.time_charging_status_pev = pt.get("PowerStatus.PEVInfo.timeChargingStatusPEV", 0); + ps->session_time_on_battery = pt.get("PowerStatus.sessionTimeOnBattery", 0); + ps->total_time_on_battery = pt.get("PowerStatus.totalTimeOnBattery", 0); + } + + void TreeMap (const sep::PowerStatus &ps, boost::property_tree::ptree *pt) + { + pt->put("PowerStatus.batteryStatus", xml::util::ToUnderlyingType(ps.battery_status)); + pt->put("PowerStatus.changedTime", ps.changed_time); + pt->put("PowerStatus.currentPowerSource", xml::util::ToUnderlyingType(ps.current_power_source)); + pt->put("PowerStatus.estimatedChargeRemaining", ps.estimated_charge_remaining); + pt->put("PowerStatus.estimatedTimeRemaining", ps.estimated_time_remaining); + pt->put("PowerStatus..href", ps.href); + pt->put("PowerStatus..pollRate", ps.poll_rate); + pt->put("PowerStatus.PEVInfo.chargingPowerNow.multiplier", ps.pev_info.charging_power_now.multiplier); + pt->put("PowerStatus.PEVInfo.chargingPowerNow.value", ps.pev_info.charging_power_now.value); + pt->put("PowerStatus.PEVInfo.energyRequestNow.multiplier", ps.pev_info.energy_request_now.multiplier); + pt->put("PowerStatus.PEVInfo.energyRequestNow.value", ps.pev_info.energy_request_now.value); + pt->put("PowerStatus.PEVInfo.maxForwardPower.multiplier", ps.pev_info.max_forward_power.multiplier); + pt->put("PowerStatus.PEVInfo.maxForwardPower.value", ps.pev_info.max_forward_power.value); + pt->put("PowerStatus.PEVInfo.minimumChargingDuration", ps.pev_info.minimum_charging_duration); + pt->put("PowerStatus.PEVInfo.targetStateOfCharge", ps.pev_info.target_state_of_charge); + pt->put("PowerStatus.PEVInfo.timeChargeIsNeeded", ps.pev_info.time_charge_is_needed); + pt->put("PowerStatus.PEVInfo.timeChargingStatusPEV", ps.pev_info.time_charging_status_pev); + pt->put("PowerStatus.sessionTimeOnBattery", ps.session_time_on_battery); + pt->put("PowerStatus.totalTimeOnBattery", ps.total_time_on_battery); + } + + std::string Serialize(const sep::PowerStatus &ps) + { + boost::property_tree::ptree pt; + TreeMap(ps, &pt); + + xml::util::SetSchema(&pt); + return xml::util::Stringify(&pt); + } + + void Parse(const std::string &xml_str, sep::PowerStatus *ps) + { + boost::property_tree::ptree pt = xml::util::Treeify(xml_str); + ObjectMap(pt, ps); + } +} // namespace xml From 26c528c95dd9abe3b84d0c65d776ab7f6a515f0c Mon Sep 17 00:00:00 2001 From: Tylores Date: Sat, 4 Feb 2023 10:11:57 -0800 Subject: [PATCH 005/108] testing the waters with mermaid.js --- diagrams/README.md | 6 ++++++ diagrams/csip-comm-006.mmd | 14 ++++++++++++++ diagrams/csip-comm-006.svg | 1 + 3 files changed, 21 insertions(+) create mode 100644 diagrams/README.md create mode 100644 diagrams/csip-comm-006.mmd create mode 100644 diagrams/csip-comm-006.svg diff --git a/diagrams/README.md b/diagrams/README.md new file mode 100644 index 00000000..bf2e53cb --- /dev/null +++ b/diagrams/README.md @@ -0,0 +1,6 @@ + +# [https://mermaid.js.org/](Mermaid) + +I have been looking for a easy integration programable diagram solution for a while and I think this is it. The sytax is very simple and it integrates with nearly everything or can run stand alone. Also the default output is SVG. + + \ No newline at end of file diff --git a/diagrams/csip-comm-006.mmd b/diagrams/csip-comm-006.mmd new file mode 100644 index 00000000..faef85cc --- /dev/null +++ b/diagrams/csip-comm-006.mmd @@ -0,0 +1,14 @@ +sequenceDiagram +%%{init:{'theme':'neutral'}}%% +%% @backgroundColor(transparent) + autonumber + Client->>+Server: HTTP GET DeviceCapabilityLink + Server-->>-Client: HTTP 200 + Note left of Client: Find EndDeviceListLink + Client->>+Server: HTTP GET EndDeviceListLink + Server-->>-Client: HTTP 200 + Note left of Client: If SFDI within EndDevice matches
find RegistrationLink + loop DERCapabilities, DERSettings, DERStatus and DERAvailability + Client->>+Server: HTTP PUT + Server-->>-Client: HTTP 201 + end \ No newline at end of file diff --git a/diagrams/csip-comm-006.svg b/diagrams/csip-comm-006.svg new file mode 100644 index 00000000..7bb2a60b --- /dev/null +++ b/diagrams/csip-comm-006.svg @@ -0,0 +1 @@ +ClientServerFind EndDeviceListLinkIf SFDI within EndDevice matches find RegistrationLinkloop[DERCapabilities, DERSettings,DERStatus and DERAvailability]HTTP GET DeviceCapabilityLink1HTTP 2002HTTP GET EndDeviceListLink3HTTP 2004HTTP PUT <Link>5HTTP 2016ClientServer \ No newline at end of file From e812de229218deafc38814bc6e32008724c2e33a Mon Sep 17 00:00:00 2001 From: Tylores Date: Sat, 4 Feb 2023 10:13:02 -0800 Subject: [PATCH 006/108] Update README.md --- diagrams/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/diagrams/README.md b/diagrams/README.md index bf2e53cb..c110da4f 100644 --- a/diagrams/README.md +++ b/diagrams/README.md @@ -1,6 +1,6 @@ -# [https://mermaid.js.org/](Mermaid) +# [Mermaid](https://mermaid.js.org/) I have been looking for a easy integration programable diagram solution for a while and I think this is it. The sytax is very simple and it integrates with nearly everything or can run stand alone. Also the default output is SVG. - \ No newline at end of file + From 8749eb21a77bfc49a595f4276f334327c2b88e5b Mon Sep 17 00:00:00 2001 From: Tylores Date: Sat, 4 Feb 2023 10:14:15 -0800 Subject: [PATCH 007/108] Update README.md --- diagrams/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diagrams/README.md b/diagrams/README.md index c110da4f..28e64f5e 100644 --- a/diagrams/README.md +++ b/diagrams/README.md @@ -3,4 +3,4 @@ I have been looking for a easy integration programable diagram solution for a while and I think this is it. The sytax is very simple and it integrates with nearly everything or can run stand alone. Also the default output is SVG. - + From b277d8c7b94fc0fa4b3755d2c980b2ad4acfe6ea Mon Sep 17 00:00:00 2001 From: Tylores Date: Sat, 4 Feb 2023 10:16:36 -0800 Subject: [PATCH 008/108] Update README.md --- diagrams/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/diagrams/README.md b/diagrams/README.md index 28e64f5e..eed22dde 100644 --- a/diagrams/README.md +++ b/diagrams/README.md @@ -3,4 +3,5 @@ I have been looking for a easy integration programable diagram solution for a while and I think this is it. The sytax is very simple and it integrates with nearly everything or can run stand alone. Also the default output is SVG. - +```mermaid:csip-comm-006.mmd +``` From a4cec2034ccbf1a4a3864d8b3f48a3037b30f533 Mon Sep 17 00:00:00 2001 From: Tylores Date: Sat, 4 Feb 2023 10:22:26 -0800 Subject: [PATCH 009/108] Update README.md --- diagrams/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/diagrams/README.md b/diagrams/README.md index eed22dde..8f89d1f3 100644 --- a/diagrams/README.md +++ b/diagrams/README.md @@ -3,5 +3,4 @@ I have been looking for a easy integration programable diagram solution for a while and I think this is it. The sytax is very simple and it integrates with nearly everything or can run stand alone. Also the default output is SVG. -```mermaid:csip-comm-006.mmd -``` +https://github.com/PortlandStatePowerLab/doe-egot-system/blob/b277d8c7b94fc0fa4b3755d2c980b2ad4acfe6ea/diagrams/csip-comm-006.mmd From 1ccee7d9cafd013cacbb68c0b2867ed8ccfba42b Mon Sep 17 00:00:00 2001 From: Tylores Date: Sat, 4 Feb 2023 10:25:55 -0800 Subject: [PATCH 010/108] Update README.md --- diagrams/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/diagrams/README.md b/diagrams/README.md index 8f89d1f3..d694a679 100644 --- a/diagrams/README.md +++ b/diagrams/README.md @@ -3,4 +3,5 @@ I have been looking for a easy integration programable diagram solution for a while and I think this is it. The sytax is very simple and it integrates with nearly everything or can run stand alone. Also the default output is SVG. -https://github.com/PortlandStatePowerLab/doe-egot-system/blob/b277d8c7b94fc0fa4b3755d2c980b2ad4acfe6ea/diagrams/csip-comm-006.mmd +```mermaid:./csip-comm-006.mmd +``` From f51e393dc02d8d5e0d682fa5bbff1f1d07ecf45c Mon Sep 17 00:00:00 2001 From: Tylores Date: Sat, 4 Feb 2023 10:29:31 -0800 Subject: [PATCH 011/108] Update README.md --- diagrams/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/diagrams/README.md b/diagrams/README.md index d694a679..317e3036 100644 --- a/diagrams/README.md +++ b/diagrams/README.md @@ -3,5 +3,4 @@ I have been looking for a easy integration programable diagram solution for a while and I think this is it. The sytax is very simple and it integrates with nearly everything or can run stand alone. Also the default output is SVG. -```mermaid:./csip-comm-006.mmd -``` +The mermaid files ".mmd" can be viewed through github without uploading the SVGs which is also nice. I will keep playing around with this tool as I think it would be a great addition for some diagrams. From d383ae571b6bca9d418797252188e7ec57e5e0a8 Mon Sep 17 00:00:00 2001 From: Tylores Date: Thu, 9 Feb 2023 06:32:52 -0800 Subject: [PATCH 012/108] still testing out some of the new figures. --- .gitignore | 3 ++ diagrams/csip-comm-006.svg | 1 - diagrams/flow-reservation.mmd | 18 ++++++++++++ .../{csip-comm-006.mmd => registration.mmd} | 1 + diagrams/time-sync.mmd | 10 +++++++ diagrams/waterheater-state.mmd | 29 +++++++++++++++++++ 6 files changed, 61 insertions(+), 1 deletion(-) delete mode 100644 diagrams/csip-comm-006.svg create mode 100644 diagrams/flow-reservation.mmd rename diagrams/{csip-comm-006.mmd => registration.mmd} (89%) create mode 100644 diagrams/time-sync.mmd create mode 100644 diagrams/waterheater-state.mmd diff --git a/.gitignore b/.gitignore index 8ffa5a31..df8da901 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,9 @@ *.out *.app +# Diagrams +*.svg + # Directories .vscode/ build/ diff --git a/diagrams/csip-comm-006.svg b/diagrams/csip-comm-006.svg deleted file mode 100644 index 7bb2a60b..00000000 --- a/diagrams/csip-comm-006.svg +++ /dev/null @@ -1 +0,0 @@ -ClientServerFind EndDeviceListLinkIf SFDI within EndDevice matches find RegistrationLinkloop[DERCapabilities, DERSettings,DERStatus and DERAvailability]HTTP GET DeviceCapabilityLink1HTTP 2002HTTP GET EndDeviceListLink3HTTP 2004HTTP PUT <Link>5HTTP 2016ClientServer \ No newline at end of file diff --git a/diagrams/flow-reservation.mmd b/diagrams/flow-reservation.mmd new file mode 100644 index 00000000..ab91503b --- /dev/null +++ b/diagrams/flow-reservation.mmd @@ -0,0 +1,18 @@ +sequenceDiagram +%%{init:{'theme':'neutral'}}%% +%% @backgroundColor(transparent) + autonumber + Client->>+Server: HTTP POST FlowReservationRequestLink + Server-->>-Client: HTTP 201 + Note right of Server: Generate FlowReservationResponse + Client->>+Server: HTTP GET FlowReservationResponseListLink + Server-->>-Client: HTTP 200 + Note left of Client: Find MRID + loop Scheduled + Client->>+Server: HTTP GET FlowReservationResponseLink + Server-->>-Client: HTTP 200 + end + loop Active + Client->>+Server: HTTP PUT PowerStatusLink + Server-->>-Client: HTTP 201 + end \ No newline at end of file diff --git a/diagrams/csip-comm-006.mmd b/diagrams/registration.mmd similarity index 89% rename from diagrams/csip-comm-006.mmd rename to diagrams/registration.mmd index faef85cc..07414d9a 100644 --- a/diagrams/csip-comm-006.mmd +++ b/diagrams/registration.mmd @@ -2,6 +2,7 @@ sequenceDiagram %%{init:{'theme':'neutral'}}%% %% @backgroundColor(transparent) autonumber + Note over Client,Server: out-of-band: EndDevice, Registration Client->>+Server: HTTP GET DeviceCapabilityLink Server-->>-Client: HTTP 200 Note left of Client: Find EndDeviceListLink diff --git a/diagrams/time-sync.mmd b/diagrams/time-sync.mmd new file mode 100644 index 00000000..25a63f6f --- /dev/null +++ b/diagrams/time-sync.mmd @@ -0,0 +1,10 @@ +sequenceDiagram +%%{init:{'theme':'neutral'}}%% +%% @backgroundColor(transparent) + autonumber + Client->>+Server: HTTP GET DeviceCapabilityLink + Server-->>-Client: HTTP 200 + Note left of Client: Find TimeLink + Client->>+Server: HTTP GET TimeLink + Server-->>-Client: HTTP 200 + Note left of Client: Synchronize diff --git a/diagrams/waterheater-state.mmd b/diagrams/waterheater-state.mmd new file mode 100644 index 00000000..1bea291b --- /dev/null +++ b/diagrams/waterheater-state.mmd @@ -0,0 +1,29 @@ +stateDiagram-v2 +%%{init:{'theme':'neutral'}}%% +%% @backgroundColor(transparent) + direction LR + Disconnected --> GridTied : enable() + GridTied --> Disconnected : disable() + state GridTied { + gt1 : On + gt2 : Off + gt2 --> gt1 : lowDB + gt1 --> gt2 : highDB + } + GridTied --> Shed : shed() + state Shed { + sd1 : On + sd2 : Off + sd2 --> sd1 : lowDB + sd1 --> sd2 : highDB + } + Shed --> GridTied : endShed() + Shed --> LoadUp : loadUp() + GridTied --> LoadUp : loadUp() + state LoadUp { + lu1 : On + lu2 : Off + lu2 --> lu1 : lowDB + lu1 --> lu2 : highDB + } + LoadUp --> GridTied : endShed() \ No newline at end of file From 3e6ea95350340490fa50ad24a732fb9b32a48f37 Mon Sep 17 00:00:00 2001 From: Tylores Date: Tue, 25 Apr 2023 18:40:21 -0700 Subject: [PATCH 013/108] restructure and clean up of DCM along with sep modifications --- CMakeLists.txt | 8 +- dcm/src/CMakeLists.txt | 23 +- dcm/src/command_pattern/CMakeLists.txt | 30 -- dcm/src/command_pattern/dcm_commands.cpp | 247 ----------- dcm/src/command_pattern/ecs_dcm.cpp | 177 -------- .../include/command_pattern/base_invoker.hpp | 45 -- .../include/command_pattern/base_receiver.hpp | 35 -- .../include/command_pattern/dcm_commands.hpp | 125 ------ .../include/command_pattern/ecs_dcm.hpp | 79 ---- .../include/command_pattern/s_sim_invoker.hpp | 38 -- .../command_pattern/simple_sim_receiver.hpp | 56 --- dcm/src/command_pattern/s_sim_invoker.cpp | 81 ---- .../command_pattern/simple_sim_receiver.cpp | 60 --- dcm/src/communication/dtm_client.cpp | 58 --- dcm/src/communication/gsp_client.cpp | 58 --- dcm/src/communication/include/dtm_client.hpp | 42 -- dcm/src/communication/include/gsp_client.hpp | 41 -- .../include/trust_cta2045_client.hpp | 96 ----- .../include/trust_gsp_client.hpp | 42 -- .../communication/trust_cta2045_client.cpp | 400 ------------------ dcm/src/communication/trust_gsp_client.cpp | 136 ------ dcm/src/ecs/CMakeLists.txt | 31 +- dcm/src/ecs/{ => cta2045}/cta2045_module.cpp | 0 .../{include => cta2045}/cta2045_module.hpp | 0 dcm/src/ecs/der.cpp | 63 --- dcm/src/ecs/include/der.hpp | 49 --- dcm/src/ecs/include/sep_common_module.hpp | 17 - .../ecs/include/sep_smart_energy_module.hpp | 14 - dcm/src/ecs/include/sep_support_module.hpp | 15 - dcm/src/ecs/include/simulation_module.hpp | 44 -- dcm/src/ecs/include/waterheater.hpp | 21 - .../{communication => ecs/sep}/CMakeLists.txt | 21 +- dcm/src/ecs/sep/dcap.cpp | 55 +++ dcm/src/ecs/sep/fsa.cpp | 33 ++ dcm/src/ecs/sep/include/sep/dcap.hpp | 38 ++ dcm/src/ecs/sep/include/sep/fsa.hpp | 38 ++ dcm/src/ecs/sep/include/sep/simple_types.hpp | 60 +++ dcm/src/ecs/sep_common_module.cpp | 19 - dcm/src/ecs/sep_smart_energy_module.cpp | 20 - dcm/src/ecs/sep_support_module.cpp | 155 ------- dcm/src/ecs/simulation_module.cpp | 6 - dcm/src/ecs/waterheater.cpp | 85 ---- dcm/src/main.cpp | 100 ++--- dtm/src/dtm/CMakeLists.txt | 4 +- dtm/src/main.cpp | 36 +- .../include/ieee-2030.5/abstract_device.hpp | 3 +- .../include/ieee-2030.5/active_power.hpp | 7 +- .../ieee-2030.5/billing_meter_reading.hpp | 31 ++ .../include/ieee-2030.5/billing_period.hpp | 24 ++ .../ieee-2030.5/billing_reading_set.hpp | 18 + .../include/ieee-2030.5/configuration.hpp | 9 +- .../consumption_tariff_interval.hpp | 44 ++ .../include/ieee-2030.5/currency_code.hpp | 15 + .../include/ieee-2030.5/customer_account.hpp | 20 + .../ieee-2030.5/customer_agreement.hpp | 34 ++ .../ieee-2030.5/date_time_interval.hpp | 7 +- .../include/ieee-2030.5/device_capability.hpp | 35 +- .../include/ieee-2030.5/end_device.hpp | 51 +-- .../ieee-2030.5/environmental_cost.hpp | 26 ++ .../ieee-2030.5/include/ieee-2030.5/event.hpp | 3 +- .../include/ieee-2030.5/event_status.hpp | 30 +- .../ieee-2030.5/flow_reservation_request.hpp | 19 +- .../ieee-2030.5/flow_reservation_response.hpp | 7 +- .../ieee-2030.5/function_set_assignments.hpp | 0 .../function_set_assignments_base.hpp | 26 +- .../ieee-2030.5/meter_reading_base.hpp | 2 +- .../include/ieee-2030.5/prepayment.hpp | 14 + .../price_response_configuration.hpp | 19 + .../include/ieee-2030.5/primacy_type.hpp | 4 +- .../include/ieee-2030.5/rate_component.hpp | 25 ++ .../include/ieee-2030.5/reading.hpp | 3 +- .../include/ieee-2030.5/reading_set_base.hpp | 2 +- .../include/ieee-2030.5/reading_type.hpp | 17 +- .../include/ieee-2030.5/request_status.hpp | 5 +- .../ieee-2030.5/respondable_resource.hpp | 10 +- ...ondable_subscribable_identified_object.hpp | 7 +- .../include/ieee-2030.5/service_kind.hpp | 6 +- .../ieee-2030.5/signed_real_energy.hpp | 5 +- .../include/ieee-2030.5/simple_types.hpp | 61 +++ .../include/ieee-2030.5/subscribable_type.hpp | 4 +- .../include/ieee-2030.5/tariff_profile.hpp | 20 + .../ieee-2030.5/time_tariff_interval.hpp | 23 + 82 files changed, 778 insertions(+), 2659 deletions(-) delete mode 100644 dcm/src/command_pattern/CMakeLists.txt delete mode 100644 dcm/src/command_pattern/dcm_commands.cpp delete mode 100644 dcm/src/command_pattern/ecs_dcm.cpp delete mode 100644 dcm/src/command_pattern/include/command_pattern/base_invoker.hpp delete mode 100644 dcm/src/command_pattern/include/command_pattern/base_receiver.hpp delete mode 100644 dcm/src/command_pattern/include/command_pattern/dcm_commands.hpp delete mode 100644 dcm/src/command_pattern/include/command_pattern/ecs_dcm.hpp delete mode 100644 dcm/src/command_pattern/include/command_pattern/s_sim_invoker.hpp delete mode 100644 dcm/src/command_pattern/include/command_pattern/simple_sim_receiver.hpp delete mode 100644 dcm/src/command_pattern/s_sim_invoker.cpp delete mode 100644 dcm/src/command_pattern/simple_sim_receiver.cpp delete mode 100644 dcm/src/communication/dtm_client.cpp delete mode 100644 dcm/src/communication/gsp_client.cpp delete mode 100644 dcm/src/communication/include/dtm_client.hpp delete mode 100644 dcm/src/communication/include/gsp_client.hpp delete mode 100644 dcm/src/communication/include/trust_cta2045_client.hpp delete mode 100644 dcm/src/communication/include/trust_gsp_client.hpp delete mode 100644 dcm/src/communication/trust_cta2045_client.cpp delete mode 100644 dcm/src/communication/trust_gsp_client.cpp rename dcm/src/ecs/{ => cta2045}/cta2045_module.cpp (100%) rename dcm/src/ecs/{include => cta2045}/cta2045_module.hpp (100%) delete mode 100644 dcm/src/ecs/der.cpp delete mode 100644 dcm/src/ecs/include/der.hpp delete mode 100644 dcm/src/ecs/include/sep_common_module.hpp delete mode 100644 dcm/src/ecs/include/sep_smart_energy_module.hpp delete mode 100644 dcm/src/ecs/include/sep_support_module.hpp delete mode 100644 dcm/src/ecs/include/simulation_module.hpp delete mode 100644 dcm/src/ecs/include/waterheater.hpp rename dcm/src/{communication => ecs/sep}/CMakeLists.txt (53%) create mode 100644 dcm/src/ecs/sep/dcap.cpp create mode 100644 dcm/src/ecs/sep/fsa.cpp create mode 100644 dcm/src/ecs/sep/include/sep/dcap.hpp create mode 100644 dcm/src/ecs/sep/include/sep/fsa.hpp create mode 100644 dcm/src/ecs/sep/include/sep/simple_types.hpp delete mode 100644 dcm/src/ecs/sep_common_module.cpp delete mode 100644 dcm/src/ecs/sep_smart_energy_module.cpp delete mode 100644 dcm/src/ecs/sep_support_module.cpp delete mode 100644 dcm/src/ecs/simulation_module.cpp delete mode 100644 dcm/src/ecs/waterheater.cpp create mode 100644 standards/ieee-2030.5/include/ieee-2030.5/billing_meter_reading.hpp create mode 100644 standards/ieee-2030.5/include/ieee-2030.5/billing_period.hpp create mode 100644 standards/ieee-2030.5/include/ieee-2030.5/billing_reading_set.hpp create mode 100644 standards/ieee-2030.5/include/ieee-2030.5/consumption_tariff_interval.hpp create mode 100644 standards/ieee-2030.5/include/ieee-2030.5/currency_code.hpp create mode 100644 standards/ieee-2030.5/include/ieee-2030.5/customer_account.hpp create mode 100644 standards/ieee-2030.5/include/ieee-2030.5/customer_agreement.hpp create mode 100644 standards/ieee-2030.5/include/ieee-2030.5/environmental_cost.hpp create mode 100644 standards/ieee-2030.5/include/ieee-2030.5/function_set_assignments.hpp create mode 100644 standards/ieee-2030.5/include/ieee-2030.5/prepayment.hpp create mode 100644 standards/ieee-2030.5/include/ieee-2030.5/price_response_configuration.hpp create mode 100644 standards/ieee-2030.5/include/ieee-2030.5/rate_component.hpp create mode 100644 standards/ieee-2030.5/include/ieee-2030.5/simple_types.hpp create mode 100644 standards/ieee-2030.5/include/ieee-2030.5/tariff_profile.hpp create mode 100644 standards/ieee-2030.5/include/ieee-2030.5/time_tariff_interval.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d01e62d2..f0c2a5be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) # fetch remote packages for development -find_package(Boost REQUIRED filesystem python3) -find_package(PythonLibs 3 REQUIRED) +find_package(Boost REQUIRED python filesystem) +find_package(Python3 COMPONENTS Interpreter Development) include(FetchContent) FetchContent_Declare( @@ -31,7 +31,7 @@ FetchContent_Declare( FetchContent_Declare( flecs GIT_REPOSITORY https://github.com/SanderMertens/flecs.git - GIT_TAG v3.0.3 + GIT_TAG v3.2.1 ) FetchContent_MakeAvailable(googletest flecs) @@ -42,7 +42,7 @@ add_subdirectory(ecs) add_subdirectory(interfaces) add_subdirectory(dtm) #add_subdirectory(gsp) -#add_subdirectory(dcm) +add_subdirectory(dcm) # install resources for programs diff --git a/dcm/src/CMakeLists.txt b/dcm/src/CMakeLists.txt index 18e657a2..c6c91fa1 100644 --- a/dcm/src/CMakeLists.txt +++ b/dcm/src/CMakeLists.txt @@ -1,2 +1,21 @@ -add_subdirectory(communication) -add_subdirectory(ecs) \ No newline at end of file +add_subdirectory(ecs) + +set(COMPONENT_NAME dcm) + +add_executable (${COMPONENT_NAME} + main.cpp +) + +target_link_libraries(${COMPONENT_NAME} + ecs_sep + trust_https + utilities + pthread +) + +target_include_directories(${COMPONENT_NAME} PUBLIC + $ + ${ecs_sep_INCLUDE_DIRS} + ${trust_https_INCLUDE_DIRS} + ${utilities_INCLUDE_DIRS} +) \ No newline at end of file diff --git a/dcm/src/command_pattern/CMakeLists.txt b/dcm/src/command_pattern/CMakeLists.txt deleted file mode 100644 index 3706936f..00000000 --- a/dcm/src/command_pattern/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -set(COMPONENT_NAME command_pattern) - -add_library(${COMPONENT_NAME} STATIC - dcm_commands.cpp - ecs_dcm.cpp - s_sim_invoker.cpp - simple_sim_receiver.cpp -) - -# Create ALIAS targets. -add_library( ${PROJECT_NAME}::${COMPONENT_NAME} ALIAS ${COMPONENT_NAME} ) - -target_link_libraries(${COMPONENT_NAME} PUBLIC - https_client - SEP::Model - ecs_client - dtm_msg_writer - cta2045_receiver - SEP::XML - pthread -) - -target_include_directories(${COMPONENT_NAME} PUBLIC - $ - ${ecs_client_INCLUDE_DIRS} - ${https_client_INCLUDE_DIRS} - ${dtm_msg_writer_INCLUDE_DIRS} - ${cta2045_receiver_INCLUDE_DIRS} - ${SEP_INCLUDES_DIRS} -) \ No newline at end of file diff --git a/dcm/src/command_pattern/dcm_commands.cpp b/dcm/src/command_pattern/dcm_commands.cpp deleted file mode 100644 index ada1b514..00000000 --- a/dcm/src/command_pattern/dcm_commands.cpp +++ /dev/null @@ -1,247 +0,0 @@ -#include "include/command_pattern/dcm_commands.hpp" - -using namespace dcm; - -BaseCommand::BaseCommand() : https_client_(nullptr), receiver_(nullptr) -{ - // do nothing -} - -BaseCommand::BaseCommand(CombinedHttpsClient *c, BaseReceiver *r) - : https_client_(c), receiver_(r) -{ - // do nothing -} - -BaseCommand::~BaseCommand() -{ - //delete https_client_; - //delete receiver_; -} - -//================================================================================= - -ImportEnergy::ImportEnergy() -{ - // do nothing -} - -ImportEnergy::ImportEnergy(CombinedHttpsClient *client, BaseReceiver *receiver) - : BaseCommand(client, receiver) -{ - std::cout << "ImportEnergy Command Constructed " << std::endl; -} - -ImportEnergy::~ImportEnergy() -{ - // do nothing -} - -std::string ImportEnergy::Execute() -{ - std::string response_from_der = "der response not supported yet"; - std::cout << " ImportEnergy Command Executing... " << std::endl; - - //this is specific to a simulated receiver at this point, and not based on a particular resource. - https_client_->Post("DTM", xml_writer_.WriteMsg("DCM", "DER", "CTA2045_Message", "ImportEnergyCommand", "ImportEnergy")); - - response_from_der = receiver_->Import(); - - //https_client_->Post("DTM", response_from_der); - - //std::cout << "response from DER was: " << response_from_der << std::endl; - //std::string msg_in = xml_writer_.ReturnCustomCommand("DCM", "DER", response_from_der, "na", "na", "response"); - //https_client_->Post("DTM",msg_in); - - return response_from_der; -} - -//================================================================================= - -ExportEnergy::ExportEnergy() -{ - // do nothing -} - -ExportEnergy::ExportEnergy(CombinedHttpsClient *client, BaseReceiver *receiver) - : BaseCommand(client, receiver) -{ - // do nothing -} - -ExportEnergy::~ExportEnergy() -{ - // do nothing -} - -std::string ExportEnergy::Execute() -{ - std::string response_from_der = "der response not supported yet"; - std::cout << " ExportEnergy Command Executing... " << std::endl; - - //this is specific to a simulated receiver at this point, and not based on a particular resource. - https_client_->Post("DTM", xml_writer_.WriteMsg("DCM", "DER", "CTA2045_Message", "ExportEnergyCommand", "ExportEnergy")); - - response_from_der = receiver_->Export(); - //https_client_->Post("DTM", response_from_der); - - return response_from_der; -} - -//================================================================================= - -GetEnergy::GetEnergy() -{ - // do nothing -} - -GetEnergy::GetEnergy(CombinedHttpsClient *client, BaseReceiver *receiver) - : BaseCommand(client, receiver) -{ - // do nothing -} - -GetEnergy::~GetEnergy() -{ - // do nothing -} - -std::string GetEnergy::Execute() -{ - std::string response_from_der = "der response not supported yet"; - std::cout << " GetEnergy Command Executing... " << std::endl; - - //this is specific to a simulated receiver at this point, and not based on a particular resource. - https_client_->Post("DTM", xml_writer_.WriteMsg("DCM", "DER", "CTA2045_Message", "GetEnergyCommand", "GetEnergy")); - response_from_der = receiver_->GetEnergy(); - if (response_from_der[0] == 'C') //if cta2045receiver - { - std::cout << "GetEnergy::Execute() response from der: " << response_from_der << std::endl; - } - https_client_->Post("DTM", xml_writer_.WriteMsg("DER", "DCM", "CTA2045_Message", "GetEnergyResponse", response_from_der)); - return response_from_der; -} - -//================================================================================= - -GetNameplate::GetNameplate() -{ - // do nothing -} - -GetNameplate::GetNameplate(CombinedHttpsClient *client, BaseReceiver *receiver) - : BaseCommand(client, receiver) -{ - // do nothing -} - -GetNameplate::~GetNameplate() -{ - // do nothing -} - -std::string GetNameplate::Execute() -{ - std::string response_from_der = "der response not supported yet"; - std::cout << " GetNameplate Command Executing... " << std::endl; - - https_client_->Post("DTM", xml_writer_.WriteMsg("DCM", "DER", "CTA2045_Message", "GetNameplateCommand", "GetNameplate")); - response_from_der = receiver_->GetNameplate(); - https_client_->Post("DTM", xml_writer_.WriteMsg("DER", "DCM", "CTA2045_Message", "GetNameplateResponse", response_from_der)); - - return response_from_der; -} - -//================================================================================= - -Idle::Idle() -{ - // do nothing -} - -Idle::Idle(CombinedHttpsClient *client, BaseReceiver *receiver) - : BaseCommand(client, receiver) -{ - // do nothing -} - -Idle::~Idle() -{ - // do nothing -} - -std::string Idle::Execute() -{ - std::string response_from_der = "der response not supported yet"; - std::cout << " Idle Command Executing... " << std::endl; - - //this is specific to a simulated receiver at this point, and not based on a particular resource. - https_client_->Post("DTM", xml_writer_.WriteMsg("DCM", "DER", "CTA2045_Message", "IdleCommand", "Idle")); - - response_from_der = receiver_->Idle(); - //https_client_->Post("DTM", response_from_der); - - return response_from_der; -} - -//================================================================================= - -CriticalPeakEvent::CriticalPeakEvent() -{ - // do nothing -} - -CriticalPeakEvent::CriticalPeakEvent(CombinedHttpsClient *client, BaseReceiver *receiver) - : BaseCommand(client, receiver) -{ - // do nothing -} - -CriticalPeakEvent::~CriticalPeakEvent() -{ - // do nothing -} - -std::string CriticalPeakEvent::Execute() -{ - std::string response_from_der = "der response not supported yet"; - std::cout << " CriticalPeakEvent Command Executing... " << std::endl; - - //this is specific to a simulated receiver at this point, and not based on a particular resource. - https_client_->Post("DTM", xml_writer_.WriteMsg("DCM", "DER", "CTA2045_Message", "CriticalPeakEventCommand", "CriticalPeakEvent")); - response_from_der = receiver_->CriticalPeakEvent(); - //https_client_->Post("DTM", response_from_der); - - return response_from_der; -} - -//================================================================================= - -GridEmergencyEvent::GridEmergencyEvent() -{ - // do nothing - -} - -GridEmergencyEvent::GridEmergencyEvent(CombinedHttpsClient *client, BaseReceiver *receiver) - : BaseCommand(client, receiver) -{ - // do nothing -} - -GridEmergencyEvent::~GridEmergencyEvent() -{ - // do nothing -} -std::string GridEmergencyEvent::Execute() -{ - std::string response_from_der; - std::cout << " GridEmergencyEvent Command Executing... " << std::endl; - - //this is specific to a simulated receiver at this point, and not based on a particular resource. - https_client_->Post("DTM", xml_writer_.WriteMsg("DCM", "DER", "CTA2045_Message", "GridEmergencyEventCommand", "GridEmergencyEvent")); - response_from_der = receiver_->GridEmergencyEvent(); - //https_client_->Post("DTM", response_from_der); - - return response_from_der; -} \ No newline at end of file diff --git a/dcm/src/command_pattern/ecs_dcm.cpp b/dcm/src/command_pattern/ecs_dcm.cpp deleted file mode 100644 index 85226a08..00000000 --- a/dcm/src/command_pattern/ecs_dcm.cpp +++ /dev/null @@ -1,177 +0,0 @@ -#include "include/command_pattern/ecs_dcm.hpp" - -using namespace dcm; - -ECS_DCM::ECS_DCM() : - combined_client_(nullptr), - receiver_(nullptr), - sim_flow_invoker_(nullptr), - import_energy_c_(nullptr), - export_energy_c_(nullptr), - get_energy_c_(nullptr), - get_nameplate_c_(nullptr), - idle_c_(nullptr), - crit_peak_c_(nullptr), - grid_emergency_c_(nullptr) -{ - //SetReceiver(); - //need a program path -} - -ECS_DCM::ECS_DCM(const std::string &root) : - combined_client_(nullptr), - receiver_(nullptr), - sim_flow_invoker_(nullptr), - import_energy_c_(nullptr), - export_energy_c_(nullptr), - get_energy_c_(nullptr), - get_nameplate_c_(nullptr), - idle_c_(nullptr), - crit_peak_c_(nullptr), - grid_emergency_c_(nullptr) -{ - std::cout << " ECS_DCM root arg overload constructor reduced" << std::endl; - - combined_client_ = new CombinedHttpsClient(root, "localhost", "4430", root, "localhost", "4430"); - SetReceiver(); //have to init after https init - import_energy_c_ = new ImportEnergy(combined_client_, receiver_); - export_energy_c_ = new ExportEnergy(combined_client_, receiver_); - get_energy_c_ = new GetEnergy(combined_client_, receiver_); - get_nameplate_c_ = new GetNameplate(combined_client_, receiver_); - idle_c_ = new Idle(combined_client_, receiver_); - sim_flow_invoker_ = new SimpleSimulatorFlowResInvoker(&dcm_world_, import_energy_c_, - export_energy_c_, get_energy_c_, - get_nameplate_c_, idle_c_, crit_peak_c_); - crit_peak_c_ = new CriticalPeakEvent(combined_client_, receiver_); - grid_emergency_c_ = new GridEmergencyEvent(combined_client_, receiver_); - dcm_world_.import(); - std::string startup_msg = xml_writer_.WriteMsg("DCM", "DTM", "CTA2045_Message", "DCM_Startup", "DCM system starting up"); - combined_client_->Post("DTM", startup_msg); -} - -ECS_DCM::~ECS_DCM() -{ - std::string shutdown_msg = xml_writer_.WriteMsg("DCM", "DTM", "CTA2045_Message", "DCM_Shutdown", "DCM system shutting down"); - combined_client_->Post("DTM", shutdown_msg); - std::cout << " ECS_DCM Destructor" << std::endl; - if (combined_client_) - delete combined_client_; - std::cout << "1" << std::endl; - if (sim_flow_invoker_) - { - std::cout << "1.5" << std::endl; - delete sim_flow_invoker_; - } - std::cout << "2" << std::endl; - if (receiver_) - delete receiver_; - std::cout << "3" << std::endl; - if (import_energy_c_) - delete import_energy_c_; - std::cout << "4" << std::endl; - if (export_energy_c_) - delete export_energy_c_; - std::cout << "5" << std::endl; - if (get_energy_c_) - delete get_energy_c_; - std::cout << "6" << std::endl; - if (get_nameplate_c_) - delete get_nameplate_c_; - std::cout << "7" << std::endl; - if (idle_c_) - delete idle_c_; - std::cout << "8" << std::endl; - if (crit_peak_c_) - delete crit_peak_c_; - std::cout << "9" << std::endl; - if (grid_emergency_c_) - delete grid_emergency_c_; - std::cout << "10" << std::endl; -} - -void ECS_DCM::SetReceiver() -{ - std::cout << " ECS_DCM::SetReceiver(), please type 0 for simulator and 1 for CTA2045 " << std::endl; - // imaginary comms tests, or pre-defined binary init - int choice = 0; - std::cin >> choice; - std::cin.ignore(100, '\n'); - if (choice) - { - receiver_ = new CTA2045Receiver(combined_client_); - } - else - receiver_ = new SimpleSimulatorReceiver; //emulated DER -} - -void ECS_DCM::RunSimulatorLoop() -{ - // TODO -} - -void ECS_DCM::TestCTA2045Commands() -{ - - bool shutdown = false; - - while (!shutdown) - { - std::cout << "TESTING CTA-2045 COMMANDS" << std::endl; - std::cout << "c - GetEnergy() " << std::endl; - std::cout << "n - GetNameplate() " << std::endl; - std::cout << "i - ImportEnergy() " << std::endl; - std::cout << "e - ExportEnergy() " << std::endl; - std::cout << "d - Idle() " << std::endl; - std::cout << "p - CriticalPeakEvent() " << std::endl; - std::cout << "q - quit " << std::endl; - std::cout << "==============" << std::endl; - - char c = getchar(); - std::cin.ignore(100, '\n'); - - switch (c) - { - case 'c': - get_energy_c_->Execute(); - break; - case 'n': - get_nameplate_c_->Execute(); - break; - case 'i': - import_energy_c_->Execute(); - break; - case 'e': - export_energy_c_->Execute(); - break; - case 'd': - idle_c_->Execute(); - break; - case 'p': - crit_peak_c_->Execute(); - break; - case 'q': - shutdown = true; - break; - default: - std::cout << "invalid command" << std::endl;; - break; - } - std::cout << "==============" << std::endl; - } - -} - -void ECS_DCM::AddFlowResRespEntity(sep::FlowReservationResponse &flowresresp) -{ - // TODO -} - -sep::FlowReservationResponse ECS_DCM::GetFlowResRespFromGSP() -{ - // TODO -} - -void ECS_DCM::InitializeFlowResInvokingSystems() -{ - // TODO -} \ No newline at end of file diff --git a/dcm/src/command_pattern/include/command_pattern/base_invoker.hpp b/dcm/src/command_pattern/include/command_pattern/base_invoker.hpp deleted file mode 100644 index 129a5ae2..00000000 --- a/dcm/src/command_pattern/include/command_pattern/base_invoker.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef __BASE_INVOKER_H__ -#define __BASE_INVOKER_H__ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "dcm_commands.hpp" - -namespace dcm -{ - -class BaseInvoker -{ - public: - BaseInvoker( - flecs::world *shared, - ImportEnergy *imp, - ExportEnergy *exp, - GetEnergy *get_e, - GetNameplate *get_n, - Idle *idle, - CriticalPeakEvent *crit); - ~BaseInvoker(); - virtual void ProcessResource(flecs::entity *e) = 0; - - protected: - flecs::world *shared_world_ptr_; - ImportEnergy *import_; - ExportEnergy *export_; - GetEnergy *get_energy_; - GetNameplate *get_nameplate_; - Idle *idle_; - CriticalPeakEvent *crit_; -}; - -} //namespace dcm -#endif //__S_SIM_INVOKER_H__ \ No newline at end of file diff --git a/dcm/src/command_pattern/include/command_pattern/base_receiver.hpp b/dcm/src/command_pattern/include/command_pattern/base_receiver.hpp deleted file mode 100644 index a008429f..00000000 --- a/dcm/src/command_pattern/include/command_pattern/base_receiver.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __BASE_RECEIVER_H__ -#define __BASE_RECEIVER_H__ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace dcm -{ - // abstract class - class BaseReceiver - { - public: - virtual std::string Import() = 0; - virtual std::string Export() = 0; - virtual std::string GetEnergy() = 0; - virtual std::string GetNameplate() = 0; - virtual std::string Idle() = 0; - virtual std::string CriticalPeakEvent() = 0; - virtual std::string GridEmergencyEvent() = 0; - - private: - }; - -} // namespace dcm - -#endif //__SIMPLE_SIM_RECEIVER_H__ \ No newline at end of file diff --git a/dcm/src/command_pattern/include/command_pattern/dcm_commands.hpp b/dcm/src/command_pattern/include/command_pattern/dcm_commands.hpp deleted file mode 100644 index a1f6517c..00000000 --- a/dcm/src/command_pattern/include/command_pattern/dcm_commands.hpp +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef __DCM_COMMANDS_H__ -#define __DCM_COMMANDS_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "simple_sim_receiver.hpp" -#include - -namespace dcm -{ - -class BaseCommand -{ - public: - BaseCommand(); - BaseCommand(CombinedHttpsClient *c, BaseReceiver *r); - ~BaseCommand(); - virtual std::string Execute() = 0; - - protected: - CombinedHttpsClient *https_client_; - BaseReceiver *receiver_; - xml::XMLCommandAdapter xml_writer_; -}; - -//=============================================================================== - -class ImportEnergy : public BaseCommand -{ - public: - ImportEnergy(); - ImportEnergy(CombinedHttpsClient *client, BaseReceiver *receiver); - ~ImportEnergy(); - std::string Execute(); - - private: -}; - -//=============================================================================== - -class ExportEnergy : public BaseCommand -{ - public: - ExportEnergy(); - ExportEnergy(CombinedHttpsClient *client, BaseReceiver *receiver); - ~ExportEnergy(); - std::string Execute(); - - private: -}; - -//=============================================================================== - -class GetEnergy : public BaseCommand -{ - public: - GetEnergy(); - GetEnergy(CombinedHttpsClient *client, BaseReceiver *receiver); - ~GetEnergy(); - std::string Execute(); - - private: -}; - -//=============================================================================== - -class GetNameplate : public BaseCommand -{ - public: - GetNameplate(); - GetNameplate(CombinedHttpsClient *client, BaseReceiver *receiver); - ~GetNameplate(); - std::string Execute(); - - private: -}; - -//=============================================================================== - -class Idle : public BaseCommand -{ - public: - Idle(); - Idle(CombinedHttpsClient *client, BaseReceiver *receiver); - ~Idle(); - std::string Execute(); - - private: -}; - -//=============================================================================== - -class CriticalPeakEvent : public BaseCommand -{ - public: - CriticalPeakEvent(); - CriticalPeakEvent(CombinedHttpsClient *client, BaseReceiver *receiver); - ~CriticalPeakEvent(); - std::string Execute(); - - private: -}; - -class GridEmergencyEvent : public BaseCommand -{ - public: - GridEmergencyEvent(); - GridEmergencyEvent(CombinedHttpsClient *client, BaseReceiver *receiver); - ~GridEmergencyEvent(); - std::string Execute(); - - private: -}; - -} // namespace dcm - -#endif //__DCM_COMMANDS_H__ \ No newline at end of file diff --git a/dcm/src/command_pattern/include/command_pattern/ecs_dcm.hpp b/dcm/src/command_pattern/include/command_pattern/ecs_dcm.hpp deleted file mode 100644 index 7d80f2b9..00000000 --- a/dcm/src/command_pattern/include/command_pattern/ecs_dcm.hpp +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef __ECS_DCM_H__ -#define __ECS_DCM_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../../cta2045_receiver/include/cta2045_receiver/cta2045_receiver.hpp" -#include "s_sim_invoker.hpp" - -static const std::string FLOW_RESERVATION_REQUEST = R"( - - 0FB7 - description1 - 0 - 1 - 0 - - 1 - -140737488355328 - - - 0 - 1 - - - 1 - 1 - - - 1 - 0 - -)"; - -namespace dcm -{ - -class ECS_DCM -{ -public: - ECS_DCM(); - ECS_DCM(const std::string &root); - ~ECS_DCM(); - void SetReceiver(); - void RunSimulatorLoop(); - void TestCTA2045Commands(); - void AddFlowResRespEntity(sep::FlowReservationResponse &flowresresp); - sep::FlowReservationResponse GetFlowResRespFromGSP(); - void InitializeFlowResInvokingSystems(); - -private: - flecs::world dcm_world_; - xml::XMLCommandAdapter xml_writer_; - CombinedHttpsClient *combined_client_; - BaseInvoker *sim_flow_invoker_; - BaseReceiver *receiver_; - ImportEnergy *import_energy_c_; - ExportEnergy *export_energy_c_; - GetEnergy *get_energy_c_; - GetNameplate *get_nameplate_c_; - Idle *idle_c_; - CriticalPeakEvent *crit_peak_c_; - GridEmergencyEvent *grid_emergency_c_; - - //BaseInvoker * sim_invoker_; -}; - -} //namespace dcm -#endif //__ECS_DCM_H__ \ No newline at end of file diff --git a/dcm/src/command_pattern/include/command_pattern/s_sim_invoker.hpp b/dcm/src/command_pattern/include/command_pattern/s_sim_invoker.hpp deleted file mode 100644 index 88190161..00000000 --- a/dcm/src/command_pattern/include/command_pattern/s_sim_invoker.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef __S_SIM_INVOKER_H__ -#define __S_SIM_INVOKER_H__ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "dcm_commands.hpp" -#include "base_invoker.hpp" - -namespace dcm -{ -class SimpleSimulatorFlowResInvoker : public BaseInvoker -{ - public: - SimpleSimulatorFlowResInvoker( - flecs::world *shared, - ImportEnergy *imp, - ExportEnergy *exp, - GetEnergy *get_e, - GetNameplate *get_n, - Idle *idle, - CriticalPeakEvent *crit); - ~SimpleSimulatorFlowResInvoker(); - void ProcessResource(flecs::entity *e); - - private: -}; - -} //namespace dcm -#endif //__S_SIM_INVOKER_H__ \ No newline at end of file diff --git a/dcm/src/command_pattern/include/command_pattern/simple_sim_receiver.hpp b/dcm/src/command_pattern/include/command_pattern/simple_sim_receiver.hpp deleted file mode 100644 index acea7136..00000000 --- a/dcm/src/command_pattern/include/command_pattern/simple_sim_receiver.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef __SIMPLE_SIM_RECEIVER_H__ -#define __SIMPLE_SIM_RECEIVER_H__ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "base_receiver.hpp" - -namespace dcm -{/* - // abstract class - class BaseReceiver - { - public: - virtual std::string Import() = 0; - virtual std::string Export() = 0; - virtual std::string GetEnergy() = 0; - virtual std::string GetNameplate() = 0; - virtual std::string Idle() = 0; - virtual std::string CriticalPeakEvent() = 0; - virtual std::string GridEmergencyEvent() = 0; - - private: - }; -*/ - // This is a receiver class for interacting with a simulated DER - class SimpleSimulatorReceiver : public BaseReceiver - { - public: - SimpleSimulatorReceiver(); - ~SimpleSimulatorReceiver(); - std::string Import(); - std::string Export(); - std::string GetEnergy(); - std::string GetNameplate(); - std::string Idle(); - std::string CriticalPeakEvent(); - std::string GridEmergencyEvent(); - void IncrementSimulatorProgress(); - - private: - xml::XMLCommandAdapter xml_writer_; - der::DERSimulator *sim_der_; - }; - -} // namespace dcm - -#endif //__SIMPLE_SIM_RECEIVER_H__ \ No newline at end of file diff --git a/dcm/src/command_pattern/s_sim_invoker.cpp b/dcm/src/command_pattern/s_sim_invoker.cpp deleted file mode 100644 index a3200e6e..00000000 --- a/dcm/src/command_pattern/s_sim_invoker.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include "include/command_pattern/s_sim_invoker.hpp" - -using namespace dcm; - -BaseInvoker::BaseInvoker( - flecs::world *shared, - ImportEnergy *imp, - ExportEnergy *exp, - GetEnergy *get_e, - GetNameplate *get_n, - Idle *idle, - CriticalPeakEvent *crit) - : shared_world_ptr_(shared), - import_(imp), - export_(exp), - get_energy_(get_e), - get_nameplate_(get_n), - idle_(idle), - crit_(crit) -{ - shared_world_ptr_->import(); -} - -BaseInvoker::~BaseInvoker() -{ - std::cout << " BaseInvoker destructor a" << std::endl; - /* delete idle_; - std::cout << " b " << std::endl; - delete get_nameplate_; - std::cout << " c " << std::endl; - delete get_energy_; - std::cout << " d " << std::endl; - delete export_; - std::cout << " e " << std::endl; - delete import_; - std::cout << " f " << std::endl; - //delete shared_world_ptr_; - std::cout << " g " << std::endl; */ -} - -SimpleSimulatorFlowResInvoker::SimpleSimulatorFlowResInvoker( - flecs::world *shared, - ImportEnergy *imp, - ExportEnergy *exp, - GetEnergy *get_e, - GetNameplate *get_n, - Idle *idle, - CriticalPeakEvent *crit) - : BaseInvoker(shared, imp, exp, get_e, get_n, idle, crit) -{ - std::cout << "SimpleSimulatorFlowResInvoker" << std::endl; -} - -SimpleSimulatorFlowResInvoker::~SimpleSimulatorFlowResInvoker() -{ - std::cout << "SimpleSimulatorFlowResInvoker Destructor " << std::endl; - // do nothing -} - -void SimpleSimulatorFlowResInvoker::ProcessResource(flecs::entity *e) -{ - std::cout << "SSFRI ProcessResource method called" << std::endl; - if (e->has()) - { - std::cout << "entity has flowreservation response" << std::endl; - sep::FlowReservationResponse *flowres_ptr = e->get_mut(); - sep::CurrentStatus *c_status_ptr = e->get_mut(); - - // Hook to change entity's status components based on contents of flowresresp component - // also, we can actually sent commands, though I don't know the specifics of how that logic should work - // Now we can look at the data in the flowres_ptr and call a command or something - - // demo of commands - if (*c_status_ptr == sep::CurrentStatus::kActive) - { - std::cout << "flowres entity currentStatus is Active " << std::endl; - import_->Execute(); - shared_world_ptr_->set({dcm_components_module::DERPrevCommand::kImportEnergy}); - } - } -} \ No newline at end of file diff --git a/dcm/src/command_pattern/simple_sim_receiver.cpp b/dcm/src/command_pattern/simple_sim_receiver.cpp deleted file mode 100644 index 1491815a..00000000 --- a/dcm/src/command_pattern/simple_sim_receiver.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "include/command_pattern/simple_sim_receiver.hpp" - -using namespace dcm; - -SimpleSimulatorReceiver::SimpleSimulatorReceiver() -{ - std::cout << " SimpleSimulatorReceiver default constructor " << std::endl; - sim_der_ = new der::DERSimulator; -} - -SimpleSimulatorReceiver::~SimpleSimulatorReceiver() -{ - std::cout << "SimpleSimulatorReceiver Destructor " << std::endl; - delete sim_der_; -} - -std::string SimpleSimulatorReceiver::Import() -{ - std::string response = sim_der_->ImportEnergy(); - return xml_writer_.ReturnCustomCommand("DCM", "DER", response, "na", "na", "response"); -} - -std::string SimpleSimulatorReceiver::Export() -{ - std::string response = sim_der_->ExportEnergy(); - return xml_writer_.ReturnCustomCommand("DCM", "DER", response, "na", "na", "response"); -} - -std::string SimpleSimulatorReceiver::GetEnergy() -{ - std::string response = sim_der_->GetEnergy(); - return xml_writer_.ReturnCustomCommand("DCM", "DER", response, "na", "na", "response"); -} - -std::string SimpleSimulatorReceiver::GetNameplate() -{ - std::string response = sim_der_->GetNameplate(); - return xml_writer_.ReturnCustomCommand("DCM", "DER", response, "na", "na", "response"); -} - -std::string SimpleSimulatorReceiver::Idle() -{ - std::string response = sim_der_->Idle(); - return xml_writer_.ReturnCustomCommand("DCM", "DER", response, "na", "na", "response"); -} - -std::string SimpleSimulatorReceiver::CriticalPeakEvent() -{ - std::cout << "SimpleSimReceiver CriticalPeakEvent, not supported currently" << std::endl; -} - -std::string SimpleSimulatorReceiver::GridEmergencyEvent() -{ - std::cout << "SimpleSimReceiver GridEmergencyEvent, not supported currently" << std::endl; -} - -void SimpleSimulatorReceiver::IncrementSimulatorProgress() -{ - sim_der_->IncrementProgress(); -} \ No newline at end of file diff --git a/dcm/src/communication/dtm_client.cpp b/dcm/src/communication/dtm_client.cpp deleted file mode 100644 index 1982f297..00000000 --- a/dcm/src/communication/dtm_client.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "include/dtm_client.hpp" - -DTMClient::DTMClient(const https::Context& context) - : client_(context) -{ - // do nothing -} - -DTMClient::~DTMClient() -{ - delete instance_; -} - -DTMClient* DTMClient::getInstance(const https::Context& context) -{ - std::lock_guard lock(mutex_); - if(instance_ = nullptr) - { - instance_ = new DTMClient(context); - } - return instance_; -} - -DTMClient* DTMClient::getInstance() -{ - std::lock_guard lock(mutex_); - if(instance_ = nullptr) - { - std::cout << "DTMClient : instance not initilized with context" << std::endl; - abort(); - } - return instance_; -} - -sep::LFDIType DTMClient::getLFDI() -{ - return client_.getLFDI(); -} - -boost::beast::http::response DTMClient::Get(const std::string &target, const std::string &query) -{ - return client_.Get(target,query); -} - -boost::beast::http::response DTMClient::Post(const std::string &target, const std::string &resource) -{ - return client_.Post(target,resource); -} - -boost::beast::http::response DTMClient::Put(const std::string &target, const std::string &resource) -{ - return client_.Put(target,resource); -} - -boost::beast::http::response DTMClient::Delete(const std::string &target) -{ - return client_.Delete(target); -} \ No newline at end of file diff --git a/dcm/src/communication/gsp_client.cpp b/dcm/src/communication/gsp_client.cpp deleted file mode 100644 index 779e00e9..00000000 --- a/dcm/src/communication/gsp_client.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "include/gsp_client.hpp" - -GSPClient::GSPClient(const https::Context& context) - : client_(context) -{ - // do nothing -} - -GSPClient::~GSPClient() -{ - delete instance_; -} - -GSPClient* GSPClient::getInstance(const https::Context& context) -{ - std::lock_guard lock(mutex_); - if(instance_ = nullptr) - { - instance_ = new GSPClient(context); - } - return instance_; -} - -GSPClient* GSPClient::getInstance() -{ - std::lock_guard lock(mutex_); - if(instance_ = nullptr) - { - std::cout << "GSPClient : instance not initilized with context" << std::endl; - abort(); - } - return instance_; -} - -sep::LFDIType GSPClient::getLFDI() -{ - return client_.getLFDI(); -} - -boost::beast::http::response GSPClient::Get(const std::string &target, const std::string &query) -{ - return client_.Get(target,query); -} - -boost::beast::http::response GSPClient::Post(const std::string &target, const std::string &resource) -{ - return client_.Post(target,resource); -} - -boost::beast::http::response GSPClient::Put(const std::string &target, const std::string &resource) -{ - return client_.Put(target,resource); -} - -boost::beast::http::response GSPClient::Delete(const std::string &target) -{ - return client_.Delete(target); -} \ No newline at end of file diff --git a/dcm/src/communication/include/dtm_client.hpp b/dcm/src/communication/include/dtm_client.hpp deleted file mode 100644 index 1ca3723a..00000000 --- a/dcm/src/communication/include/dtm_client.hpp +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef __DTM_CLIENT_H__ -#define __DTM_CLIENT_H__ - -#include -#include - -class DTMClient : public https::AbstractClient -{ -public: - DTMClient(DTMClient &other) = delete; // clonable - - void operator=(const DTMClient &) = delete; // assignable - - static DTMClient* getInstance(const https::Context& context); - static DTMClient* getInstance(); - - sep::LFDIType getLFDI() override; - - boost::beast::http::response Get( - const std::string &target, const std::string &query = "") override; - - boost::beast::http::response Post( - const std::string &target, const std::string &resource) override; - - boost::beast::http::response Put( - const std::string &target, const std::string &resource) override; - - boost::beast::http::response Delete( - const std::string &target) override; - -protected: - DTMClient(const https::Context& context); - ~DTMClient() noexcept; - -private: - static DTMClient *instance_; - static std::mutex mutex_; - https::Client client_; -}; - - -#endif // __DTM_CLIENT_H__ \ No newline at end of file diff --git a/dcm/src/communication/include/gsp_client.hpp b/dcm/src/communication/include/gsp_client.hpp deleted file mode 100644 index b6df1c32..00000000 --- a/dcm/src/communication/include/gsp_client.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef __GSP_CLIENT_H__ -#define __GSP_CLIENT_H__ - -#include -#include - -class GSPClient : public https::AbstractClient -{ -public: - GSPClient(GSPClient &other) = delete; // clonable - - void operator=(const GSPClient &) = delete; // assignable - - static GSPClient* getInstance(const https::Context& context); - static GSPClient* getInstance(); - - sep::LFDIType getLFDI() override; - - boost::beast::http::response Get( - const std::string &target, const std::string &query = "") override; - - boost::beast::http::response Post( - const std::string &target, const std::string &resource) override; - - boost::beast::http::response Put( - const std::string &target, const std::string &resource) override; - - boost::beast::http::response Delete( - const std::string &target) override; - -protected: - GSPClient(const https::Context& context); - ~GSPClient() noexcept; - -private: - static GSPClient *instance_; - static std::mutex mutex_; - https::Client client_; -}; - -#endif // __GSP_CLIENT_H__ \ No newline at end of file diff --git a/dcm/src/communication/include/trust_cta2045_client.hpp b/dcm/src/communication/include/trust_cta2045_client.hpp deleted file mode 100644 index 4367350f..00000000 --- a/dcm/src/communication/include/trust_cta2045_client.hpp +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef __TRUST_CTA2045_CLIENT_H__ -#define __TRUST_CTA2045_DER_CLIENT_H__ - -#include -#include -#include -#include - -class TrustUCM : public UCM -{ -public: - TrustUCM(); - virtual ~TrustUCM(); - - virtual bool isMessageTypeSupported(cea2045::MessageTypeCode type_code); - virtual cea2045::MaxPayloadLengthCode getMaxPayload(); - virtual void processMaxPayloadResponse(cea2045::MaxPayloadLengthCode payload); - virtual void processDeviceInfoResponse(cea2045::cea2045DeviceInfoResponse *message); - virtual void processCommodityResponse(cea2045::cea2045CommodityResponse *message); - virtual void processSetEnergyPriceResponse(cea2045::cea2045IntermediateResponse *message); - virtual void processSetTemperatureOffsetResponse(cea2045::cea2045IntermediateResponse *message); - virtual void processGetTemperatureOffsetResponse(cea2045::cea2045GetTemperateOffsetResponse *message); - virtual void processSetSetpointsResponse(cea2045::cea2045IntermediateResponse *message); - virtual void processGetSetpointsResponse(cea2045::cea2045GetSetpointsResponse1 *message); - virtual void processGetSetpointsResponse(cea2045::cea2045GetSetpointsResponse2 *message); - virtual void processStartCyclingResponse(cea2045::cea2045IntermediateResponse *message); - virtual void processTerminateCyclingResponse(cea2045::cea2045IntermediateResponse *message); - virtual void processGetPresentTemperatureResponse(cea2045::cea2045GetPresentTemperatureResponse *message); - virtual void processGetUTCTimeResponse(cea2045::cea2045GetUTCTimeResponse *message); - virtual void processAckReceived(cea2045::MessageCode code); - virtual void processNakReceived(cea2045::LinkLayerNakCode nak, cea2045::MessageCode code); - virtual void processAppAckReceived(cea2045::cea2045Basic *message); - virtual void processAppNakReceived(cea2045::cea2045Basic *message); - virtual void processOperationalStateReceived(cea2045::cea2045Basic *message); - virtual void processAppCustomerOverride(cea2045::cea2045Basic *message); - virtual void processIncompleteMessage(const unsigned char *buffer, unsigned int byte_count); - - cea2045::MaxPayloadLengthCode max_payload_; - cta2045::DeviceInfo device_info_; - cta2045::commodity_map commodities_; - cea2045::cea2045GetTemperateOffsetResponse temperature_offset_; - cea2045::cea2045GetSetpointsResponse1 setpoint_1_; - cea2045::cea2045GetSetpointsResponse2 setpoint_2_; - cea2045::cea2045GetPresentTemperatureResponse present_temperature_; - cea2045::cea2045GetUTCTimeResponse utc_time_; -}; - -class TrustCTADevice : public cta2045::AbstractDevice -{ -public: - TrustCTADevice(const std::string &context); - ~TrustCTADevice() noexcept; - - cta2045::DeviceInfo getDeviceInfo() override; - cta2045::commodity_map getCommodity() override; - cea2045::ResponseCodes loadUp(const uint8_t duration = 0) override; - cea2045::ResponseCodes shed(const uint8_t duration = 0) override; - cea2045::ResponseCodes endShed(const uint8_t duration = 0) override; - cea2045::ResponseCodes criticalPeakEvent(const uint8_t duration = 0) override; - cea2045::ResponseCodes gridEmergency(const uint8_t duration = 0) override; - -private: - cea2045::ResponseCodes response_codes_; - cea2045::CEA2045SerialPort *serial_port_; - TrustUCM *ucm_; - cea2045::ICEA2045DeviceUCM *device_; -}; - -class TrustDERClient : public cta2045::AbstractDevice -{ -public: - TrustDERClient(TrustDERClient &other) = delete; // clonable - void operator=(const TrustDERClient &) = delete; // assignable - static TrustDERClient* getInstance(const std::string& context); - static TrustDERClient* getInstance(); - - cta2045::DeviceInfo getDeviceInfo() override; - cta2045::commodity_map getCommodity() override; - cea2045::ResponseCodes loadUp(const uint8_t duration = 0) override; - cea2045::ResponseCodes shed(const uint8_t duration = 0) override; - cea2045::ResponseCodes endShed(const uint8_t duration = 0) override; - cea2045::ResponseCodes criticalPeakEvent(const uint8_t duration = 0) override; - cea2045::ResponseCodes gridEmergency(const uint8_t duration = 0) override; - -protected: - TrustDERClient(const std::string &context); - ~TrustDERClient(); - -private: - // thread-safe singleton instance - static TrustDERClient *instance_; - static std::mutex mutex_; - TrustCTADevice device_; -}; - -#endif // __TRUST_CTA2045_DER_CLIENT_H__ \ No newline at end of file diff --git a/dcm/src/communication/include/trust_gsp_client.hpp b/dcm/src/communication/include/trust_gsp_client.hpp deleted file mode 100644 index f3d31628..00000000 --- a/dcm/src/communication/include/trust_gsp_client.hpp +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef __TRUST_GSP_CLIENT_H__ -#define __TRUST_GSP_CLIENT_H__ - -#include "gsp_client.hpp" -#include "dtm_client.hpp" -#include -#include - -class TrustGSPClient : public https::AbstractClient -{ -public: - TrustGSPClient(TrustGSPClient &other) = delete; // clonable - - void operator=(const TrustGSPClient &) = delete; // assignable - - static TrustGSPClient* getInstance(const https::Context& gsp, const https::Context& dtm); - static TrustGSPClient* getInstance(); - - sep::LFDIType getLFDI() override; - - boost::beast::http::response Get( - const std::string &target, const std::string &query = "") override; - - boost::beast::http::response Post( - const std::string &target, const std::string &resource) override; - - boost::beast::http::response Put( - const std::string &target, const std::string &resource) override; - - boost::beast::http::response Delete( - const std::string &target) override; - -protected: - TrustGSPClient(const https::Context& gsp, const https::Context& dtm); - ~TrustGSPClient() noexcept; - -private: - static TrustGSPClient *instance_; - static std::mutex mutex_; -}; - -#endif // __TRUST_GSP_CLIENT_H__ \ No newline at end of file diff --git a/dcm/src/communication/trust_cta2045_client.cpp b/dcm/src/communication/trust_cta2045_client.cpp deleted file mode 100644 index 20ec1841..00000000 --- a/dcm/src/communication/trust_cta2045_client.cpp +++ /dev/null @@ -1,400 +0,0 @@ -#include "include/trust_cta2045_client.hpp" -#include "include/dtm_client.hpp" -#include -#include -#include - -using namespace cea2045; - -UCM::UCM() -{ - max_payload_ = cea2045::MaxPayloadLengthCode::LENGTH2; -} - -UCM::~UCM() -{ - // do nothing -} - -bool UCM::isMessageTypeSupported(MessageTypeCode type_code) -{ - if (type_code == MessageTypeCode::NONE) - { - return false; - } - - return true; -} - -MaxPayloadLengthCode UCM::getMaxPayload() -{ - return max_payload_; -} - -void UCM::processMaxPayloadResponse(MaxPayloadLengthCode payload) -{ - dtm::Message msg; - msg.from = "DER"; - msg.to = "DCM"; - msg.command = "processMaxPayloadResponse"; - msg.args["MaxPayloadLengthCode"] = std::to_string((int)payload); - msg.timestamp = psu::utilities::getTime(); - - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - max_payload_ = payload; -} - -void UCM::processDeviceInfoResponse(cea2045DeviceInfoResponse *message) -{ - //device_info_ = *message; - device_info_.device_type = message->getDeviceType(); - device_info_.capability_map = (uint64_t)message->capability; - device_info_.vendor_id = message->getVendorID(); - device_info_.firmware_day = (uint32_t)message->firmwareDay; - device_info_.firmware_month = (uint32_t)message->firmwareMonth; - device_info_.firmware_year = 2000 + (uint32_t)message->firmwareYear20xx; - device_info_.firmware_minor = (uint32_t)message->firmwareMinor; - device_info_.firmware_major = (uint32_t)message->firmwareMajor; - - dtm::Message msg; - msg.from = "DER"; - msg.to = "DCM"; - msg.command = "processDeviceInfoResponse"; - msg.args["device type"] = std::to_string(device_info_.device_type); - msg.args["capability"] = std::to_string(device_info_.capability_map); - msg.args["vendor id"] = std::to_string(device_info_.vendor_id); - msg.args["firmware day"] = std::to_string(device_info_.firmware_day); - msg.args["firmware month"] = std::to_string(device_info_.firmware_month); - msg.args["firmware year"] = std::to_string(device_info_.firmware_year); - msg.args["firmware minor"] = std::to_string(device_info_.firmware_minor); - msg.args["firmware major"] = std::to_string(device_info_.firmware_major); - msg.timestamp = psu::utilities::getTime(); - - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); -} - -void UCM::processCommodityResponse(cea2045CommodityResponse *message) -{ - dtm::Message msg; - msg.from = "DER"; - msg.to = "DCM"; - msg.command = "processCommodityResponse"; - msg.timestamp = psu::utilities::getTime(); - - size_t count = message->getCommodityDataCount(); - for (size_t i = 0; i < count; i++) - { - cea2045CommodityData data = *message->getCommodityData(i); - std::string code = std::to_string((uint8_t)data.commodityCode); - commodities_[(uint8_t)data.commodityCode] = data; - msg.args[code + " : code"] = code; - msg.args[code + " : cumulative amount"] = std::to_string(data.getCumulativeAmount()); - msg.args[code + " : instantaneous rate"] = std::to_string(data.getInstantaneousRate()); - } - - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); -} - -void UCM::processSetEnergyPriceResponse(cea2045IntermediateResponse *message) -{ - // TODO -} - -void UCM::processSetTemperatureOffsetResponse(cea2045IntermediateResponse *message) -{ - // TODO -} - -void UCM::processGetTemperatureOffsetResponse(cea2045GetTemperateOffsetResponse *message) -{ - // TODO -} - -void UCM::processSetSetpointsResponse(cea2045IntermediateResponse *message) -{ - // TODO -} - -void UCM::processGetSetpointsResponse(cea2045GetSetpointsResponse1 *message) -{ - // TODO -} - -void UCM::processGetSetpointsResponse(cea2045GetSetpointsResponse2 *message) -{ - // TODO -} - -void UCM::processStartCyclingResponse(cea2045IntermediateResponse *message) -{ - // TODO -} - -void UCM::processTerminateCyclingResponse(cea2045IntermediateResponse *message) -{ - // TODO -} - -void UCM::processGetPresentTemperatureResponse(cea2045GetPresentTemperatureResponse *message) -{ - // TODO -} - -void UCM::processGetUTCTimeResponse(cea2045GetUTCTimeResponse *message) -{ - // TODO -} - -void UCM::processAckReceived(MessageCode code) -{ - // TODO -} - -void UCM::processNakReceived(LinkLayerNakCode nak, MessageCode code) -{ - // TODO -} - -void UCM::processAppAckReceived(cea2045Basic *message) -{ - // TODO -} - -void UCM::processAppNakReceived(cea2045Basic *message) -{ - // TODO -} - -void UCM::processOperationalStateReceived(cea2045Basic *message) -{ - // TODO -} - -void UCM::processAppCustomerOverride(cea2045Basic *message) -{ - // TODO -} - -void UCM::processIncompleteMessage(const unsigned char *buffer, unsigned int byte_count) -{ - dtm::Message msg; - msg.from = "DER"; - msg.to = "DCM"; - msg.command = "processIncompleteMessage"; - msg.args["buffer"] = std::to_string(*buffer); - msg.args["byte_count"] = std::to_string(byte_count); - msg.timestamp = psu::utilities::getTime(); - - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - std::cout << "CTA2045 UCM : incomplete message received. Byte count = " << byte_count << "\n"; -} - -TrustCTADevice::TrustCTADevice(const std::string &context) -{ - serial_port_ = new CEA2045SerialPort(context); - if (!serial_port_->open()) - { - std::cout << "CTA2045 UCM: failed to open serial port\n"; - abort(); - } - - ucm_ = new TrustUCM(); - device_ = DeviceFactory::createUCM(serial_port_, ucm_); - - device_->start(); - - dtm::Message msg; - msg.from = "DCM"; - msg.to = "DER"; - msg.command = "querySuportDataLinkMessages"; - msg.timestamp = psu::utilities::getTime(); - - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - response_codes_ = device_->querySuportDataLinkMessages().get(); - if (response_codes_.responesCode != ResponseCode::OK) - { - std::cout - << "CTA2045 TrustCTADevice: does not support data link messages with code = " - << static_cast(response_codes_.responesCode); - abort(); - } - - msg.from = "DCM"; - msg.to = "DER"; - msg.command = "querySuportIntermediateMessages"; - msg.timestamp = psu::utilities::getTime(); - - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - response_codes_ = device_->querySuportIntermediateMessages().get(); - if (response_codes_.responesCode != ResponseCode::OK) - { - std::cout - << "CTA2045 TrustCTADevice: does not support intermediate messages with code = " - << static_cast(response_codes_.responesCode); - abort(); - } -} - -TrustCTADevice::~TrustCTADevice() -{ - device_->shutDown(); - delete device_; - delete ucm_; - delete serial_port_; -} - -cta2045::DeviceInfo TrustCTADevice::getDeviceInfo() -{ - dtm::Message msg; - msg.from = "DCM"; - msg.to = "DER"; - msg.command = "intermediateGetDeviceInformation"; - msg.timestamp = psu::utilities::getTime(); - - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - response_codes_ = device_->intermediateGetDeviceInformation().get(); - if (response_codes_.responesCode != ResponseCode::OK) - { - std::cout - << "CTA2045 TrustCTADevice: does not support device info messages with code = " - << static_cast(response_codes_.responesCode); - abort(); - } - return ucm_->device_info_; -} - -cta2045::commodity_map TrustCTADevice::getCommodity() -{ - dtm::Message msg; - msg.from = "DCM"; - msg.to = "DER"; - msg.command = "intermediateGetCommodity"; - msg.timestamp = psu::utilities::getTime(); - - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - response_codes_ = device_->intermediateGetCommodity().get(); - if (response_codes_.responesCode != ResponseCode::OK) - { - std::cout - << "CTA2045 TrustCTADevice: does not support get commodity with code = " - << static_cast(response_codes_.responesCode); - abort(); - } - return ucm_->commodities_; -} - -cea2045::ResponseCodes TrustCTADevice::loadUp(const uint8_t duration) -{ - dtm::Message msg; - msg.from = "DCM"; - msg.to = "DER"; - msg.command = "basicLoadUp"; - msg.args["duration"] = std::to_string(duration); - msg.timestamp = psu::utilities::getTime(); - - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - response_codes_ = device_->basicLoadUp(duration).get(); - if (response_codes_.responesCode != ResponseCode::OK) - { - std::cout - << "CTA2045 TrustCTADevice: does not support loadUp with code = " - << static_cast(response_codes_.responesCode); - abort(); - } - return response_codes_; -} - -cea2045::ResponseCodes TrustCTADevice::shed(const uint8_t duration) -{ - dtm::Message msg; - msg.from = "DCM"; - msg.to = "DER"; - msg.command = "basicLoadUp"; - msg.args["duration"] = std::to_string(duration); - msg.timestamp = psu::utilities::getTime(); - - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - response_codes_ = device_->basicShed(duration).get(); - if (response_codes_.responesCode != ResponseCode::OK) - { - std::cout - << "CTA2045 TrustCTADevice: does not support shed with code = " - << static_cast(response_codes_.responesCode); - abort(); - } - return response_codes_; -} - -cea2045::ResponseCodes TrustCTADevice::endShed(const uint8_t duration) -{ - dtm::Message msg; - msg.from = "DCM"; - msg.to = "DER"; - msg.command = "basicEndShed"; - msg.args["duration"] = std::to_string(duration); - msg.timestamp = psu::utilities::getTime(); - - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - response_codes_ = device_->basicEndShed(duration).get(); - if (response_codes_.responesCode != ResponseCode::OK) - { - std::cout - << "CTA2045 TrustCTADevice: does not support endShed with code = " - << static_cast(response_codes_.responesCode); - abort(); - } - return response_codes_; -} - -cea2045::ResponseCodes TrustCTADevice::criticalPeakEvent(const uint8_t duration) -{ - dtm::Message msg; - msg.from = "DCM"; - msg.to = "DER"; - msg.command = "basicCriticalPeakEvent"; - msg.args["duration"] = std::to_string(duration); - msg.timestamp = psu::utilities::getTime(); - - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - response_codes_ = device_->basicCriticalPeakEvent(duration).get(); - if (response_codes_.responesCode != ResponseCode::OK) - { - std::cout - << "CTA2045 TrustCTADevice: does not support criticalPeakEvent with code = " - << static_cast(response_codes_.responesCode); - abort(); - } - return response_codes_; -} - -cea2045::ResponseCodes TrustCTADevice::gridEmergency(const uint8_t duration) -{ - dtm::Message msg; - msg.from = "DCM"; - msg.to = "DER"; - msg.command = "basicGridEmergency"; - msg.args["duration"] = std::to_string(duration); - msg.timestamp = psu::utilities::getTime(); - - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - response_codes_ = device_->basicGridEmergency(duration).get(); - if (response_codes_.responesCode != ResponseCode::OK) - { - std::cout - << "CTA2045 TrustCTADevice: does not support gridEmergency with code = " - << static_cast(response_codes_.responesCode); - abort(); - } - return response_codes_; -} \ No newline at end of file diff --git a/dcm/src/communication/trust_gsp_client.cpp b/dcm/src/communication/trust_gsp_client.cpp deleted file mode 100644 index 5863106a..00000000 --- a/dcm/src/communication/trust_gsp_client.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include "include/trust_gsp_client.hpp" -#include -#include - -TrustGSPClient::TrustGSPClient(const https::Context& gsp, const https::Context& dtm) -{ - // init both singleton clients with context. - GSPClient::getInstance(gsp); - DTMClient::getInstance(dtm); -} - -TrustGSPClient::~TrustGSPClient() -{ - delete instance_; -} - -TrustGSPClient* TrustGSPClient::getInstance(const https::Context& gsp, const https::Context& dtm) -{ - std::lock_guard lock(mutex_); - if(instance_ = nullptr) - { - instance_ = new TrustGSPClient(gsp, dtm); - } - return instance_; -} - -TrustGSPClient* TrustGSPClient::getInstance() -{ - std::lock_guard lock(mutex_); - if(instance_ = nullptr) - { - std::cout << "TrustGSPClient : instance not initilized with context" << std::endl; - abort(); - } - return instance_; -} - -sep::LFDIType TrustGSPClient::getLFDI() -{ - return DTMClient::getInstance()->getLFDI(); -} - -boost::beast::http::response TrustGSPClient::Get(const std::string &target, const std::string &query) -{ - dtm::Message msg; - msg.from = "DCM"; - msg.to = "GSP"; - msg.command = "GET"; - msg.args["target"] = target; - msg.args["query"] = query; - msg.timestamp = psu::utilities::getTime(); - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - auto response = GSPClient::getInstance()->Get(target,query); - - msg.from = "GSP"; - msg.to = "DCM"; - msg.command = "GETResponse"; - msg.args["result"] = std::to_string(response.result_int()); - msg.args["body"] = boost::beast::buffers_to_string(response.body().data()); - msg.timestamp = psu::utilities::getTime(); - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - return response; -} - -boost::beast::http::response TrustGSPClient::Post(const std::string &target, const std::string &resource) -{ - dtm::Message msg; - msg.from = "DCM"; - msg.to = "GSP"; - msg.command = "POST"; - msg.args["target"] = target; - msg.args["body"] = resource; - msg.timestamp = psu::utilities::getTime(); - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - auto response = GSPClient::getInstance()->Post(target,resource); - - msg.from = "GSP"; - msg.to = "DCM"; - msg.command = "POSTResponse"; - msg.args["result"] = std::to_string(response.result_int()); - msg.args["body"] = boost::beast::buffers_to_string(response.body().data()); - msg.timestamp = psu::utilities::getTime(); - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - return response; -} - -boost::beast::http::response TrustGSPClient::Put(const std::string &target, const std::string &resource) -{ - dtm::Message msg; - msg.from = "DCM"; - msg.to = "GSP"; - msg.command = "PUT"; - msg.args["target"] = target; - msg.args["body"] = resource; - msg.timestamp = psu::utilities::getTime(); - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - auto response = GSPClient::getInstance()->Put(target,resource); - - msg.from = "GSP"; - msg.to = "DCM"; - msg.command = "PUTResponse"; - msg.args["result"] = std::to_string(response.result_int()); - msg.args["body"] = boost::beast::buffers_to_string(response.body().data()); - msg.timestamp = psu::utilities::getTime(); - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - return response; -} - -boost::beast::http::response TrustGSPClient::Delete(const std::string &target) -{ - dtm::Message msg; - msg.from = "DCM"; - msg.to = "GSP"; - msg.command = "DELETE"; - msg.args["target"] = target; - msg.timestamp = psu::utilities::getTime(); - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - auto response = GSPClient::getInstance()->Delete(target); - - msg.from = "GSP"; - msg.to = "DCM"; - msg.command = "DELETEResponse"; - msg.args["result"] = std::to_string(response.result_int()); - msg.args["body"] = boost::beast::buffers_to_string(response.body().data()); - msg.timestamp = psu::utilities::getTime(); - DTMClient::getInstance()->Post("/na", dtm::Stringify(msg)); - - return response; -} \ No newline at end of file diff --git a/dcm/src/ecs/CMakeLists.txt b/dcm/src/ecs/CMakeLists.txt index 695fdb97..fcc0a569 100644 --- a/dcm/src/ecs/CMakeLists.txt +++ b/dcm/src/ecs/CMakeLists.txt @@ -1,30 +1 @@ -set(COMPONENT_NAME DCM_ECS) - -add_library(${COMPONENT_NAME} STATIC - cta2045_module.cpp - sep_common_module.cpp - sep_smart_energy_module.cpp - sep_support_module.cpp -) - -# Create ALIAS targets. -add_library( ${PROJECT_NAME}::${COMPONENT_NAME} ALIAS ${COMPONENT_NAME} ) - -target_link_libraries(${COMPONENT_NAME} PUBLIC - flecs - SEP_Models - XML_Validator - Boost::boost - DCM_Comms - pthread -) - -target_include_directories(${COMPONENT_NAME} PUBLIC - $ - $ - ${flecs_INCLUDE_DIRS} - ${SEP_Models_INCLUDE_DIRS} - ${XML_Validator_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${DCM_Comms_INCLUDE_DIRS} -) \ No newline at end of file +add_subdirectory(sep) \ No newline at end of file diff --git a/dcm/src/ecs/cta2045_module.cpp b/dcm/src/ecs/cta2045/cta2045_module.cpp similarity index 100% rename from dcm/src/ecs/cta2045_module.cpp rename to dcm/src/ecs/cta2045/cta2045_module.cpp diff --git a/dcm/src/ecs/include/cta2045_module.hpp b/dcm/src/ecs/cta2045/cta2045_module.hpp similarity index 100% rename from dcm/src/ecs/include/cta2045_module.hpp rename to dcm/src/ecs/cta2045/cta2045_module.hpp diff --git a/dcm/src/ecs/der.cpp b/dcm/src/ecs/der.cpp deleted file mode 100644 index 020fdc6b..00000000 --- a/dcm/src/ecs/der.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "include/der.hpp" -#include -#include - -namespace DER -{ - Module::Module(flecs::world& ecs) - { - ecs.module(); - - ecs.component(); - ecs.component(); - ecs.component(); - ecs.component(); - ecs.component(); - ecs.component(); - - ecs.observer("OnSetRealPower") - .event(flecs::OnSet) - .each([](RealPower& pwr, MaxRealPower& limit){ - if (pwr.value > limit.value){ - pwr.value = limit.value; - std::cout << "Too big: " << pwr.value << std::endl; - } - - if (pwr.value + limit.value < 0){ - pwr.value = 0 - static_cast(limit.value); - std::cout << "Too small: " << pwr.value << std::endl; - } - }); - - ecs.observer("OnSetReactivePower") - .event(flecs::OnSet) - .each([](ReactivePower& pwr, MaxReactivePower& limit){ - if (pwr.value > limit.value){ - pwr.value = limit.value; - std::cout << "Too big: " << pwr.value << std::endl; - } - - if (pwr.value + limit.value < 0){ - pwr.value = 0 - static_cast(limit.value); - std::cout << "Too small: " << pwr.value << std::endl; - } - }); - - ecs.observer("OnSetEnergy") - .event(flecs::OnSet) - .each([](Energy& energy, MaxEnergy& limit){ - if (energy.value > limit.value){ - energy.value = limit.value; - std::cout << "Too big: " << energy.value << std::endl; - } - - if (energy.value + limit.value < 0){ - energy.value = 0 - static_cast(limit.value); - std::cout << "Too small: " << energy.value << std::endl; - } - }); - - } - - -} // namespace DER diff --git a/dcm/src/ecs/include/der.hpp b/dcm/src/ecs/include/der.hpp deleted file mode 100644 index 39e3d1aa..00000000 --- a/dcm/src/ecs/include/der.hpp +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef __DER_H__ -#define __DER_H__ - -#include -#include - -namespace DER -{ - struct RealPower - { - float value; - }; - - struct ReactivePower - { - float value; - }; - - // assume +/- boundary for max power - struct MaxRealPower - { - uint32_t value; - }; - - // assume +/- boundary for max power - struct MaxReactivePower - { - uint32_t value; - }; - - struct Energy - { - float value; - }; - - struct MaxEnergy - { - uint32_t value; - }; - - struct Module - { - - Module(flecs::world& ecs); - }; - -} // namespace DER - -#endif // __DER_H__ \ No newline at end of file diff --git a/dcm/src/ecs/include/sep_common_module.hpp b/dcm/src/ecs/include/sep_common_module.hpp deleted file mode 100644 index 5563ec17..00000000 --- a/dcm/src/ecs/include/sep_common_module.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __DCM_SEP_COMMON_MODULE_H__ -#define __DCM_SEP_COMMON_MODULE_H__ - -#include - - -namespace sep -{ - struct CommonModule - { - CommonModule(flecs::world& ecs); - }; -} // namespace sep - - - -#endif // __DCM_SEP_COMMON_MODULE_H__ \ No newline at end of file diff --git a/dcm/src/ecs/include/sep_smart_energy_module.hpp b/dcm/src/ecs/include/sep_smart_energy_module.hpp deleted file mode 100644 index 5692d140..00000000 --- a/dcm/src/ecs/include/sep_smart_energy_module.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __DCM_SEP_SMART_ENERGY_MODULE_H__ -#define __DCM_SEP_SMART_ENERGY_MODULE_H__ - -#include - -namespace sep -{ - struct SmartEnergyModule - { - SmartEnergyModule(flecs::world &ecs); - }; -} // namespace sep - -#endif // __DCM_SEP_SMART_ENERGY_MODULE_H__ \ No newline at end of file diff --git a/dcm/src/ecs/include/sep_support_module.hpp b/dcm/src/ecs/include/sep_support_module.hpp deleted file mode 100644 index e6231449..00000000 --- a/dcm/src/ecs/include/sep_support_module.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef __DCM_SEP_SUPPORT_MODULE_H__ -#define __DCM_SEP_SUPPORT_MODULE_H__ - -#include - -namespace sep -{ - struct SupportModule - { - public: - SupportModule(flecs::world &ecs); - }; -} // namespace sep - -#endif // __DCM_SEP_SUPPORT_MODULE_H__ \ No newline at end of file diff --git a/dcm/src/ecs/include/simulation_module.hpp b/dcm/src/ecs/include/simulation_module.hpp deleted file mode 100644 index d8942278..00000000 --- a/dcm/src/ecs/include/simulation_module.hpp +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef __SIMULATION_MODULE_H__ -#define __SIMULATION_MODULE_H__ - - -#include - -namespace Simulation -{ - struct Power - { - float magnitude; - float angle; - }; - - struct MaxPower - { - int32_t magnitude; - - }; - - struct Energy - { - float value; - }; - - struct MaxEnergy - { - uint32_t value; - }; - - - struct Module - { - - Module(flecs::world& ecs); - }; - -} // namespace Simulation - - - - - -#endif // __SIMULATION_MODULE_H__ \ No newline at end of file diff --git a/dcm/src/ecs/include/waterheater.hpp b/dcm/src/ecs/include/waterheater.hpp deleted file mode 100644 index aa765482..00000000 --- a/dcm/src/ecs/include/waterheater.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __WATERHEATER_H__ -#define __WATERHEATER_H__ - -#include - -namespace WaterHeater -{ - enum State - { - Idle, - Shed, - LoadUp - }; - - struct Module - { - Module(flecs::world& ecs); - }; -} // namespace Simulator - -#endif // __WATERHEATER_H__ \ No newline at end of file diff --git a/dcm/src/communication/CMakeLists.txt b/dcm/src/ecs/sep/CMakeLists.txt similarity index 53% rename from dcm/src/communication/CMakeLists.txt rename to dcm/src/ecs/sep/CMakeLists.txt index e4ae9e20..fc12f547 100644 --- a/dcm/src/communication/CMakeLists.txt +++ b/dcm/src/ecs/sep/CMakeLists.txt @@ -1,27 +1,22 @@ -set(COMPONENT_NAME DCM_Comms) +set(COMPONENT_NAME ecs_sep) + add_library(${COMPONENT_NAME} STATIC - gsp_client.cpp - dtm_client.cpp - trust_cta2045_client.cpp - trust_gsp_client.cpp + dcap.cpp + fsa.cpp ) # Create ALIAS targets. add_library( ${PROJECT_NAME}::${COMPONENT_NAME} ALIAS ${COMPONENT_NAME} ) target_link_libraries(${COMPONENT_NAME} PUBLIC - trust_xml - cta2045_ucm - utilities - https_client + flecs + trust_https pthread ) target_include_directories(${COMPONENT_NAME} PUBLIC $ $ - ${trust_xml_INCLUDE_DIRS} - ${cta2045_ucm_INCLUDES_DIRS} - ${utilities_INCLUDE_DIRS} - ${https_client_INCLUDE_DIRS} + ${flecs_INCLUDE_DIRS} + ${trust_https_INCLUDE_DIRS} ) \ No newline at end of file diff --git a/dcm/src/ecs/sep/dcap.cpp b/dcm/src/ecs/sep/dcap.cpp new file mode 100644 index 00000000..bfedda29 --- /dev/null +++ b/dcm/src/ecs/sep/dcap.cpp @@ -0,0 +1,55 @@ +#include "include/sep/dcap.hpp" +#include "include/sep/fsa.hpp" +#include +#include + +namespace sep { +namespace dcap { + +Module::Module(flecs::world& world){ + world.module(); + + world.component(); + world.component(); + world.component(); + world.component(); + world.component(); + world.component(); + + // world.prefab().is_a(); + // world.prefab().slot_of(); + // world.prefab().slot_of(); + // world.prefab().slot_of(); + // world.prefab().slot_of(); + // world.prefab().slot_of(); + + world.system("update edev") + .each([](flecs::entity e, PollRate& poll, EndDeviceListLink& edev){ + poll.seconds--; + if (poll.seconds == 0){ + auto resp = trust::HttpsClient::getInstance().Get(edev.href); + std::cout << resp << std::endl; + poll.seconds = 5; + } + }); + + // world.system("registration") + // .kind(flecs::OnStart) + // .each([](flecs::entity e, DeviceCapability& dcap) { + // auto link = e.target(Link) + // auto resp = trust::HttpsClient::getInstance().Get(dcap.href); + // }); + + world.system("update_dcap") + .each([](flecs::entity e, PollRate& poll){ + poll.seconds--; + if (poll.seconds == 0){ + auto resp = trust::HttpsClient::getInstance().Get("/dcap"); + std::cout << resp << std::endl; + poll.seconds = 5; + } + }); +} + +} // namespace dcap +} // namespace sep diff --git a/dcm/src/ecs/sep/fsa.cpp b/dcm/src/ecs/sep/fsa.cpp new file mode 100644 index 00000000..4d076aea --- /dev/null +++ b/dcm/src/ecs/sep/fsa.cpp @@ -0,0 +1,33 @@ +#include "include/sep/fsa.hpp" +#include "include/sep/simple_types.hpp" + +namespace sep { +namespace fsab { + +Module::Module(flecs::world& world){ + world.module(); + + world.component(); + world.component(); + world.component(); + world.component(); + world.component(); + world.component(); + world.component(); + world.component(); + world.component(); + + // world.prefab(); + // world.prefab().slot_of(); + // world.prefab().slot_of(); + // world.prefab().slot_of(); + // world.prefab().slot_of(); + // world.prefab().slot_of(); + // world.prefab().slot_of(); + // world.prefab().slot_of(); + // world.prefab().slot_of(); + // world.prefab().slot_of(); +}; + +} // namespace fsab +} // namespace sep \ No newline at end of file diff --git a/dcm/src/ecs/sep/include/sep/dcap.hpp b/dcm/src/ecs/sep/include/sep/dcap.hpp new file mode 100644 index 00000000..5a7c3c43 --- /dev/null +++ b/dcm/src/ecs/sep/include/sep/dcap.hpp @@ -0,0 +1,38 @@ +#ifndef __SERVER_H__ +#define __SERVER_H__ + +#include +#include +#include "fsa.hpp" + +namespace sep { +namespace dcap { + +std::string serialize (flecs::entity& e); + +struct DeviceCapability {}; + +struct EndDeviceListLink : ListLink {}; + +struct MirrorUsagePointListLink : ListLink {}; + +struct SelfDeviceLink : Link {}; + +struct PollRate{ + UInt32 seconds; +}; + +struct Test : Link { + EndDeviceListLink edev; + MirrorUsagePointListLink mmup; + SelfDeviceLink sdev; + PollRate poll; +}; + +struct Module { + Module(flecs::world& world); +}; + +} // namespace dcap +} // namespace sep +#endif // __SERVER_H__ \ No newline at end of file diff --git a/dcm/src/ecs/sep/include/sep/fsa.hpp b/dcm/src/ecs/sep/include/sep/fsa.hpp new file mode 100644 index 00000000..bdb22993 --- /dev/null +++ b/dcm/src/ecs/sep/include/sep/fsa.hpp @@ -0,0 +1,38 @@ +#ifndef __FSA_H__ +#define __FSA_H__ + +#include +#include +#include "simple_types.hpp" + +namespace sep { +namespace fsab { + +struct FunctionSetAssignmentsBase : sep::Resource {}; + +struct CustomerAccountListLink : ListLink {}; + +struct DemandResponseProgramListLink : ListLink {}; + +struct DERProgramListLink : ListLink {}; + +struct FileListLink : ListLink {}; + +struct MessagingProgramListLink : ListLink {}; + +struct PrepaymentListLink : ListLink {}; + +struct ResponseSetListLink : ListLink {}; + +struct TariffProfileListLink : ListLink {}; + +struct UsagePointListLink : ListLink {}; + +struct Module { + Module(flecs::world& world); +}; + +} // namespace fsab +} // namespace sep + +#endif // __FSA_H__ \ No newline at end of file diff --git a/dcm/src/ecs/sep/include/sep/simple_types.hpp b/dcm/src/ecs/sep/include/sep/simple_types.hpp new file mode 100644 index 00000000..63bf219c --- /dev/null +++ b/dcm/src/ecs/sep/include/sep/simple_types.hpp @@ -0,0 +1,60 @@ +#ifndef __SIMPLE_TYPES_H__ +#define __SIMPLE_TYPES_H__ +#include +#include +#include + +namespace sep { + +using HexBinary8 = uint8_t; +using HexBinary16 = uint16_t; +using HexBinary32 = uint32_t; +using HexBinary48 = uint64_t; +using HexBinary64 = uint64_t; +using HexBinary128 = boost::multiprecision::uint128_t; +using HexBinary160 = boost::multiprecision::uint256_t; +using String6 = std::string; +using String16 = std::string; +using String20 = std::string; +using String32 = std::string; +using String42 = std::string; +using String192 = std::string; +using UInt8 = uint8_t; +using UInt16 = uint16_t; +using UInt32 = uint32_t; +using UInt40 = uint64_t; +using UInt48 = uint64_t; +using UInt64 = uint64_t; +using Int8 = int8_t; +using Int16 = int16_t; +using Int32 = int32_t; +using Int48 = int64_t; +using Int64 = int64_t; +using VersionType = UInt16; +using TimeType = Int64; +using mRIDType = HexBinary128; + +struct Resource { + std::string href; +}; + +struct Link { + std::string href; +}; + +struct List : Resource { + UInt32 all; +}; + +struct ListLink : Link { + UInt32 all; +}; + +struct IdentifiedObject : Resource { + mRIDType mrid; + String32 description; + VersionType version; +}; + +} +#endif // __SIMPLE_TYPES_H__ \ No newline at end of file diff --git a/dcm/src/ecs/sep_common_module.cpp b/dcm/src/ecs/sep_common_module.cpp deleted file mode 100644 index 2df3545b..00000000 --- a/dcm/src/ecs/sep_common_module.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "include/sep_common_module.hpp" -#include - -namespace sep -{ - CommonModule::CommonModule(flecs::world &ecs) - { - /* Register module with world */ - ecs.module(); - - /* Register components */ - ecs.component