bool Teleinfo::StartHardware() { StartHeartbeatThread(); //Try to open the Serial Port try { _log.Log(LOG_STATUS, "Teleinfo: Using serial port: %s", m_szSerialPort.c_str()); open( m_szSerialPort, m_iBaudRate, m_iOptParity, m_iOptCsize ); } catch (boost::exception & e) { _log.Log(LOG_ERROR, "Teleinfo: Error opening serial port!"); #ifdef _DEBUG _log.Log(LOG_ERROR, "-----------------\n%s\n-----------------", boost::diagnostic_information(e).c_str()); #else (void)e; #endif return false; } catch (...) { _log.Log(LOG_ERROR, "Teleinfo: Error opening serial port!!!"); return false; } setReadCallback(boost::bind(&Teleinfo::readCallback, this, _1, _2)); m_bIsStarted = true; sOnConnected(this); return true; }
bool C1Wire::StartHardware() { // Start worker thread m_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&C1Wire::Do_Work, this))); m_bIsStarted=true; sOnConnected(this); StartHeartbeatThread(); return (m_thread!=NULL); }
bool S0MeterSerial::StartHardware() { StartHeartbeatThread(); //Try to open the Serial Port try { _log.Log(LOG_STATUS,"S0 Meter: Using serial port: %s", m_szSerialPort.c_str()); #ifndef WIN32 openOnlyBaud( m_szSerialPort, m_iBaudRate, boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::even), boost::asio::serial_port_base::character_size(7) ); #else open( m_szSerialPort, m_iBaudRate, boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::even), boost::asio::serial_port_base::character_size(7) ); #endif } catch (boost::exception & e) { _log.Log(LOG_ERROR,"S0 Meter: Error opening serial port!"); #ifdef _DEBUG _log.Log(LOG_ERROR,"-----------------\n%s\n-----------------",boost::diagnostic_information(e).c_str()); #endif return false; } catch ( ... ) { _log.Log(LOG_ERROR,"S0 Meter: Error opening serial port!!!"); return false; } m_bIsStarted=true; m_bufferpos=0; ReloadLastTotals(); setReadCallback(boost::bind(&S0MeterSerial::readCallback, this, _1, _2)); sOnConnected(this); #ifdef DEBUG_S0 int ii = 0; for (ii = 0; ii < TOT_DEBUG_LINES; ii++) { std::string dline = szDebugDataP2[ii]; ParseData((const unsigned char*)dline.c_str(), dline.size()); } #endif return true; }
bool MQTT::StartHardware() { StartHeartbeatThread(); m_stoprequested=false; //force connect the next first time m_IsConnected=false; m_bIsStarted = true; //Start worker thread m_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&MQTT::Do_Work, this))); return (m_thread!=NULL); }
bool CPanasonic::StartHardware() { StopHardware(); m_bIsStarted = true; sOnConnected(this); StartHeartbeatThread(); //Start worker thread m_stoprequested = false; m_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&CPanasonic::Do_Work, this))); _log.Log(LOG_STATUS, "Panasonic Plugin: Started"); return true; }
bool C1Wire::StartHardware() { // Start worker thread if (0 != m_sensorThreadPeriod) { m_threadSensors = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&C1Wire::SensorThread, this))); } if (0 != m_switchThreadPeriod) { m_threadSwitches = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&C1Wire::SwitchThread, this))); } m_bIsStarted=true; sOnConnected(this); StartHeartbeatThread(); return (m_threadSensors!=NULL && m_threadSwitches!=NULL); }
bool CLogitechMediaServer::StartHardware() { StopHardware(); m_bIsStarted = true; sOnConnected(this); m_iThreadsRunning = 0; m_bShowedStartupMessage = false; StartHeartbeatThread(); //Start worker thread m_stoprequested = false; m_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&CLogitechMediaServer::Do_Work, this))); return (m_thread != NULL); }
bool CGpio::StartHardware() { m_stoprequested=false; // _log.Log(LOG_NORM,"GPIO: Starting hardware (debounce: %d ms, period: %d ms, poll interval: %d sec)", m_debounce, m_period, m_pollinterval); if (InitPins()) { /* Disabled for now, devices should be added manually (this was the old behaviour, which we'll follow for now). Keep code for possible future usage. if (!CreateDomoticzDevices()) { _log.Log(LOG_NORM, "GPIO: Error creating pins in DB, aborting..."); m_stoprequested=true; }*/ if (!m_stoprequested) { // Read all exported GPIO ports and set the device status accordingly. // No need for delayed startup and force update when no masters are able to connect. std::vector<std::vector<std::string> > result; result = m_sql.safe_query("SELECT ID FROM Users WHERE (RemoteSharing==1) AND (Active==1)"); if (result.size() > 0) { for (int i = 0; i < DELAYED_STARTUP_SEC; ++i) { sleep_milliseconds(1000); if (m_stoprequested) break; } _log.Log(LOG_NORM, "GPIO: Optional connected Master Domoticz now updates its status"); UpdateDeviceStates(true); } else UpdateDeviceStates(false); if (m_pollinterval > 0) m_thread_poller = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&CGpio::Poller, this))); } } else { _log.Log(LOG_NORM, "GPIO: No exported pins found, aborting..."); m_stoprequested=true; } m_bIsStarted=true; sOnConnected(this); StartHeartbeatThread(); return (m_thread != NULL); }
bool CTeleinfoSerial::StartHardware() { StartHeartbeatThread(); //Try to open the Serial Port try { _log.Log(LOG_STATUS, "(%s) Teleinfo device uses serial port: %s at %i bauds", Name.c_str(), m_szSerialPort.c_str(), m_iBaudRate); open(m_szSerialPort, m_iBaudRate, m_iOptParity, m_iOptCsize); } catch (boost::exception & e) { #ifdef DEBUG_TeleinfoSerial _log.Log(LOG_ERROR, "-----------------\n%s\n-----------------", boost::diagnostic_information(e).c_str()); #else (void)e; #endif _log.Log(LOG_STATUS, "Teleinfo: Serial port open failed, let's retry with CharSize:8 ..."); try { open(m_szSerialPort,m_iBaudRate,m_iOptParity,boost::asio::serial_port_base::character_size(8)); _log.Log(LOG_STATUS, "Teleinfo: Serial port open successfully with CharSize:8 ..."); } catch (...) { _log.Log(LOG_ERROR, "Teleinfo: Error opening serial port, even with CharSize:8 !"); return false; } } catch (...) { _log.Log(LOG_ERROR, "Teleinfo: Error opening serial port!!!"); return false; } setReadCallback(boost::bind(&CTeleinfoSerial::readCallback, this, _1, _2)); m_bIsStarted = true; sOnConnected(this); teleinfo.CRCmode1 = 255; // Guess the CRC mode at first run if (m_bDisableCRC) _log.Log(LOG_STATUS, "(%s) CRC checks on incoming data are disabled", Name.c_str()); else _log.Log(LOG_STATUS, "(%s) CRC checks will be performed on incoming data", Name.c_str()); return true; }
bool SolarEdgeTCP::StartHardware() { m_stoprequested=false; //force connect the next first time m_retrycntr=RETRY_DELAY; m_bIsStarted=true; m_state=E_WAITING_SYNC; m_bufferpos=0; m_wantedlength=0; StartHeartbeatThread(); //Start worker thread m_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&SolarEdgeTCP::Do_Work, this))); return (m_thread!=NULL); }
bool CKodi::StartHardware() { StopHardware(); m_bIsStarted = true; sOnConnected(this); m_iThreadsRunning = 0; StartHeartbeatThread(); ReloadNodes(); //Start worker thread m_stoprequested = false; m_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&CKodi::Do_Work, this))); _log.Log(LOG_STATUS, "Kodi: Started"); return true; }