本文整理汇总了C++中sOnConnected函数的典型用法代码示例。如果您正苦于以下问题:C++ sOnConnected函数的具体用法?C++ sOnConnected怎么用?C++ sOnConnected使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sOnConnected函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Init
bool CDummy::StartHardware()
{
Init();
m_bIsStarted=true;
sOnConnected(this);
return true;
}
开发者ID:ghoben,项目名称:domoticz,代码行数:7,代码来源:Dummy.cpp
示例2: socket
bool CurrentCostMeterTCP::ConnectInternal()
{
m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (m_socket == INVALID_SOCKET)
{
_log.Log(LOG_ERROR,"CurrentCost Smart Meter: could not create a TCP/IP socket!");
return false;
}
// connect to the server
int nRet;
nRet = connect(m_socket,(const sockaddr*)&m_addr, sizeof(m_addr));
if (nRet == SOCKET_ERROR)
{
closesocket(m_socket);
m_socket=INVALID_SOCKET;
_log.Log(LOG_ERROR,"CurrentCost Smart Meter: could not connect to: %s:%ld",m_szIPAddress.c_str(),m_usIPPort);
return false;
}
_log.Log(LOG_STATUS,"CurrentCost Smart Meter: connected to: %s:%ld", m_szIPAddress.c_str(), m_usIPPort);
Init();
sOnConnected(this);
return true;
}
开发者ID:AbsolutK,项目名称:domoticz,代码行数:27,代码来源:CurrentCostMeterTCP.cpp
示例3: open
bool OTGWSerial::OpenSerialDevice()
{
//Try to open the Serial Port
try
{
_log.Log(LOG_STATUS,"OTGW: Using serial port: %s", m_szSerialPort.c_str());
open(
m_szSerialPort,
m_iBaudRate,
boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::none),
boost::asio::serial_port_base::character_size(8)
);
}
catch (boost::exception & e)
{
_log.Log(LOG_ERROR,"OTGW: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,"OTGW:Error opening serial port!!!");
return false;
}
m_bIsStarted=true;
m_bufferpos=0;
setReadCallback(boost::bind(&OTGWSerial::readCallback, this, _1, _2));
sOnConnected(this);
m_bRequestVersion = true;
return true;
}
开发者ID:AbsolutK,项目名称:domoticz,代码行数:35,代码来源:OTGWSerial.cpp
示例4: socket
bool SolarMaxTCP::ConnectInternal()
{
m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (m_socket == INVALID_SOCKET)
{
_log.Log(LOG_ERROR, "SolarMax: TCP could not create a TCP/IP socket!");
return false;
}
/*
//Set socket timeout to 2 minutes
#if !defined WIN32
struct timeval tv;
tv.tv_sec = 120;
setsockopt(m_socket, SOL_SOCKET, SO_RCVTIMEO,(struct timeval *)&tv,sizeof(struct timeval));
#else
unsigned long nTimeout = 120*1000;
setsockopt(m_socket, SOL_SOCKET, SO_RCVTIMEO, (const char*)&nTimeout, sizeof(DWORD));
#endif
*/
// connect to the server
int nRet;
nRet = connect(m_socket, (const sockaddr*)&m_addr, sizeof(m_addr));
if (nRet == SOCKET_ERROR)
{
closesocket(m_socket);
m_socket = INVALID_SOCKET;
_log.Log(LOG_ERROR, "SolarMax: TCP could not connect to: %s:%ld", m_szIPAddress.c_str(), m_usIPPort);
return false;
}
_log.Log(LOG_STATUS, "SolarMax: TCP connected to: %s:%ld", m_szIPAddress.c_str(), m_usIPPort);
sOnConnected(this);
return true;
}
开发者ID:AbsolutK,项目名称:domoticz,代码行数:35,代码来源:SolarMaxTCP.cpp
示例5: StartHeartbeatThread
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;
}
开发者ID:interxis,项目名称:domoticz,代码行数:35,代码来源:Teleinfo.cpp
示例6: open
bool CDavisLoggerSerial::OpenSerialDevice()
{
//Try to open the Serial Port
try
{
open(m_szSerialPort,m_iBaudRate);
_log.Log(LOG_STATUS,"Davis: Using serial port: %s", m_szSerialPort.c_str());
m_statecounter=0;
m_state=DSTATE_WAKEUP;
}
catch (boost::exception & e)
{
_log.Log(LOG_ERROR,"Davis: 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,"Davis: Error opening serial port!!!");
return false;
}
m_bIsStarted=true;
setReadCallback(boost::bind(&CDavisLoggerSerial::readCallback, this, _1, _2));
sOnConnected(this);
return true;
}
开发者ID:comitservice,项目名称:domoticz,代码行数:30,代码来源:DavisLoggerSerial.cpp
示例7: _configthreadlocale
void ZWaveBase::Do_Work()
{
#ifdef WIN32
//prevent OpenZWave locale from taking over
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
#endif
while (!m_stoprequested)
{
sleep_milliseconds(500);
if (m_stoprequested)
return;
if (m_bInitState)
{
if (GetInitialDevices())
{
m_bInitState=false;
sOnConnected(this);
}
}
else
{
GetUpdates();
if (m_bControllerCommandInProgress==true)
{
time_t atime=mytime(NULL);
time_t tdiff=atime-m_ControllerCommandStartTime;
if (tdiff>=CONTROLLER_COMMAND_TIMEOUT)
{
_log.Log(LOG_ERROR,"ZWave: Stopping Controller command (Timeout!)");
CancelControllerCommand();
}
}
}
}
}
开发者ID:G3ronim0,项目名称:domoticz,代码行数:35,代码来源:ZWaveBase.cpp
示例8: sOnConnected
void MQTT::on_connect(int rc)
{
/* rc=
** 0 - success
** 1 - connection refused(unacceptable protocol version)
** 2 - connection refused(identifier rejected)
** 3 - connection refused(broker unavailable)
*/
if (rc == 0){
if (m_IsConnected) {
_log.Log(LOG_STATUS, "MQTT: re-connected to: %s:%ld", m_szIPAddress.c_str(), m_usIPPort);
} else {
_log.Log(LOG_STATUS, "MQTT: connected to: %s:%ld", m_szIPAddress.c_str(), m_usIPPort);
m_IsConnected = true;
sOnConnected(this);
m_sConnection = m_mainworker.sOnDeviceReceived.connect(boost::bind(&MQTT::SendDeviceInfo, this, _1, _2, _3, _4));
}
subscribe(NULL, TOPIC_IN);
}
else {
_log.Log(LOG_ERROR, "MQTT: Connection failed!, restarting (rc=%d)",rc);
m_bDoReconnect = true;
}
}
开发者ID:interxis,项目名称:domoticz,代码行数:25,代码来源:MQTT.cpp
示例9: WHERE
void CHardwareMonitor::Init()
{
#ifdef __APPLE__
//sorry apple not supported for now
m_bEnabled=false;
return;
#endif
// Check if there is already a hardware devices for our class, if no add it.
m_lastquerytime=0;
m_HwdID = 0;
std::vector<std::vector<std::string> > result;
result = m_sql.safe_query("SELECT ID,Enabled FROM Hardware WHERE (Type==%d) AND (Name=='Motherboard') LIMIT 1", HTYPE_System);
if (result.size()<1)
{
m_sql.safe_query("INSERT INTO Hardware (Name, Enabled, Type, Address, Port, Username, Password, Mode1, Mode2, Mode3, Mode4, Mode5, Mode6) VALUES ('Motherboard',1, %d,'',1,'','',0,0,0,0,0,0)", HTYPE_System);
result=m_sql.safe_query("SELECT MAX(ID) FROM Hardware");
if (result.size()>0)
{
std::vector<std::string> sd=result[0];
m_HwdID=atoi(sd[0].c_str());
}
result = m_sql.safe_query("SELECT ID,Enabled FROM Hardware WHERE (Type==%d) AND (Name=='Motherboard') LIMIT 1", HTYPE_System);
}
if (result.size()>0)
{
std::vector<std::string> sd=result[0];
m_HwdID=atoi(sd[0].c_str());
m_bEnabled=atoi(sd[1].c_str())!=0;
}
sOnConnected(this);
}
开发者ID:saeedhadi,项目名称:domoticz,代码行数:32,代码来源:HardwareMonitor.cpp
示例10: fclose
bool P1MeterSerial::StartHardware()
{
#ifdef DEBUG_FROM_FILE
FILE *fIn=fopen("E:\\meter.txt","rb+");
BYTE buffer[1000];
int ret=fread((BYTE*)&buffer,1,sizeof(buffer),fIn);
fclose(fIn);
ParseData((const BYTE*)&buffer,ret);
#endif
m_stoprequested = false;
m_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&P1MeterSerial::Do_Work, this)));
//Try to open the Serial Port
try
{
_log.Log(LOG_STATUS,"P1 Smart Meter: Using serial port: %s", m_szSerialPort.c_str());
if (m_iBaudRate==9600)
{
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)
);
}
else
{
//DSMRv4
open(
m_szSerialPort,
m_iBaudRate,
boost::asio::serial_port_base::parity(
boost::asio::serial_port_base::parity::none),
boost::asio::serial_port_base::character_size(8)
);
}
}
catch (boost::exception & e)
{
_log.Log(LOG_ERROR,"P1 Smart Meter: 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,"P1 Smart Meter: Error opening serial port!!!");
return false;
}
m_bIsStarted=true;
m_linecount=0;
m_exclmarkfound=0;
setReadCallback(boost::bind(&P1MeterSerial::readCallback, this, _1, _2));
sOnConnected(this);
return true;
}
开发者ID:swevm,项目名称:domoticz,代码行数:60,代码来源:P1MeterSerial.cpp
示例11: sOnConnected
void MochadTCP::OnConnect()
{
_log.Log(LOG_STATUS, "Mochad: connected to: %s:%ld", m_szIPAddress.c_str(), m_usIPPort);
m_bIsStarted = true;
sOnConnected(this);
}
开发者ID:AbsolutK,项目名称:domoticz,代码行数:7,代码来源:MochadTCP.cpp
示例12: open
bool CRFLink::OpenSerialDevice()
{
//Try to open the Serial Port
try
{
open(m_szSerialPort, 57600);
_log.Log(LOG_STATUS,"RFLink: Using serial port: %s", m_szSerialPort.c_str());
}
catch (boost::exception & e)
{
_log.Log(LOG_ERROR,"RFLink: 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,"RFLink: Error opening serial port!!!");
return false;
}
m_bIsStarted=true;
m_LastReceivedTime = mytime(NULL);
setReadCallback(boost::bind(&CRFLink::readCallback, this, _1, _2));
sOnConnected(this);
return true;
}
开发者ID:clafa,项目名称:domoticz-1,代码行数:29,代码来源:RFLink.cpp
示例13: sOnConnected
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);
return (m_thread!=NULL);
}
开发者ID:ZaaaV,项目名称:domoticz,代码行数:8,代码来源:1Wire.cpp
示例14: Init
bool CTellstick::StartHardware()
{
Init();
m_bIsStarted=true;
sOnConnected(this);
_log.Log(LOG_NORM, "Tellstick: StartHardware");
return true;
}
开发者ID:karekaa,项目名称:domoticz,代码行数:8,代码来源:Tellstick.cpp
示例15: sOnConnected
void S0MeterTCP::OnConnect()
{
_log.Log(LOG_STATUS,"S0 Meter: connected to: %s:%d", m_szIPAddress.c_str(), m_usIPPort);
m_bDoRestart=false;
m_bIsStarted=true;
m_bufferpos = 0;
sOnConnected(this);
}
开发者ID:Evsdd,项目名称:domoticz,代码行数:8,代码来源:S0MeterTCP.cpp
示例16: sOnConnected
void OTGWTCP::OnConnect()
{
_log.Log(LOG_STATUS,"OTGW: connected to: %s:%ld", m_szIPAddress.c_str(), m_usIPPort);
m_bDoRestart=false;
m_bIsStarted=true;
m_bufferpos=0;
sOnConnected(this);
m_bRequestVersion = true;
}
开发者ID:AbsolutK,项目名称:domoticz,代码行数:9,代码来源:OTGWTCP.cpp
示例17: mytime
void CRFLinkTCP::OnConnect()
{
_log.Log(LOG_STATUS,"RFLink: connected to: %s:%ld", m_szIPAddress.c_str(), m_usIPPort);
m_bDoRestart=false;
m_bIsStarted=true;
m_rfbufferpos = 0;
m_LastReceivedTime = mytime(NULL);
sOnConnected(this);
write("10;PING;\n");
}
开发者ID:IgorYbema,项目名称:domoticz,代码行数:10,代码来源:RFLinkTCP.cpp
示例18: Init
bool CSterbox::StartHardware()
{
Init();
//Start worker thread
m_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&CSterbox::Do_Work, this)));
m_bIsStarted=true;
sOnConnected(this);
_log.Log(LOG_STATUS, "Sterbox: Started");
return (m_thread!=NULL);
}
开发者ID:PatMart,项目名称:domoticz,代码行数:10,代码来源:Sterbox.cpp
示例19: Init
bool CThermosmart::StartHardware()
{
Init();
m_LastMinute = -1;
//Start worker thread
m_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&CThermosmart::Do_Work, this)));
m_bIsStarted=true;
sOnConnected(this);
return (m_thread!=NULL);
}
开发者ID:domoticz,项目名称:domoticz,代码行数:10,代码来源:Thermosmart.cpp
示例20: Init
bool CWunderground::StartHardware()
{
Init();
//Start worker thread
m_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&CWunderground::Do_Work, this)));
if (!m_thread)
return false;
m_bIsStarted=true;
sOnConnected(this);
return true;
}
开发者ID:IgorYbema,项目名称:domoticz,代码行数:11,代码来源:Wunderground.cpp
注:本文中的sOnConnected函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论