Rev 971 | Rev 981 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 971 | Rev 976 | ||
|---|---|---|---|
| Line 34... | Line 34... | ||
| 34 | #include "../CanNet/cannetmanager.h" |
34 | #include "../CanNet/cannetmanager.h" |
| 35 | #include "../CanNet/canmessage.h" |
35 | #include "../CanNet/canmessage.h" |
| 36 | #include "../Threads/semaphore.h" |
36 | #include "../Threads/semaphore.h" |
| 37 | #include "../Threads/threadsafequeue.h" |
37 | #include "../Threads/threadsafequeue.h" |
| 38 | #include "intervalthread.h" |
38 | #include "intervalthread.h" |
| - | 39 | #include "socketthread.h" |
|
| 39 | 40 | ||
| 40 | using namespace v8; |
41 | using namespace v8; |
| 41 | 42 | ||
| 42 | Handle<Value> VirtualMachine_log(const Arguments& args); |
43 | Handle<Value> VirtualMachine_log(const Arguments& args); |
| 43 | Handle<Value> VirtualMachine_sendCanMessage(const Arguments& args); |
44 | Handle<Value> VirtualMachine_sendCanMessage(const Arguments& args); |
| 44 | Handle<Value> VirtualMachine_loadScript(const Arguments& args); |
45 | Handle<Value> VirtualMachine_loadScript(const Arguments& args); |
| 45 | Handle<Value> VirtualMachine_stopIntervalThread(const Arguments& args); |
46 | Handle<Value> VirtualMachine_stopIntervalThread(const Arguments& args); |
| 46 | Handle<Value> VirtualMachine_startIntervalThread(const Arguments& args); |
47 | Handle<Value> VirtualMachine_startIntervalThread(const Arguments& args); |
| - | 48 | Handle<Value> VirtualMachine_stopSocketThread(const Arguments& args); |
|
| - | 49 | Handle<Value> VirtualMachine_startSocketThread(const Arguments& args); |
|
| - | 50 | Handle<Value> VirtualMachine_sendToSocketThread(const Arguments& args); |
|
| 47 | 51 | ||
| 48 | class VirtualMachine : public Thread<VirtualMachine> |
52 | class VirtualMachine : public Thread<VirtualMachine> |
| 49 | { |
53 | { |
| 50 | public: |
54 | public: |
| 51 | static VirtualMachine& getInstance(); |
55 | static VirtualMachine& getInstance(); |
| Line 55... | Line 59... | ||
| 55 | void queueExpression(string expression); |
59 | void queueExpression(string expression); |
| 56 | 60 | ||
| 57 | void run(); |
61 | void run(); |
| 58 | 62 | ||
| 59 | bool loadScript(string scriptName); |
63 | bool loadScript(string scriptName); |
| - | 64 | ||
| 60 | unsigned int startIntervalThread(unsigned int timeout); |
65 | unsigned int startIntervalThread(unsigned int timeout); |
| 61 | bool stopIntervalThread(unsigned int id); |
66 | bool stopIntervalThread(unsigned int id); |
| - | 67 | ||
| - | 68 | unsigned int startSocketThread(string address, int port, unsigned int reconnectTimeout); |
|
| - | 69 | bool stopSocketThread(unsigned int id); |
|
| - | 70 | void sendToSocketThread(unsigned int id, string data); |
|
| 62 | 71 | ||
| 63 | private: |
72 | private: |
| 64 | void callHandleHeartbeat(int hardwareId); |
73 | void callHandleHeartbeat(int hardwareId); |
| 65 | void callHandleMessage(CanMessage canMessage); |
74 | void callHandleMessage(CanMessage canMessage); |
| 66 | bool runExpression(string expression); |
75 | bool runExpression(string expression); |
| Line 82... | Line 91... | ||
| 82 | 91 | ||
| 83 | ThreadSafeQueue<string> myExpressions; |
92 | ThreadSafeQueue<string> myExpressions; |
| 84 | ThreadSafeQueue<CanMessage> myCanMessages; |
93 | ThreadSafeQueue<CanMessage> myCanMessages; |
| 85 | 94 | ||
| 86 | map<int, IntervalThread> myIntervalThreads; |
95 | map<int, IntervalThread> myIntervalThreads; |
| - | 96 | map<int, SocketThread> mySocketThreads; |
|
| 87 | }; |
97 | }; |
| 88 | 98 | ||
| 89 | #endif /* _VIRTUALMACHINE_H */ |
99 | #endif /* _VIRTUALMACHINE_H */ |
| 90 | 100 | ||