Commit 58833535 authored by Ozmen O's avatar Ozmen O
Browse files

ES and PV serial port communications are added to the model

parent 8f953a6f
Loading
Loading
Loading
Loading
+39 −10
Original line number Diff line number Diff line

#ifndef FMUModel_H_
#define FMUModel_H_

@@ -65,12 +66,28 @@ class FMUModel:
			std::ostringstream strs;
			if (request == "HVAC"){
				strs << ((get_home1_y()*9/5)+32); // get home temperature
				str = strs.str();
	                        str = str+"\n";
			}
			if(request == "WH"){
				strs << ((get_wh1_T()*9/5)+32);
				str = strs.str();
	                        str = str+"\n";
			}
			if (request == "ES"){
				strs << get_storage1_SOC();
                                strs << ",";
                                strs << get_storage1_SOCmin();
				strs << ",";
				strs << get_storage1_SOCmax();
                                strs << ",";
				strs << get_storage1_Erated()/3600;//joules to kwatt/hr
                                strs << ",";
				strs << get_storage1_Prated();
                                str = strs.str();
	                        str = str+"\n";
				cout<<"GGAGAG "<<str<<endl;
			}
			char* buffer = new char[str.length()];
			strcpy(buffer, str.c_str());
			computer_io_type* c = new computer_io_type(buffer,str.length());
@@ -113,24 +130,36 @@ class FMUModel:
					token1.erase(0,pos2 + delimiter.length());
					count=count+1;
				}
				if ((token1 != "IndoorTempF") & (token1 != "UpperTankTemp") & (token1 != "ESConfig") & (token1 != "PVConfig")){
					if (from == "HVAC"){
					if ((token1 != "OutdoorTempF") & (token1 != "UpperTankTemp")){
						double temp = (atof(token1.c_str())-32)*5/9;
						set_hvac1_Setpoint_k(temp);
					}
				}
					if (from == "WH"){
					if ((token1 != "OutdoorTempF") & (token1 != "UpperTankTemp")){
						double temp = (atof(token1.c_str())-32)*5/9;
						set_wh1_Setpoint1_k(temp);
					}
					if (from == "ES"){
						double temp = atof(token1.c_str());
						set_storage1_ChargeRequest_k(temp);
					}
					if (from == "PV"){
						double temp = atof(token1.c_str());
						set_storage1_capacityReduce(temp);
					}
				if (token1 == "OutdoorTempF"){
				}
				if (token1 == "IndoorTempF"){
					request = "HVAC";
				}
				if (token1 == "UpperTankTemp"){
					request = "WH";
				}
				if (token1 == "ESConfig"){
					request = "ES";
				}
				//if (token1 == "PVConfig"){
				//	request = "PV";
				//}
				s.erase(0,pos1 + mes_sep.length());
			}
		}
+39 −10
Original line number Diff line number Diff line

#ifndef FMUModel_H_
#define FMUModel_H_

@@ -65,12 +66,28 @@ class FMUModel:
			std::ostringstream strs;
			if (request == "HVAC"){
				strs << ((get_home1_y()*9/5)+32); // get home temperature
				str = strs.str();
	                        str = str+"\n";
			}
			if(request == "WH"){
				strs << ((get_wh1_T()*9/5)+32);
				str = strs.str();
	                        str = str+"\n";
			}
			if (request == "ES"){
				strs << get_storage1_SOC();
                                strs << ",";
                                strs << get_storage1_SOCmin();
				strs << ",";
				strs << get_storage1_SOCmax();
                                strs << ",";
				strs << get_storage1_Erated()/3600;//joules to kwatt/hr
                                strs << ",";
				strs << get_storage1_Prated();
                                str = strs.str();
	                        str = str+"\n";
				cout<<"GGAGAG "<<str<<endl;
			}
			char* buffer = new char[str.length()];
			strcpy(buffer, str.c_str());
			computer_io_type* c = new computer_io_type(buffer,str.length());
@@ -113,24 +130,36 @@ class FMUModel:
					token1.erase(0,pos2 + delimiter.length());
					count=count+1;
				}
				if ((token1 != "IndoorTempF") & (token1 != "UpperTankTemp") & (token1 != "ESConfig") & (token1 != "PVConfig")){
					if (from == "HVAC"){
					if ((token1 != "OutdoorTempF") & (token1 != "UpperTankTemp")){
						double temp = (atof(token1.c_str())-32)*5/9;
						set_hvac1_Setpoint_k(temp);
					}
				}
					if (from == "WH"){
					if ((token1 != "OutdoorTempF") & (token1 != "UpperTankTemp")){
						double temp = (atof(token1.c_str())-32)*5/9;
						set_wh1_Setpoint1_k(temp);
					}
					if (from == "ES"){
						double temp = atof(token1.c_str());
						set_storage1_ChargeRequest_k(temp);
					}
					if (from == "PV"){
						double temp = atof(token1.c_str());
						set_storage1_capacityReduce(temp);
					}
				if (token1 == "OutdoorTempF"){
				}
				if (token1 == "IndoorTempF"){
					request = "HVAC";
				}
				if (token1 == "UpperTankTemp"){
					request = "WH";
				}
				if (token1 == "ESConfig"){
					request = "ES";
				}
				//if (token1 == "PVConfig"){
				//	request = "PV";
				//}
				s.erase(0,pos1 + mes_sep.length());
			}
		}
+638 −562

File changed.

Preview size limit exceeded, changes collapsed.

Loading