EUROPEAN SYNCHROTRON RADIATION FACILITY
INSTALLATION EUROPEENNE DE RAYONNEMENT SYNCHROTRON
ESRF Logo
Main Page   Namespace List   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

StarterUtil.h

Go to the documentation of this file.
00001 //=============================================================================
00002 //
00003 // file :        StarterUtil.h
00004 //
00005 // description : Include for the StarterUtil class.
00006 //
00007 // project :    Starter for Tango Administration
00008 //
00009 // $Author: pascal_verdier $
00010 //
00011 // $Revision: 1.2 $
00012 //
00013 // copyleft :    European Synchrotron Radiation Facility
00014 //               BP 220, Grenoble 38043
00015 //               FRANCE
00016 //
00017 //=============================================================================
00018 #ifndef _STARTER_UTIL_H
00019 #define _STARTER_UTIL_H
00020 
00021 #include <tango.h>
00022 
00033 namespace Starter
00034 {
00035 
00036  //     Add your own constants definitions here.
00037  //-----------------------------------------------
00038 #ifndef WIN32
00039 typedef unsigned char boolean;
00040 #endif
00041 
00042 typedef struct {
00043         string  name;
00044         string  admin_name;
00045         bool    controled;
00046         bool    running;
00047         short   startup_level;
00048         Tango::DeviceProxy      *dev;
00049 }
00050 ServerControled;
00051 
00052 //      Definitions for separators
00053 //----------------------------------
00054 #ifdef WIN32
00055 #       define  slash   '\\'
00056 #       define  TmpRoot "\\temp"
00057 #else
00058 #       define  slash   '/'
00059 #       define  TmpRoot "/tmp"
00060 #endif
00061 #define LogPath(s)              \
00062                 s = TmpRoot;    \
00063                 s += slash;             \
00064                 s += "ds.log";
00065 
00066 class StarterUtil
00067 {
00068 public :
00077 StarterUtil(Tango::DeviceImpl *dev, string host_name);
00079 
00089 char *get_server_name(char *argin);
00095 char *get_instance_name(char *argin);
00103 char *check_exe_file(char *servname, vector<string> v_path);
00109 string build_log_file_name(char *);
00114 char *get_file_date(char *filename);
00118 char *strtime(time_t t);
00125 ServerControled *get_server_by_name(string, vector<ServerControled>&);
00132 vector<string>  get_host_ds_list(Tango::DeviceProxy *);
00136 bool is_notifyd_alive(Tango::DeviceProxy *);
00137 
00138 #ifdef WIN32
00139 
00148 int StarterUtil::strcasecmp(const char *s1, const char *s2);
00149 #endif
00150 
00151 void start_timer();
00152 int     get_timer_value();
00153 
00155 private:
00156         static int      elapsed;
00157         string          hostname;
00158         string          notifyd_name;
00159 
00160 #ifndef WIN32
00161         static struct timeval   before, after;
00162 #else
00163 #endif /* WIN32 */
00164 };
00165 
00166 
00167 
00168 
00169 
00170 //=========================================================
00174 //=========================================================
00175 class SharedData: public Tango::TangoMonitor
00176 {
00177 private:
00178         time_t  last_cmd_time;
00182         omni_thread                     *polling_id;
00183 
00184 public:
00185         SharedData();
00189 time_t get_timer();
00193 void set_timer();
00194 };
00195 
00196 
00197 
00198 //=========================================================
00204 //=========================================================
00205 class PollingState: public omni_thread
00206 {
00207 private:
00211         SharedData              *shared;
00215         Tango::DevBoolean       polling_on;
00219         Tango::DevLong          cmd_timeout;
00220 public:
00229         PollingState(SharedData *shared, long timeout);
00230 
00236         //virtual void run();
00237 
00238         void *run_undetached(void *);
00239         void start() {start_undetached();}
00240 };
00241 
00242 }       //      namespace
00243 
00244 #endif  // _STARTER_UTIL_H
Tango Device Server User's Guide



(c) ESRF - Software Engineering Group