20 using json = nlohmann::ordered_json;
22 double maximum_tripVoltage = 0;
23 double tripVoltage_startTime = 0;
24 double maximum_tripVoltage_duration = 0;
25 double maximum_tripCurrent = 0;
26 double tripCurrent_startTime = 0;
27 double maximum_tripCurrent_duration = 0;
28 bool disconnect_on_trip =
true;
29 bool connected =
true;
36 unsigned int inputSignal_idx = 0;
40 bool voltageTripped =
false;
41 bool currentTripped =
false;
43 bool unkownCurrent =
false;
44 signal* impedanceTable = NULL;
47 _power* result_power = NULL;
56 file.open(
"appliances/"+_name+
".json");
59 in = json::parse(file);
60 maximum_tripVoltage = in[_name][
"_maximum_tripVoltage"];
61 maximum_tripVoltage_duration = in[_name][
"_maximum_tripVoltage_duration"];
62 maximum_tripCurrent = in[_name][
"_maximum_tripCurrent"];
63 maximum_tripCurrent_duration = in[_name][
"_maximum_tripCurrent_duration"];
67 real = in[_name][
"_real"];
68 complex = in[_name][
"_complex"];
69 disconnect_on_trip = in[_name][
"disconnect_on_trip"];
78 volt_input = &_volt_input;
79 result_current = &_result_current;
84 unkownCurrent =
false;
85 result_power =
new _power(*volt_input,*result_current);
90 if( (result_current != NULL) && (unkownCurrent ==
true) )free(result_current);
91 if(result_power != NULL)free(result_power);
97 if( ( (inputSignal_idx < volt_input->get_analytics()->samples_num ) || (inputSignal_idx < result_current->get_analytics()->samples_num ) ) && connected){
98 double thisInstantVoltage = 0;
99 double thisInstantTime = 0;
100 double thisInstantCurrent = 0;
102 if(inputSignal_idx < volt_input->get_analytics()->samples_num){
107 if(inputSignal_idx < result_current->get_analytics()->samples_num){
111 if(abs(thisInstantVoltage) > abs(maximum_tripVoltage) && !voltageTripped){
112 tripVoltage_startTime = thisInstantTime;
113 voltageTripped =
true;
114 if(disconnect_on_trip)connected =
false;
117 if(abs(thisInstantCurrent) > abs(maximum_tripCurrent) && !currentTripped){
118 tripCurrent_startTime = thisInstantTime;
119 currentTripped =
true;
120 if(disconnect_on_trip)connected =
false;
128 void init(
double _maximum_tripVoltage = 0,
129 double _maximum_tripVoltage_duration = 0,
130 double _maximum_tripCurrent = 0,
131 double _maximum_tripCurrent_duration = 0,
137 bool _disconnect_on_trip = 0
141 out[name][
"_maximum_tripVoltage"] = (_maximum_tripVoltage);
142 out[name][
"_maximum_tripVoltage_duration"] = (_maximum_tripVoltage_duration);
143 out[name][
"_maximum_tripCurrent"] = (_maximum_tripCurrent);
144 out[name][
"_maximum_tripCurrent_duration"] = (_maximum_tripCurrent_duration);
145 out[name][
"_R"] = (_R);
146 out[name][
"_L"] = (_L);
147 out[name][
"_C"] = (_C);
148 out[name][
"_real"] = (_real);
149 out[name][
"_complex"] = (_complex);
150 out[name][
"disconnect_on_trip"] = (_disconnect_on_trip);
153 fileCheck.open(
"appliances/"+name+
".json");
154 if(!fileCheck.is_open()){
155 fileout.open(
"appliances/"+name+
".json");
156 fileout << std::setw(4) << out;
167 file.open(
"appliances/"+name+
".json");
169 in = json::parse(file);
170 maximum_tripVoltage = in[name][
"_maximum_tripVoltage"];
171 maximum_tripVoltage_duration = in[name][
"_maximum_tripVoltage_duration"];
172 maximum_tripCurrent = in[name][
"_maximum_tripCurrent"];
173 maximum_tripCurrent_duration = in[name][
"_maximum_tripCurrent_duration"];
177 real = in[name][
"_real"];
178 complex = in[name][
"_complex"];
179 disconnect_on_trip = in[name][
"disconnect_on_trip"];
186 return voltageTripped;
189 return currentTripped;
192 return tripCurrent_startTime;
195 return tripVoltage_startTime;
202 return result_current;
string get_setting(string class_name, string setting)
double voltage_tripTime()
void init(double _maximum_tripVoltage=0, double _maximum_tripVoltage_duration=0, double _maximum_tripCurrent=0, double _maximum_tripCurrent_duration=0, double _R=0, double _L=0, double _C=0, double _real=0, double _complex=0, bool _disconnect_on_trip=0)
bool pdf_export(string name, string file_address=settings.get_setting("signal","import_path"))
double current_tripTime()
appliance(_voltage &_volt_input, _current &_result_current, std::string _name="appliance")
HELD_DATA getData(int row, int col) const
return the data at some address
signal class the parent class for every other signal or any form of time-sorted (time,...
const bool isTimeAnalysed()
check if the signal was analysed in the time domain
const v_container * get_signal_data() const
get any values in the signal data table
bool analyse()
generalized huge analysis in the time domain fetches basic data
electric specific classes current/voltage/power that inherit from signals class while adding thier sp...
this file includes the base class "signal" for signals modeling and analysing thier time-domain / fre...
this file includes the basic signal_operation class responsible for doing any required manipulation o...