Loading Noto/Servers/NotoWeatherStation/bin/fakewx.py 0 → 100644 +54 −0 Original line number Diff line number Diff line import SocketServer import datetime class MyTCPHandler(SocketServer.BaseRequestHandler): """ The RequestHandler class for our server. It is instantiated once per connection to the server, and must override the handle() method to implement communication to the client. """ def handle(self): # self.request is the TCP socket connected to the client msg="" done=0 crec=0 while not done: ch = self.request.recv(1) if ch=='': self.data="" break # if ch=='\n': # done=1 msg=msg+ch self.data=msg print 'received:'+ self.data print len(self.data) if self.data=='poppiexit\n': self.request.close() reading=0 done=1 break if self.data=='spettro\n': now=datetime.datetime.utcnow() tt=now.timetuple() # self.request.send('0132 dr21 %s +42:19:44 2000.0 300.00 5 21964.000 0.0 kkc 80.047 60.416 17:23:13 +44:37:55 0 0 31.5 1018.0 90.0 \n') print "received spettro, sent back fake string" self.request.send('0132 dr21 %s +42:19:44 2000.0 300.00 5 21964.000 0.0 kkc 80.047 60.416 17:23:13 +44:37:55 0 0 %f %f %f 22\n' % (datetime.datetime.utcnow().strftime("%H:%M:%S"),tt[3]+.04,tt[4]+.99,tt[5]+.43)) self.data="" msg="" if __name__ == "__main__": HOST, PORT = "0.0.0.0", 5002 # Create the server, binding to localhost on port 9999 server = SocketServer.TCPServer((HOST, PORT), MyTCPHandler) # Activate the server; this will keep running until you # interrupt the program with Ctrl-C server.serve_forever() Noto/Servers/NotoWeatherStation/bin/simplemeteoclient.py 0 → 100644 +30 −0 Original line number Diff line number Diff line #!/usr/bin/env python # from Acspy.Clients.SimpleClient import PySimpleClient from Acspy.Common.Log import getLogger import time simpleClient=PySimpleClient() logger=getLogger() try: meteo=simpleClient.getComponent("WEATHERSTATION/WeatherStation") logger.logInfo('getting component METEO') meteoparam=meteo.getData() # print meteo.getHumidity() print meteoparam time.sleep(1) print "temperature= ", meteo.getTemperature() time.sleep(1) print "humidity= ", meteo.getHumidity() time.sleep(1) print "Pressure= ", meteo.getPressure() except Exception,e: print "The exception was:", e Noto/Servers/NotoWeatherStation/config/CDB/schemas/MedWeatherStation.xsd 0 → 100644 +34 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="ISO-8859-1"?> <!-- --> <xs:schema targetNamespace="urn:schemas-cosylab-com:MedWeatherStation:1.0" xmlns="urn:schemas-cosylab-com:MedWeatherStation:1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cdb="urn:schemas-cosylab-com:CDB:1.0" xmlns:baci="urn:schemas-cosylab-com:BACI:1.0" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:import namespace="urn:schemas-cosylab-com:CDB:1.0" schemaLocation="CDB.xsd"/> <xs:import namespace="urn:schemas-cosylab-com:BACI:1.0" schemaLocation="BACI.xsd"/> <xs:complexType name="MedWeatherStationType"> <xs:sequence> <xs:element name="temperature" type="baci:RWdouble"/> <xs:element name="winddir" type="baci:RWdouble"/> <xs:element name="windspeed" type="baci:RWdouble"/> <xs:element name="humidity" type="baci:RWdouble"/> <xs:element name="pressure" type="baci:RWdouble"/> </xs:sequence> <xs:attribute name="IPAddress" type="xs:string" use="required"/> <xs:attribute name="port" type="xs:unsignedInt" use="required"/> </xs:complexType> <xs:element name="MedWeatherStation" type="MedWeatherStationType"/> </xs:schema> Noto/Servers/NotoWeatherStation/include/CXMLDataParser.h 0 → 100644 +96 −0 Original line number Diff line number Diff line #ifndef _CXMLDPARSER #define _CXMLDPARSER #include <string> #include <expat.h> #include <string.h> #include <iostream> #include <map> #include "MeteoData.h" #define HEATINGTEMP th01 #define HEATINGVOLTAGE th01 #define SUPPLYVOLTAGE th01 /* th01 heating temp vh01 heating voltage vs01 supply voltage vr01 rif. voltage dn01 wind dir min dm01 wind dir ave dx01 wind dir max sn01 wind speed ave sm01 wind speed max sx01 wind speed max ta01 air temp ua01 rel. humidity pa01 air pressure rc01 rain acc. rd01 rain duration ri01 rain intensity rp01 rain peak duration hc01 hail acc. hd01 hail duration hi01 hail intensity hp01 hail peak duration */ using namespace std; class CXMLDataParser { //<String><Name>date</Name><Val>20100305143937</Val></String><DBL><Name>ta01</Name><Val>22.600000</Val><Name>dm01</Name><Val>180.0</Val></DBL> public: CXMLDataParser(); CXMLDataParser(MeteoData *md); virtual ~CXMLDataParser(); int Parse(char* buff); int Parse(std::string buff); protected: #define BUFFSIZE 8192 static int Depth; char Buff[BUFFSIZE]; static void start_hndl(void* data, const XML_Char* el, const XML_Char** attr); static void end_hndl(void *data, const XML_Char* el); static void char_hndl(void *data, const XML_Char *s, int len); // static vodi addSensor(MeteoData *md,string static void checkSensor(MeteoData *md, string xmlvalue, const string label); XML_Parser p; MeteoData *m_meteodata; map<string,double> m_map; string m_tagname; string m_tagdate; double m_tagvalue; string m_acttag; // actual tag; MeteoData *m_sensorData; }; #endif Noto/Servers/NotoWeatherStation/include/DevIOhumidity.h 0 → 100644 +101 −0 Original line number Diff line number Diff line #ifndef DevIOHumidity_H_ #define DevIOHumidity_H_ /* **************************************************************************************************** */ /*INAF - OACA */ /* */ /* */ /* This code is under GNU General Public Licence (GPL). */ /* */ /* Who when What */ /* Sergio Poppi(spoppi@oa-cagliari.inaf.it) 02/01/2009 Creation */ #include <baciDevIO.h> #include <IRA> #include <map> #include "MeteoSocket.h" using namespace IRA; /** * This class is derived from template DevIO and it is used by the temperature property of the MeteoStation component * @author <a href=mailto:spoppi@oa-cagliari.inaf.it>Sergio Poppi</a>, * Istituto di Radioastronomia, Italia<br> */ class DevIOHumidity : public DevIO<CORBA::Double> { public: /** * Constructor * @param Socket pointer to a SecureArea that proctects a the socket. This object must be already initialized and configured. */ DevIOHumidity(CSecureArea<MeteoSocket>* socket):m_socket(socket) { m_initparser=false; AUTO_TRACE("DevIOHumidity::DevIOHumidity()"); } /** * Destructor */ ~DevIOHumidity() { ACS_TRACE("DevIOHumidity::~DevIOHumidity()"); } /** * @return true to initialize the property with default value from CDB. */ bool initializeValue() { AUTO_TRACE("DevIOHumidity::initializeValue()"); return false; } /** * Used to read the property value. * @throw ComponentErrors::PropertyError * @param timestamp epoch when the operation completes */ CORBA::Double read(ACS::Time& timestamp) throw (ACSErr::ACSbaseExImpl) { // get the CommandLine ....... try { CError err; CString rdata=""; CSecAreaResourceWrapper<MeteoSocket> sock=m_socket->Get(); m_val=sock->getHumidity(); return m_val; } catch (ACSErr::ACSbaseExImpl& E) { _ADD_BACKTRACE(ComponentErrors::PropertyErrorExImpl,dummy,E,"DevIOHumidity::read()"); dummy.setPropertyName("systemTemperature"); dummy.setReason("Property could not be read"); //_IRA_LOGGUARD_LOG_EXCEPTION(m_logGuard,dummy,LM_DEBUG); throw dummy; } timestamp=getTimeStamp(); //complition time } /** * It writes values into controller. Unused because the properties are read-only. */ void write(const CORBA::Double& value, ACS::Time& timestamp) throw (ACSErr::ACSbaseExImpl) { timestamp=getTimeStamp(); return; } private: CSecureArea<MeteoSocket>* m_socket; CORBA::Double m_val; bool m_initparser; }; #endif /*DevIOHumidity_H_*/ Loading
Noto/Servers/NotoWeatherStation/bin/fakewx.py 0 → 100644 +54 −0 Original line number Diff line number Diff line import SocketServer import datetime class MyTCPHandler(SocketServer.BaseRequestHandler): """ The RequestHandler class for our server. It is instantiated once per connection to the server, and must override the handle() method to implement communication to the client. """ def handle(self): # self.request is the TCP socket connected to the client msg="" done=0 crec=0 while not done: ch = self.request.recv(1) if ch=='': self.data="" break # if ch=='\n': # done=1 msg=msg+ch self.data=msg print 'received:'+ self.data print len(self.data) if self.data=='poppiexit\n': self.request.close() reading=0 done=1 break if self.data=='spettro\n': now=datetime.datetime.utcnow() tt=now.timetuple() # self.request.send('0132 dr21 %s +42:19:44 2000.0 300.00 5 21964.000 0.0 kkc 80.047 60.416 17:23:13 +44:37:55 0 0 31.5 1018.0 90.0 \n') print "received spettro, sent back fake string" self.request.send('0132 dr21 %s +42:19:44 2000.0 300.00 5 21964.000 0.0 kkc 80.047 60.416 17:23:13 +44:37:55 0 0 %f %f %f 22\n' % (datetime.datetime.utcnow().strftime("%H:%M:%S"),tt[3]+.04,tt[4]+.99,tt[5]+.43)) self.data="" msg="" if __name__ == "__main__": HOST, PORT = "0.0.0.0", 5002 # Create the server, binding to localhost on port 9999 server = SocketServer.TCPServer((HOST, PORT), MyTCPHandler) # Activate the server; this will keep running until you # interrupt the program with Ctrl-C server.serve_forever()
Noto/Servers/NotoWeatherStation/bin/simplemeteoclient.py 0 → 100644 +30 −0 Original line number Diff line number Diff line #!/usr/bin/env python # from Acspy.Clients.SimpleClient import PySimpleClient from Acspy.Common.Log import getLogger import time simpleClient=PySimpleClient() logger=getLogger() try: meteo=simpleClient.getComponent("WEATHERSTATION/WeatherStation") logger.logInfo('getting component METEO') meteoparam=meteo.getData() # print meteo.getHumidity() print meteoparam time.sleep(1) print "temperature= ", meteo.getTemperature() time.sleep(1) print "humidity= ", meteo.getHumidity() time.sleep(1) print "Pressure= ", meteo.getPressure() except Exception,e: print "The exception was:", e
Noto/Servers/NotoWeatherStation/config/CDB/schemas/MedWeatherStation.xsd 0 → 100644 +34 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="ISO-8859-1"?> <!-- --> <xs:schema targetNamespace="urn:schemas-cosylab-com:MedWeatherStation:1.0" xmlns="urn:schemas-cosylab-com:MedWeatherStation:1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cdb="urn:schemas-cosylab-com:CDB:1.0" xmlns:baci="urn:schemas-cosylab-com:BACI:1.0" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:import namespace="urn:schemas-cosylab-com:CDB:1.0" schemaLocation="CDB.xsd"/> <xs:import namespace="urn:schemas-cosylab-com:BACI:1.0" schemaLocation="BACI.xsd"/> <xs:complexType name="MedWeatherStationType"> <xs:sequence> <xs:element name="temperature" type="baci:RWdouble"/> <xs:element name="winddir" type="baci:RWdouble"/> <xs:element name="windspeed" type="baci:RWdouble"/> <xs:element name="humidity" type="baci:RWdouble"/> <xs:element name="pressure" type="baci:RWdouble"/> </xs:sequence> <xs:attribute name="IPAddress" type="xs:string" use="required"/> <xs:attribute name="port" type="xs:unsignedInt" use="required"/> </xs:complexType> <xs:element name="MedWeatherStation" type="MedWeatherStationType"/> </xs:schema>
Noto/Servers/NotoWeatherStation/include/CXMLDataParser.h 0 → 100644 +96 −0 Original line number Diff line number Diff line #ifndef _CXMLDPARSER #define _CXMLDPARSER #include <string> #include <expat.h> #include <string.h> #include <iostream> #include <map> #include "MeteoData.h" #define HEATINGTEMP th01 #define HEATINGVOLTAGE th01 #define SUPPLYVOLTAGE th01 /* th01 heating temp vh01 heating voltage vs01 supply voltage vr01 rif. voltage dn01 wind dir min dm01 wind dir ave dx01 wind dir max sn01 wind speed ave sm01 wind speed max sx01 wind speed max ta01 air temp ua01 rel. humidity pa01 air pressure rc01 rain acc. rd01 rain duration ri01 rain intensity rp01 rain peak duration hc01 hail acc. hd01 hail duration hi01 hail intensity hp01 hail peak duration */ using namespace std; class CXMLDataParser { //<String><Name>date</Name><Val>20100305143937</Val></String><DBL><Name>ta01</Name><Val>22.600000</Val><Name>dm01</Name><Val>180.0</Val></DBL> public: CXMLDataParser(); CXMLDataParser(MeteoData *md); virtual ~CXMLDataParser(); int Parse(char* buff); int Parse(std::string buff); protected: #define BUFFSIZE 8192 static int Depth; char Buff[BUFFSIZE]; static void start_hndl(void* data, const XML_Char* el, const XML_Char** attr); static void end_hndl(void *data, const XML_Char* el); static void char_hndl(void *data, const XML_Char *s, int len); // static vodi addSensor(MeteoData *md,string static void checkSensor(MeteoData *md, string xmlvalue, const string label); XML_Parser p; MeteoData *m_meteodata; map<string,double> m_map; string m_tagname; string m_tagdate; double m_tagvalue; string m_acttag; // actual tag; MeteoData *m_sensorData; }; #endif
Noto/Servers/NotoWeatherStation/include/DevIOhumidity.h 0 → 100644 +101 −0 Original line number Diff line number Diff line #ifndef DevIOHumidity_H_ #define DevIOHumidity_H_ /* **************************************************************************************************** */ /*INAF - OACA */ /* */ /* */ /* This code is under GNU General Public Licence (GPL). */ /* */ /* Who when What */ /* Sergio Poppi(spoppi@oa-cagliari.inaf.it) 02/01/2009 Creation */ #include <baciDevIO.h> #include <IRA> #include <map> #include "MeteoSocket.h" using namespace IRA; /** * This class is derived from template DevIO and it is used by the temperature property of the MeteoStation component * @author <a href=mailto:spoppi@oa-cagliari.inaf.it>Sergio Poppi</a>, * Istituto di Radioastronomia, Italia<br> */ class DevIOHumidity : public DevIO<CORBA::Double> { public: /** * Constructor * @param Socket pointer to a SecureArea that proctects a the socket. This object must be already initialized and configured. */ DevIOHumidity(CSecureArea<MeteoSocket>* socket):m_socket(socket) { m_initparser=false; AUTO_TRACE("DevIOHumidity::DevIOHumidity()"); } /** * Destructor */ ~DevIOHumidity() { ACS_TRACE("DevIOHumidity::~DevIOHumidity()"); } /** * @return true to initialize the property with default value from CDB. */ bool initializeValue() { AUTO_TRACE("DevIOHumidity::initializeValue()"); return false; } /** * Used to read the property value. * @throw ComponentErrors::PropertyError * @param timestamp epoch when the operation completes */ CORBA::Double read(ACS::Time& timestamp) throw (ACSErr::ACSbaseExImpl) { // get the CommandLine ....... try { CError err; CString rdata=""; CSecAreaResourceWrapper<MeteoSocket> sock=m_socket->Get(); m_val=sock->getHumidity(); return m_val; } catch (ACSErr::ACSbaseExImpl& E) { _ADD_BACKTRACE(ComponentErrors::PropertyErrorExImpl,dummy,E,"DevIOHumidity::read()"); dummy.setPropertyName("systemTemperature"); dummy.setReason("Property could not be read"); //_IRA_LOGGUARD_LOG_EXCEPTION(m_logGuard,dummy,LM_DEBUG); throw dummy; } timestamp=getTimeStamp(); //complition time } /** * It writes values into controller. Unused because the properties are read-only. */ void write(const CORBA::Double& value, ACS::Time& timestamp) throw (ACSErr::ACSbaseExImpl) { timestamp=getTimeStamp(); return; } private: CSecureArea<MeteoSocket>* m_socket; CORBA::Double m_val; bool m_initparser; }; #endif /*DevIOHumidity_H_*/