GBlackBoxModel.cxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include "GBlackBoxModel.h"
00040
00041 namespace bbtk
00042 {
00043
00044
00045 GBlackBoxModel::GBlackBoxModel()
00046 {
00047 _isExecutable = false;
00048 }
00049
00050
00051
00052 GBlackBoxModel::~GBlackBoxModel()
00053 {
00054 }
00055
00056
00057
00058 std::string GBlackBoxModel::getBBTKPackage()
00059 {
00060 return _bbtkPackage;
00061 }
00062
00063
00064
00065 void GBlackBoxModel::setBBTKPackage(std::string obpackage)
00066 {
00067 _bbtkPackage = obpackage;
00068 }
00069
00070
00071
00072 bool GBlackBoxModel::isExecutable()
00073 {
00074 return _isExecutable;
00075 }
00076
00077
00078
00079 void GBlackBoxModel::setExecutable(bool executable)
00080 {
00081 _isExecutable = executable;
00082 }
00083
00084
00085
00086 std::string GBlackBoxModel::getStatusText()
00087 {
00088 std::string temp = "";
00089 temp+=_bbtkPackage;
00090 temp+=":";
00091 temp+=_bbtkType;
00092 temp+=":";
00093 temp+=_bbtkName;
00094
00095 return temp;
00096 }
00097
00098
00099
00100 void GBlackBoxModel::setValueToInputPort(int pos,std::string value)
00101 {
00102 _inputs[pos]->setValue(value);
00103 }
00104
00105
00106
00107 void GBlackBoxModel::save(std::string &content)
00108 {
00109 content+="BOX\n";
00110
00111 content+=_bbtkPackage;
00112 content+=":";
00113 content+=_bbtkType;
00114 content+=":";
00115 content+=_bbtkName;
00116 content+="\n";
00117 content+="ISEXEC:";
00118 if(_isExecutable)
00119 {
00120 content+="TRUE";
00121 }
00122 else
00123 {
00124 content+="FALSE";
00125 }
00126 content+="\n";
00127
00128
00129
00130 char buffer [50];
00131 sprintf (buffer, "%f", _xInic);
00132 content+=buffer;
00133 content+=":";
00134 sprintf (buffer, "%f", _yInic);
00135 content+=buffer;
00136 content+=":";
00137 sprintf (buffer, "%f", _zInic);
00138 content+=buffer;
00139 content+="\n";
00140
00141 sprintf (buffer, "%f", _xFin);
00142 content+=buffer;
00143 content+=":";
00144 sprintf (buffer, "%f", _yFin);
00145 content+=buffer;
00146 content+=":";
00147 sprintf (buffer, "%f", _zFin);
00148 content+=buffer;
00149 content+="\n";
00150
00151
00152 for(int i = 0; i<(int)_inputs.size();i++)
00153 {
00154 if(_inputs[i]->isValueSet())
00155 {
00156 _inputs[i]->save(content);
00157 }
00158 }
00159 content+="FIN_BOX\n";
00160
00161 }
00162
00163
00164
00165 void GBlackBoxModel::setValueToInput(std::string name,std::string value)
00166 {
00167 for(int i = 0; i<(int)_inputs.size();i++)
00168 {
00169 if(_inputs[i]->getBBTKName()==name)
00170 {
00171 _inputs[i]->setValue(value);
00172 }
00173 }
00174 }
00175
00176
00177
00178 std::string GBlackBoxModel::getValueInputPort(int pos)
00179 {
00180 return _inputs[pos]->getValue();
00181 }
00182
00183
00184
00185 std::string GBlackBoxModel::getValueInput(std::string name)
00186 {
00187 for(int i = 0; i<(int)_inputs.size();i++)
00188 {
00189 if(_inputs[i]->getBBTKName()==name)
00190 {
00191 return _inputs[i]->getValue();
00192 }
00193 }
00194 return NULL;
00195 }
00196
00197
00198
00199 std::vector<int> GBlackBoxModel::getConnectedInputs()
00200 {
00201 std::vector<int> connected;
00202 for(int i = 0; i<(int)_inputs.size();i++)
00203 {
00204 if(_inputs[i]->isConnected())
00205 {
00206 connected.push_back(i);
00207 }
00208 }
00209 return connected;
00210 }
00211
00212
00213
00214 std::vector<int> GBlackBoxModel::getConnectedOutputs()
00215 {
00216 std::vector<int> connected;
00217 for(int i = 0; i<(int)_outputs.size();i++)
00218 {
00219 if(_outputs[i]->isConnected())
00220 {
00221 connected.push_back(i);
00222 }
00223 }
00224 return connected;
00225 }
00226
00227
00228 }
00229
00230
00231