V0.12
This commit is contained in:
parent
8459eba2d6
commit
dc12ef7c8c
@ -4,6 +4,7 @@
|
|||||||
#include "nlohmann/json.hpp"
|
#include "nlohmann/json.hpp"
|
||||||
#include "CC.h"
|
#include "CC.h"
|
||||||
#include "string"
|
#include "string"
|
||||||
|
|
||||||
using JSON = nlohmann::json;
|
using JSON = nlohmann::json;
|
||||||
|
|
||||||
// 定义用于简化json序列化和反序列化的宏
|
// 定义用于简化json序列化和反序列化的宏
|
||||||
@ -13,8 +14,7 @@ friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json
|
|||||||
|
|
||||||
namespace CTL {
|
namespace CTL {
|
||||||
// 定义一个继承自nlohmann::json的JSONObject类
|
// 定义一个继承自nlohmann::json的JSONObject类
|
||||||
class JSONObject: public JSON
|
class JSONObject: public JSON{
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
// 继承nlohmann::json的构造函数
|
// 继承nlohmann::json的构造函数
|
||||||
using nlohmann::json::json;
|
using nlohmann::json::json;
|
||||||
|
|||||||
@ -133,7 +133,7 @@ void CTL::DatagramSocket::receive(DatagramPacket &packet) const {
|
|||||||
const InetAddress address(info.IPAddress);
|
const InetAddress address(info.IPAddress);
|
||||||
packet.setAddress(address);
|
packet.setAddress(address);
|
||||||
packet.setPort(info.Port);
|
packet.setPort(info.Port);
|
||||||
packet.setData(buffer.subBuffer(0,len - 1));
|
packet.setData(buffer.subBuffer(0,len));
|
||||||
packet.setLength(len);
|
packet.setLength(len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,6 +84,9 @@ public:
|
|||||||
}
|
}
|
||||||
static void Function_0xA4(const DataPacket& packet){
|
static void Function_0xA4(const DataPacket& packet){
|
||||||
|
|
||||||
|
}
|
||||||
|
static void Function_0xA7(const DataPacket& packet){
|
||||||
|
CTL::System::Println("Error: {} Str: {}",packet.Parameter1,packet.AdditionalData.toString().c_str());
|
||||||
}
|
}
|
||||||
static void Function_0xF2(const DataPacket& packet){
|
static void Function_0xF2(const DataPacket& packet){
|
||||||
const auto Setting = Config::getConfig();
|
const auto Setting = Config::getConfig();
|
||||||
|
|||||||
@ -73,6 +73,13 @@ public:
|
|||||||
taskInfo->TaskType = Json.get("TaskType");
|
taskInfo->TaskType = Json.get("TaskType");
|
||||||
taskInfo->ServerPort = Json.get("ServerPort");
|
taskInfo->ServerPort = Json.get("ServerPort");
|
||||||
const auto TermList = Json.get("Terms").get<CCVector<int>>();
|
const auto TermList = Json.get("Terms").get<CCVector<int>>();
|
||||||
|
try {
|
||||||
|
taskInfo->SendOrder = Json.get("SendOrder");
|
||||||
|
if (taskInfo->SendOrder == 1) {
|
||||||
|
taskInfo->TaskOrder = Json.get("TaskOrder").get<std::vector<char>>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (...){}
|
||||||
for (const auto& TID : TermList) {
|
for (const auto& TID : TermList) {
|
||||||
taskInfo->Terms.put(TID, TID);
|
taskInfo->Terms.put(TID, TID);
|
||||||
}
|
}
|
||||||
@ -83,6 +90,13 @@ public:
|
|||||||
else if (Flag == 0) {
|
else if (Flag == 0) {
|
||||||
const auto taskInfo = TaskInfo::getData(TaskID);
|
const auto taskInfo = TaskInfo::getData(TaskID);
|
||||||
if (taskInfo) {
|
if (taskInfo) {
|
||||||
|
try {
|
||||||
|
taskInfo->SendOrder = Json.get("SendOrder");
|
||||||
|
if (taskInfo->SendOrder == 1) {
|
||||||
|
taskInfo->TaskOrder = Json.get("TaskOrder").get<std::vector<char>>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (...){}
|
||||||
if (taskInfo->Type == 0 && taskInfo->pushFlowTask) {
|
if (taskInfo->Type == 0 && taskInfo->pushFlowTask) {
|
||||||
taskInfo->pushFlowTask->stop();
|
taskInfo->pushFlowTask->stop();
|
||||||
}
|
}
|
||||||
@ -108,6 +122,13 @@ public:
|
|||||||
for (const auto& TID : TermList) {
|
for (const auto& TID : TermList) {
|
||||||
taskInfo->Terms.put(TID, TID);
|
taskInfo->Terms.put(TID, TID);
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
taskInfo->SendOrder = Task.SendOrder;
|
||||||
|
if (taskInfo->SendOrder == 1) {
|
||||||
|
taskInfo->TaskOrder = Task.TaskOrder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (...){}
|
||||||
taskInfo->pushFlowTask = new PushFlowTask(taskInfo->TaskID);
|
taskInfo->pushFlowTask = new PushFlowTask(taskInfo->TaskID);
|
||||||
TaskInfo::Start(taskInfo);
|
TaskInfo::Start(taskInfo);
|
||||||
taskInfo->pushFlowTask->start();
|
taskInfo->pushFlowTask->start();
|
||||||
|
|||||||
@ -23,14 +23,18 @@ void Routing::RoutingFunction(const DataPacket &packet) {
|
|||||||
R_Order_AA::Function_0xAA(packet);
|
R_Order_AA::Function_0xAA(packet);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0xC1: {
|
|
||||||
R_Order_AA::Function_0xC1(packet);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 0xA4: {
|
case 0xA4: {
|
||||||
R_Order_AA::Function_0xA4(packet);
|
R_Order_AA::Function_0xA4(packet);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 0xA7: {
|
||||||
|
R_Order_AA::Function_0xA7(packet);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 0xC1: {
|
||||||
|
R_Order_AA::Function_0xC1(packet);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 0xF2: {
|
case 0xF2: {
|
||||||
R_Order_AA::Function_0xF2(packet);
|
R_Order_AA::Function_0xF2(packet);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -57,7 +57,7 @@ void TaskInfo::InitSocket() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CTL::Thread::SleepMS(5);
|
CTL::Thread::Sleep(300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -69,12 +69,34 @@ void TaskInfo::InitSocket() {
|
|||||||
|
|
||||||
void TaskInfo::Start(TaskInfo *taskInfo) {
|
void TaskInfo::Start(TaskInfo *taskInfo) {
|
||||||
TaskInfoMap.put(taskInfo->TaskID,taskInfo);
|
TaskInfoMap.put(taskInfo->TaskID,taskInfo);
|
||||||
|
const auto Aim = new AIMInfo;
|
||||||
|
CTL::AutoDestruct AimDestruct(Aim);
|
||||||
|
Aim->Data = CTL::ByteArray(taskInfo->TaskOrder.data(),taskInfo->TaskOrder.size());
|
||||||
|
for (const auto &ID : taskInfo->Terms) {
|
||||||
|
const auto term = Terminal::getData(ID.first);
|
||||||
|
if (term) {
|
||||||
|
Aim->IP = term->IP;
|
||||||
|
Aim->Port = term->Port;
|
||||||
|
Transmitter::Send_Massage(Aim);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskInfo::Stop(const int TaskID) {
|
void TaskInfo::Stop(const int TaskID) {
|
||||||
const auto taskInfo = getData(TaskID);
|
const auto taskInfo = getData(TaskID);
|
||||||
if (taskInfo) {
|
if (taskInfo) {
|
||||||
taskInfo->Flag = 0;
|
taskInfo->Flag = 0;
|
||||||
|
const auto Aim = new AIMInfo;
|
||||||
|
CTL::AutoDestruct AimDestruct(Aim);
|
||||||
|
Aim->Data = CTL::ByteArray(taskInfo->TaskOrder.data(),taskInfo->TaskOrder.size());
|
||||||
|
for (const auto &ID : taskInfo->Terms) {
|
||||||
|
const auto term = Terminal::getData(ID.first);
|
||||||
|
if (term) {
|
||||||
|
Aim->IP = term->IP;
|
||||||
|
Aim->Port = term->Port;
|
||||||
|
Transmitter::Send_Massage(Aim);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
TaskInfoMap.Remove(TaskID);
|
TaskInfoMap.Remove(TaskID);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,13 +7,15 @@
|
|||||||
#include "PushFlowTask.h"
|
#include "PushFlowTask.h"
|
||||||
|
|
||||||
struct Dist_Tasks {
|
struct Dist_Tasks {
|
||||||
JSON_TYPE_INTRUSIVE(Dist_Tasks,TaskID,TaskType,Terms,AimIP,AimPort,ServerPort);
|
JSON_TYPE_INTRUSIVE(Dist_Tasks,TaskID,TaskType,Terms,AimIP,AimPort,ServerPort,SendOrder,TaskOrder);
|
||||||
int TaskID = -1;
|
int TaskID = -1;
|
||||||
int TaskType = 0;
|
int TaskType = 0;
|
||||||
CTL::String AimIP;
|
CTL::String AimIP;
|
||||||
int AimPort = 10062;
|
int AimPort = 10062;
|
||||||
int ServerPort = 10060;
|
int ServerPort = 10060;
|
||||||
CCVector<int> Terms;
|
CCVector<int> Terms;
|
||||||
|
int SendOrder = 0;
|
||||||
|
std::vector<char> TaskOrder{};
|
||||||
};
|
};
|
||||||
|
|
||||||
class TaskInfo {
|
class TaskInfo {
|
||||||
@ -30,6 +32,8 @@ public:
|
|||||||
int TaskID = -1;
|
int TaskID = -1;
|
||||||
int TaskType = 0;
|
int TaskType = 0;
|
||||||
int ServerPort = 10060;
|
int ServerPort = 10060;
|
||||||
|
int SendOrder = 0;
|
||||||
|
std::vector<char> TaskOrder{};
|
||||||
CTL::Map<int, int> Terms;
|
CTL::Map<int, int> Terms;
|
||||||
PushFlowTask* pushFlowTask = nullptr;
|
PushFlowTask* pushFlowTask = nullptr;
|
||||||
private:
|
private:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user