You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
958 B
60 lines
958 B
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// nwthread.h is part of TestModbus-Client.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef _NWTHREAD_H_
|
|
#define _NWTHREAD_H_
|
|
|
|
#include <string>
|
|
#include <gtk/gtk.h>
|
|
#include <gdk/gdk.h>
|
|
#include <glib.h>
|
|
#include <sys/time.h>
|
|
|
|
enum {
|
|
NWT_nothing,
|
|
NWT_connect,
|
|
NWT_running,
|
|
NWT_error,
|
|
NWT_close
|
|
};
|
|
|
|
|
|
class NetworkThread {
|
|
private:
|
|
GMutex mutex;
|
|
GThread *thread;
|
|
int state;
|
|
|
|
int req_fc; // 0 .. is no request
|
|
int req_offset;
|
|
int req_size;
|
|
int req_timeout; // timeout[ms]
|
|
struct timeval req_time;
|
|
|
|
std::string host, port;
|
|
|
|
void SetState(int s);
|
|
void ClientSendStatustext(char* txt);
|
|
|
|
public:
|
|
NetworkThread();
|
|
~NetworkThread();
|
|
|
|
void Lock();
|
|
void UnLock();
|
|
|
|
int Connect(std::string dest_host, std::string dest_port);
|
|
int Disconnect();
|
|
|
|
int GetState();
|
|
int SendRequest();
|
|
|
|
void Thread();
|
|
};
|
|
|
|
|
|
#endif
|