|
uniset-algorithms
0.2
|
00001 00067 // ------------------------------------------------------------------------------------------ 00068 #ifndef SEES_H_ 00069 #define SEES_H_ 00070 // ------------------------------------------------------------------------------------------ 00071 #include <TriggerOutput.h> 00072 #include <TriggerOR.h> 00073 #include <TriggerAND.h> 00074 #include <ObjectsManager.h> 00075 #include <DebugStream.h> 00076 #include "ObjectMode.h" 00077 #include "SEESMessages.h" 00078 #include "SEESTypes.h" 00079 #include "SEES_SK.h" 00080 // ------------------------------------------------------------------------------------------ 00081 class SEESMode; 00082 class SEESControl; 00083 class QG; 00084 class Diesel; 00085 class Generator; 00086 class SEESGroup; 00087 // ------------------------------------------------------------------------------------------ 00091 class SEES: 00092 public SEES_SK 00093 { 00094 public: 00095 SEES( int gnum, const std::string name, SEESControl* master, xmlNode* confnode ); 00096 ~SEES(); 00097 00098 virtual char* getName(); 00099 inline std::string getSESName(){ return myname; } 00100 00101 inline int getNumber(){ return num; } 00102 00103 inline int getGroupNumber(){ return gnum; } 00104 inline void setGroupNumber( int num ){ gnum = num; } 00105 00106 int getReservPower(); 00107 inline int getNominalPower(){ return npower; } 00108 long getP(); 00109 long getU(); 00110 long getF(); 00111 00112 SEESTypes::ControlMode getControlMode(); 00113 inline ObjectMode getOMode(){ return (ObjectMode)in_state_as; } 00114 00115 void requiredReserv( bool set ); 00116 bool waitRunning(); 00117 bool waitStopping(); 00118 bool isOnMode(); 00119 bool isAutoMode(); 00120 bool isReservMode(); 00121 bool isProtection(); 00122 bool isAutoControl(); 00124 long getPriority(); 00125 void setLeader( bool set ); 00126 00127 // bool isOnReserv(); 00128 bool canReservRunning(); 00129 bool canReservStopping(); 00130 bool isReservOnNeeded(); 00131 bool isReservOffNeeded(); 00132 00133 void onReservCommand(); 00134 void offReservCommand(); 00135 void resetReservCommand(); 00136 void updateReservCommand(); 00137 void setAloneWorking( bool state ); 00138 00139 // SEESMessage::SEESMode getMode(); 00140 00142 enum Timers 00143 { 00144 OnTimer, 00145 RunTimer, 00146 OffTimer, 00147 DGProtectionStopTimer, 00148 DGProtectionCheckTimer, 00149 QGTimer, 00150 AcceptWaitingTimer, 00151 AcceptControlTimer, 00152 Load20Timer, 00153 NoPowerTimer, 00154 BlockedRunTimer, 00155 UpdateStateTimer 00156 }; 00157 00158 const int OnTime; 00159 const int QGOnTime; 00160 const int QGOffTime; 00161 const int RunTime; 00162 const int OffTime; 00163 const int AcceptWaitingTime; 00164 const int AcceptControlTime; 00165 const int Load20Time; 00166 const int CmdPause; 00167 const int ReservCount; 00168 const int askTimeout; 00169 const int askPause; 00170 const int filterPause; 00171 const int protectionPause; 00172 const int initPause; 00173 const int NoPowerTime; 00174 int BlockedRunTime; 00175 const int DGProtectionStopTime; 00176 const int DGProtectionCheckTime; 00177 const int modeTime; 00178 const int updateStateTime; 00179 int resetPause; 00180 int initAttempts; 00182 SEESControl* master; 00183 QG* qg; 00184 Diesel* dis; 00185 Generator* gen; 00186 00187 bool setLamp(const UniSetTypes::ObjectId id, UniSetTypes::LampCommand cmd); 00188 00189 TriggerOutput<SEES, SEES::Timers, int>* tm; 00190 00192 enum InputId 00193 { 00194 // для команды включения резерва 00195 Load105, 00196 Load95, 00197 Protection, 00198 Fault, 00199 NoPower, 00200 RequiredReserve, 00202 // для команды отключения резерва 00203 ReservOn_Condition, 00204 Load20 00205 }; 00206 00207 TriggerOutput<SEES, UniSetTypes::ObjectId, bool>* out; 00208 // TriggerAND<SEES,UniSetTypes::ObjectId>* reservMode; 00209 00210 enum SigState 00211 { 00212 Sig_None, 00213 Sig_Filtrating, 00214 Sig_OK 00215 }; 00216 00217 SigState load20_sig; 00220 TriggerOutput<SEES, UniSetTypes::ObjectId, bool>* msg; 00221 00222 const UniSetTypes::ObjectId myPostID; 00223 00224 static DebugStream dlog; 00225 static void init_dlog( DebugStream& dlog ); 00226 00227 protected: 00228 SEES(); 00229 00230 TriggerOR<SEES,SEES::InputId>* needReservOn; 00231 TriggerAND<SEES,SEES::InputId>* needReservOff; 00232 00233 virtual void step(); 00234 // virtual void processingMessage( UniSetTypes::VoidMessage *msg ); 00235 virtual void sigterm( int signo ); 00236 00237 virtual void processingMessage( UniSetTypes::VoidMessage* msg ); 00238 virtual void sysCommand( UniSetTypes::SystemMessage* sm ); 00239 virtual void sensorInfo( UniSetTypes::SensorMessage* sm ); 00240 virtual void timerInfo( UniSetTypes::TimerMessage* tm ); 00241 void seesInfo( SEESMessage *sm ); 00242 00243 void changeMode( SEESMode* m ); 00244 void setTimer(SEES::Timers tid, int val); 00245 void setOut(UniSetTypes::ObjectId sid, bool state); 00246 void setProtection( bool state ); 00247 00248 void onReservCondition( bool set ); 00249 void offReservCondition( bool set ); 00250 void updateReservNeeded(); 00251 void resetModeTimer(); 00252 void checkControlMode(); 00253 00254 void setMyControlMode( SEESTypes::ControlMode m ); 00255 00256 long getAnalogInput( UniSetTypes::ObjectId id ); 00257 00258 inline bool isHaveQGLock(){ return haveQGLock; } 00259 inline void setQGLock( bool set ){ haveQGLock = set; } 00260 00261 private: 00262 friend class SEESMode; 00263 friend class SEESWaitingMode; 00264 friend class SEESAutoWaitingMode; 00265 friend class SEESProtectionMode; 00266 friend class SEESGroup; 00267 00268 friend std::ostream& operator<<(std::ostream& os, SEES& am ); 00269 friend std::ostream& operator<<(std::ostream& os, SEES* am ); 00270 00271 void init(); 00272 00273 SEESMode* mode; 00274 SEESTypes::ControlMode myMode; 00275 int gnum; 00276 int num; 00277 int maxPower; 00278 int curReservPower; 00279 PassiveTimer ptMode; 00280 00281 PassiveTimer ptPing; 00282 PassiveTimer ptAnalog; 00283 UniSetTypes::ObjectId power_as; 00284 UniSetTypes::ObjectId voltage_as; 00285 UniSetTypes::ObjectId frequency_as; 00286 long in_power_as; 00287 long in_voltage_as; 00288 long in_frequency_as; 00289 int npower; 00290 00291 bool checkMode; 00292 Trigger trModeUnbalance; 00293 Trigger trModeUnbalanceCheck; 00294 PassiveTimer ptModeUnbalance; 00295 00296 UniSetTypes::uniset_mutex myModeMutex; 00297 UniSetTypes::uniset_mutex modeMutex; 00298 UniSetTypes::uniset_mutex reservMutex; 00299 00300 // Для переходных режимов 00301 SEESMessage::SEESMode toMode; 00302 SEESMessage::SEESMode prevMode; 00303 SEESMode* backMode; 00304 int attemptCounter; 00305 int attempt; 00307 bool protection; 00308 UniSetTypes::uniset_mutex protectionMutex; 00309 bool in_RequiredReserve; 00311 // ВНИМАНИЕ! Сделан только (!) для использованияв SEESGroup 00312 bool haveQGLock; 00313 }; 00314 // ------------------------------------------------------------------------------------------ 00315 #endif // SEES_H_ 00316 // ------------------------------------------------------------------------------------------
1.7.6.1