Merge branch '测试2' of http://192.168.1.22:3000/zw/Linux_Front1056 into 测试2
This commit is contained in:
@@ -4,9 +4,7 @@
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include "PQSMsg.h"
|
||||
#include "client2.h"
|
||||
#include "dealMsg.h"
|
||||
|
||||
#include "cloudfront/code/interface.h"
|
||||
#include <iostream>
|
||||
@@ -79,6 +77,7 @@ std::vector<DeviceInfo> generate_test_devices(int count) {
|
||||
"P" + dev_id.substr(1) + "01", // <20><><EFBFBD><EFBFBD>ID<49><44> P00101
|
||||
"Voltage " + dev_name,
|
||||
dev_id,
|
||||
1,
|
||||
0.0, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹֵ
|
||||
0.0,
|
||||
100.0,
|
||||
@@ -88,6 +87,7 @@ std::vector<DeviceInfo> generate_test_devices(int count) {
|
||||
"P" + dev_id.substr(1) + "02", // <20><><EFBFBD><EFBFBD>ID<49><44> P00102
|
||||
"Current " + dev_name,
|
||||
dev_id,
|
||||
2,
|
||||
0.0, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
0.0,
|
||||
20.0,
|
||||
@@ -109,37 +109,6 @@ std::vector<DeviceInfo> generate_test_devices(int count) {
|
||||
return devices;
|
||||
}
|
||||
|
||||
/* <20>̹߳<DFB3><CCB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳߳<DFB3>*/
|
||||
void* work_thread(void* arg) {
|
||||
int index = *(int*)arg; // <20><>ȡ<EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD>
|
||||
free(arg); // <20>ͷŶ<CDB7>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>״̬Ϊ<CCAC><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
pthread_mutex_lock(&thread_info[index].lock);
|
||||
printf("Thread %d started\n", index);
|
||||
thread_info[index].state = THREAD_RUNNING;
|
||||
pthread_mutex_unlock(&thread_info[index].lock);
|
||||
|
||||
// ģ<><EFBFBD><E2B9A4>ѭ<EFBFBD><D1AD>(5<><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||
while (1) {
|
||||
sleep(5);
|
||||
|
||||
// 10%<25><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>̹߳<DFB3><CCB9><EFBFBD>
|
||||
if (rand() % 10 == 0) {
|
||||
pthread_mutex_lock(&thread_info[index].lock);
|
||||
printf("Thread %d simulated failure\n", index);
|
||||
pthread_mutex_unlock(&thread_info[index].lock);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// <20>߳<EFBFBD><DFB3><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
|
||||
pthread_mutex_lock(&thread_info[index].lock);
|
||||
thread_info[index].state = THREAD_STOPPED;
|
||||
printf("Thread %d stopped\n", index);
|
||||
pthread_mutex_unlock(&thread_info[index].lock);
|
||||
return NULL;
|
||||
}
|
||||
/* <20>̹߳<DFB3><CCB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0<><30><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>*/
|
||||
/* <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD>̺߳<DFB3><CCBA><EFBFBD>*/
|
||||
void* client_manager_thread(void* arg) {
|
||||
@@ -156,14 +125,14 @@ void* client_manager_thread(void* arg) {
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
std::vector<PointInfo> points1 = {
|
||||
{"P001", "Main Voltage", "D001", 10.0, 0.0, 100.0, 0.0},
|
||||
{"P002", "Backup Voltage", "D001", 5.0, 0.0, 50.0, 0.0}
|
||||
{"P001", "Main Voltage", "D001",1 ,1, 1, 1, 1},
|
||||
{"P002", "Backup Voltage", "D001",2 ,1, 1, 1, 1}
|
||||
};
|
||||
|
||||
std::vector<PointInfo> points2 = {
|
||||
{"P101", "Generator Output", "D002", 20.0, 0.0, 200.0, 0.0}
|
||||
{"P101", "Generator Output", "D002",1 ,1, 1, 1, 1}
|
||||
};
|
||||
|
||||
//00-B7-8D-A8-00-D6
|
||||
// <20><><EFBFBD><EFBFBD>װ<EFBFBD><D7B0><EFBFBD>б<EFBFBD>
|
||||
std::vector<DeviceInfo> devices = {
|
||||
{
|
||||
@@ -171,7 +140,7 @@ void* client_manager_thread(void* arg) {
|
||||
1, points1
|
||||
},
|
||||
{
|
||||
"D002", "Backup Device", "Model-Y", "00-B7-8D-A8-00-D6",
|
||||
"D002", "Backup Device", "Model-Y", "00-B7-8D-01-79-06",
|
||||
1, points2
|
||||
}
|
||||
};
|
||||
@@ -267,7 +236,7 @@ void restart_thread(int index) {
|
||||
free(new_index);
|
||||
}
|
||||
}
|
||||
else if (index == 2) {
|
||||
else if (false) {
|
||||
// <20>ӿڣ<D3BF>mq
|
||||
char* argv[] = { (char*)new_index };//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̺Ų<CCBA><C5B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
ThreadArgs* args = new ThreadArgs{1, argv};
|
||||
|
||||
Reference in New Issue
Block a user