Commit a394487f by xjp0422

protobuf异常捕获 TDSCmd更新

parent b2af52f6
No preview for this file type
...@@ -50,6 +50,8 @@ namespace Mqtt_AGI ...@@ -50,6 +50,8 @@ namespace Mqtt_AGI
//获取配置信息中的站点等级信息 生成LevelUid //获取配置信息中的站点等级信息 生成LevelUid
static void Level_Topic_Uid_init() static void Level_Topic_Uid_init()
{ {
try
{
string IniPath = System.Windows.Forms.Application.StartupPath + "\\config.ini"; string IniPath = System.Windows.Forms.Application.StartupPath + "\\config.ini";
StringBuilder level1 = new StringBuilder(16); StringBuilder level1 = new StringBuilder(16);
StringBuilder level2 = new StringBuilder(16); StringBuilder level2 = new StringBuilder(16);
...@@ -57,53 +59,66 @@ namespace Mqtt_AGI ...@@ -57,53 +59,66 @@ namespace Mqtt_AGI
GetPrivateProfileString("role", "level1", "0", level1, 16, IniPath); GetPrivateProfileString("role", "level1", "0", level1, 16, IniPath);
GetPrivateProfileString("role", "level2", "0", level2, 16, IniPath); GetPrivateProfileString("role", "level2", "0", level2, 16, IniPath);
GetPrivateProfileString("role", "level3", "0", level3, 16, IniPath); GetPrivateProfileString("role", "level3", "0", level3, 16, IniPath);
//Console.WriteLine(SerializeUid.SerilizeString(Convert.ToUInt32(level1.ToString()), Convert.ToUInt32(level2.ToString()), Convert.ToUInt32(level3.ToString()))); //Console.WriteLine(SerializeUid.SerilizeString(Convert.ToUInt32(level1.ToString()), Convert.ToUInt32(level2.ToString()), Convert.ToUInt32(level3.ToString())));
LevelTopic= SerializeUid.Serilize_Init_Level_Topic(Convert.ToUInt32(level1.ToString()), Convert.ToUInt32(level2.ToString()), Convert.ToUInt32(level3.ToString())); LevelTopic = SerializeUid.Serilize_Init_Level_Topic(Convert.ToUInt32(level1.ToString()), Convert.ToUInt32(level2.ToString()), Convert.ToUInt32(level3.ToString()));
LevelUid = SerializeUid.Serilize_Init_Level_Uid(Convert.ToUInt32(level1.ToString()) , Convert.ToUInt32(level2.ToString()) , Convert.ToUInt32(level3.ToString())); LevelUid = SerializeUid.Serilize_Init_Level_Uid(Convert.ToUInt32(level1.ToString()), Convert.ToUInt32(level2.ToString()), Convert.ToUInt32(level3.ToString()));
clientId = SerializeUid.SerilizeUid(LevelUid, systemID.AGI); clientId = SerializeUid.SerilizeUid(LevelUid, systemID.AGI);
Console.WriteLine("MqttclientId:" + clientId); Console.WriteLine("MqttclientId:" + clientId);
//Console.WriteLine(Convert.ToString(subTopic,2).PadLeft(32,'0'));//32位 前面补0 //Console.WriteLine(Convert.ToString(subTopic,2).PadLeft(32,'0'));//32位 前面补0
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
} }
static void heart_thread() { static void heart_thread() {
//初始化包配置 //初始化包配置
while (true) try
{ {
Heartbeat heartbeat = new Heartbeat(); while (true)
heartbeat.Suid = Convert.ToUInt32(SerializeUid.SerilizeUid(LevelUid, systemID.AGI), 2); {
heartbeat.IidList.Add(IID.AgiReport); Heartbeat heartbeat = new Heartbeat();
heartbeat.IidList.Add(IID.AgiReportRespond); heartbeat.Suid = Convert.ToUInt32(SerializeUid.SerilizeUid(LevelUid, systemID.AGI), 2);
heartbeat.IidList.Add(IID.AgiTle); heartbeat.IidList.Add(IID.AgiReport);
heartbeat.IidList.Add(IID.AgiTleRespond); heartbeat.IidList.Add(IID.AgiReportRespond);
TDSCmd MessageHeart = new TDSCmd(); heartbeat.IidList.Add(IID.AgiTle);
MessageHeart.InterfaceId = IID.OamHeartBeatRx; heartbeat.IidList.Add(IID.AgiTleRespond);
MessageHeart.DstSuid = Convert.ToUInt32(SerializeUid.SerilizeUid(LevelUid, systemID.OAM), 2); TDSCmd MessageHeart = new TDSCmd();
MessageHeart.SrcSuid = Convert.ToUInt32(SerializeUid.SerilizeUid(LevelUid, systemID.AGI), 2); MessageHeart.InterfaceId = IID.OamHeartBeatRx;
MessageHeart.ForwardFlag = 0;//不需要转发 MessageHeart.DstSuid = Convert.ToUInt32(SerializeUid.SerilizeUid(LevelUid, systemID.OAM), 2);
MessageHeart.Ts = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(DateTime.UtcNow); MessageHeart.SrcSuid = Convert.ToUInt32(SerializeUid.SerilizeUid(LevelUid, systemID.AGI), 2);
//加载数据段 MessageHeart.ForwardFlag = 0;//不需要转发
Any Parameter = Any.Pack(heartbeat); MessageHeart.Ts = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(DateTime.UtcNow);
MessageHeart.Parameters.Add(Parameter); //加载数据段
client.Publish(SerializeUid.SerilizeTopic(LevelTopic, systemID.OAM), MessageHeart.ToByteArray()); Any Parameter = Any.Pack(heartbeat);
Thread.Sleep(1000 * 10); MessageHeart.Parameters.Add(Parameter);
client.Publish(SerializeUid.SerilizeTopic(LevelTopic, systemID.OAM), MessageHeart.ToByteArray());
Thread.Sleep(1000 * 10);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
} }
} }
static void client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e) static void client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e)
{ {
//处理接收到的消息 protobuf协议 //处理接收到的消息 protobuf协议
try
TDSCmd datastruct = TDSCmd.Parser.ParseFrom(e.Message);
Console.WriteLine("收到消息 反序列化:" + datastruct + "\r\n");
Any Parameter;
for (int messageNum = 0; messageNum < datastruct.Parameters.Count; ++messageNum)
{ {
Parameter = datastruct.Parameters[messageNum]; TDSCmd datastruct = TDSCmd.Parser.ParseFrom(e.Message);
if(datastruct.InterfaceId == IID.AgiReport) Console.WriteLine("收到消息 反序列化:" + datastruct + "\r\n");
Any Parameter;
for (int messageNum = 0; messageNum < datastruct.Parameters.Count; ++messageNum)
{ {
CalcReportReq CalcReport = Parameter.Unpack<CalcReportReq>(); Parameter = datastruct.Parameters[messageNum];
string[] args = { CalcReport.StartDateTime,CalcReport.EndDateTime, if (datastruct.InterfaceId == IID.AgiReport)
{
CalcReportReq CalcReport = Parameter.Unpack<CalcReportReq>();
string[] args = { CalcReport.StartDateTime,CalcReport.EndDateTime,
CalcReport.Latitude.ToString(),CalcReport.Longitude.ToString(), CalcReport.Latitude.ToString(),CalcReport.Longitude.ToString(),
CalcReport.Altitude.ToString(),CalcReport.Slice.ToString(), CalcReport.Altitude.ToString(),CalcReport.Slice.ToString(),
CalcReport.MinAzi.ToString(),CalcReport.MaxAzi.ToString(), CalcReport.MinAzi.ToString(),CalcReport.MaxAzi.ToString(),
...@@ -111,19 +126,24 @@ namespace Mqtt_AGI ...@@ -111,19 +126,24 @@ namespace Mqtt_AGI
CalcReport.MinDist.ToString(),CalcReport.MaxDist.ToString(), CalcReport.MinDist.ToString(),CalcReport.MaxDist.ToString(),
CalcReport.PointSlice.ToString(),CalcReport.PointCollect.ToString(), CalcReport.PointSlice.ToString(),CalcReport.PointCollect.ToString(),
CalcReport.Line0,CalcReport.Line1,CalcReport.Line2}; CalcReport.Line0,CalcReport.Line1,CalcReport.Line2};
calc_report(args);//轨道预报 calc_report(args);//轨道预报
} }
else if (datastruct.InterfaceId == IID.AgiTle) else if (datastruct.InterfaceId == IID.AgiTle)
{ {
CalcTleReq CalcTle = Parameter.Unpack<CalcTleReq>(); CalcTleReq CalcTle = Parameter.Unpack<CalcTleReq>();
string[] args = { CalcTle.NoradID.ToString(), CalcTle.NoradName, string[] args = { CalcTle.NoradID.ToString(), CalcTle.NoradName,
CalcTle.Year.ToString(),CalcTle.Month.ToString(),CalcTle.Day.ToString(), CalcTle.Year.ToString(),CalcTle.Month.ToString(),CalcTle.Day.ToString(),
CalcTle.Hour.ToString(),CalcTle.Minute.ToString(),CalcTle.Second.ToString(), CalcTle.Hour.ToString(),CalcTle.Minute.ToString(),CalcTle.Second.ToString(),
CalcTle.A.ToString(),CalcTle.Ee.ToString(),CalcTle.I.ToString(), CalcTle.A.ToString(),CalcTle.Ee.ToString(),CalcTle.I.ToString(),
CalcTle.Raan.ToString(),CalcTle.Arc.ToString(),CalcTle.M.ToString() }; CalcTle.Raan.ToString(),CalcTle.Arc.ToString(),CalcTle.M.ToString() };
calc_tle(args); //精轨转TLE calc_tle(args); //精轨转TLE
}
} }
} }
catch (Exception ex) {
Console.WriteLine(ex.Message);
}
//轨道预报 //轨道预报
//处理接收到的消息 //处理接收到的消息
//string msg = System.Text.Encoding.Default.GetString(e.Message); //string msg = System.Text.Encoding.Default.GetString(e.Message);
...@@ -560,6 +580,7 @@ namespace Mqtt_AGI ...@@ -560,6 +580,7 @@ namespace Mqtt_AGI
//protobuf xxd begin //protobuf xxd begin
/* 测试先不发送xxd*/
Xxd xxd = new Xxd(); Xxd xxd = new Xxd();
xxd.Dt = xxd_date; xxd.Dt = xxd_date;
xxd.Lon = longtitude; xxd.Lon = longtitude;
...@@ -567,6 +588,7 @@ namespace Mqtt_AGI ...@@ -567,6 +588,7 @@ namespace Mqtt_AGI
xxd.Height = altitude / 1000.0; xxd.Height = altitude / 1000.0;
CalcReport.Xxds.Add(xxd); CalcReport.Xxds.Add(xxd);
//end //end
//JObject XxdObject = new JObject(); //JObject XxdObject = new JObject();
......
b30ae5d6ea524ee0ee189b3222a07c4c6c7596c1 a355bbb913a05c0d56683ebbb94f068d51ee8b9c
...@@ -169,9 +169,11 @@ enum IID : int { ...@@ -169,9 +169,11 @@ enum IID : int {
IID_Server_TaskListSend_respond = 10424, IID_Server_TaskListSend_respond = 10424,
IID_Server_TaskListReceive = 10425, IID_Server_TaskListReceive = 10425,
IID_Server_TaskListReceive_respond = 10426, IID_Server_TaskListReceive_respond = 10426,
IID_Server_FileReceive = 10427, IID_Server_FileSend = 10427,
IID_Server_FileReceive_respond = 10428, IID_Server_FileSend_respond = 10428,
IID_Server_TaskExecAnalysisResult = 105, IID_Server_FileReceive = 10429,
IID_Server_FileReceive_respond = 10430,
IID_Server_TaskExecAnalysisResult = 10501,
IID_Server_TaskExecAnalysisResult_respond = 10502, IID_Server_TaskExecAnalysisResult_respond = 10502,
IID_Server_TaskExecList = 10503, IID_Server_TaskExecList = 10503,
IID_Server_TaskExecList_respond = 10504, IID_Server_TaskExecList_respond = 10504,
...@@ -857,16 +859,17 @@ class TDSCmd final : ...@@ -857,16 +859,17 @@ class TDSCmd final :
// accessors ------------------------------------------------------- // accessors -------------------------------------------------------
enum : int { enum : int {
kParametersFieldNumber = 8, kParametersFieldNumber = 9,
kTsFieldNumber = 7, kTsFieldNumber = 8,
kInterfaceIdFieldNumber = 1, kInterfaceIdFieldNumber = 1,
kDstSuidFieldNumber = 2, kDstSuidFieldNumber = 2,
kSrcSuidFieldNumber = 3, kSrcSuidFieldNumber = 3,
kForwardFlagFieldNumber = 4, kForwardFlagFieldNumber = 4,
kPriorityFieldNumber = 5,
kRequestIndexFieldNumber = 6, kRequestIndexFieldNumber = 6,
kPriorityFieldNumber = 5,
kOperationsTypeFieldNumber = 7,
}; };
// repeated .google.protobuf.Any parameters = 8; // repeated .google.protobuf.Any parameters = 9;
int parameters_size() const; int parameters_size() const;
private: private:
int _internal_parameters_size() const; int _internal_parameters_size() const;
...@@ -884,7 +887,7 @@ class TDSCmd final : ...@@ -884,7 +887,7 @@ class TDSCmd final :
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Any >& const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Any >&
parameters() const; parameters() const;
// .google.protobuf.Timestamp ts = 7; // .google.protobuf.Timestamp ts = 8;
bool has_ts() const; bool has_ts() const;
private: private:
bool _internal_has_ts() const; bool _internal_has_ts() const;
...@@ -938,6 +941,15 @@ class TDSCmd final : ...@@ -938,6 +941,15 @@ class TDSCmd final :
void _internal_set_forward_flag(uint32_t value); void _internal_set_forward_flag(uint32_t value);
public: public:
// uint64 request_index = 6;
void clear_request_index();
uint64_t request_index() const;
void set_request_index(uint64_t value);
private:
uint64_t _internal_request_index() const;
void _internal_set_request_index(uint64_t value);
public:
// uint32 priority = 5; // uint32 priority = 5;
void clear_priority(); void clear_priority();
uint32_t priority() const; uint32_t priority() const;
...@@ -947,13 +959,13 @@ class TDSCmd final : ...@@ -947,13 +959,13 @@ class TDSCmd final :
void _internal_set_priority(uint32_t value); void _internal_set_priority(uint32_t value);
public: public:
// uint32 request_index = 6; // uint32 operations_type = 7;
void clear_request_index(); void clear_operations_type();
uint32_t request_index() const; uint32_t operations_type() const;
void set_request_index(uint32_t value); void set_operations_type(uint32_t value);
private: private:
uint32_t _internal_request_index() const; uint32_t _internal_operations_type() const;
void _internal_set_request_index(uint32_t value); void _internal_set_operations_type(uint32_t value);
public: public:
// @@protoc_insertion_point(class_scope:TDSCmd) // @@protoc_insertion_point(class_scope:TDSCmd)
...@@ -969,8 +981,9 @@ class TDSCmd final : ...@@ -969,8 +981,9 @@ class TDSCmd final :
uint32_t dst_suid_; uint32_t dst_suid_;
uint32_t src_suid_; uint32_t src_suid_;
uint32_t forward_flag_; uint32_t forward_flag_;
uint64_t request_index_;
uint32_t priority_; uint32_t priority_;
uint32_t request_index_; uint32_t operations_type_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
friend struct ::TableStruct_TDSCmd_2eproto; friend struct ::TableStruct_TDSCmd_2eproto;
}; };
...@@ -1287,27 +1300,47 @@ inline void TDSCmd::set_priority(uint32_t value) { ...@@ -1287,27 +1300,47 @@ inline void TDSCmd::set_priority(uint32_t value) {
// @@protoc_insertion_point(field_set:TDSCmd.priority) // @@protoc_insertion_point(field_set:TDSCmd.priority)
} }
// uint32 request_index = 6; // uint64 request_index = 6;
inline void TDSCmd::clear_request_index() { inline void TDSCmd::clear_request_index() {
request_index_ = 0u; request_index_ = uint64_t{0u};
} }
inline uint32_t TDSCmd::_internal_request_index() const { inline uint64_t TDSCmd::_internal_request_index() const {
return request_index_; return request_index_;
} }
inline uint32_t TDSCmd::request_index() const { inline uint64_t TDSCmd::request_index() const {
// @@protoc_insertion_point(field_get:TDSCmd.request_index) // @@protoc_insertion_point(field_get:TDSCmd.request_index)
return _internal_request_index(); return _internal_request_index();
} }
inline void TDSCmd::_internal_set_request_index(uint32_t value) { inline void TDSCmd::_internal_set_request_index(uint64_t value) {
request_index_ = value; request_index_ = value;
} }
inline void TDSCmd::set_request_index(uint32_t value) { inline void TDSCmd::set_request_index(uint64_t value) {
_internal_set_request_index(value); _internal_set_request_index(value);
// @@protoc_insertion_point(field_set:TDSCmd.request_index) // @@protoc_insertion_point(field_set:TDSCmd.request_index)
} }
// .google.protobuf.Timestamp ts = 7; // uint32 operations_type = 7;
inline void TDSCmd::clear_operations_type() {
operations_type_ = 0u;
}
inline uint32_t TDSCmd::_internal_operations_type() const {
return operations_type_;
}
inline uint32_t TDSCmd::operations_type() const {
// @@protoc_insertion_point(field_get:TDSCmd.operations_type)
return _internal_operations_type();
}
inline void TDSCmd::_internal_set_operations_type(uint32_t value) {
operations_type_ = value;
}
inline void TDSCmd::set_operations_type(uint32_t value) {
_internal_set_operations_type(value);
// @@protoc_insertion_point(field_set:TDSCmd.operations_type)
}
// .google.protobuf.Timestamp ts = 8;
inline bool TDSCmd::_internal_has_ts() const { inline bool TDSCmd::_internal_has_ts() const {
return this != internal_default_instance() && ts_ != nullptr; return this != internal_default_instance() && ts_ != nullptr;
} }
...@@ -1392,7 +1425,7 @@ inline void TDSCmd::set_allocated_ts(::PROTOBUF_NAMESPACE_ID::Timestamp* ts) { ...@@ -1392,7 +1425,7 @@ inline void TDSCmd::set_allocated_ts(::PROTOBUF_NAMESPACE_ID::Timestamp* ts) {
// @@protoc_insertion_point(field_set_allocated:TDSCmd.ts) // @@protoc_insertion_point(field_set_allocated:TDSCmd.ts)
} }
// repeated .google.protobuf.Any parameters = 8; // repeated .google.protobuf.Any parameters = 9;
inline int TDSCmd::_internal_parameters_size() const { inline int TDSCmd::_internal_parameters_size() const {
return parameters_.size(); return parameters_.size();
} }
......
...@@ -98,9 +98,11 @@ enum IID ...@@ -98,9 +98,11 @@ enum IID
IID_Server_TaskListSend_respond = 10424; IID_Server_TaskListSend_respond = 10424;
IID_Server_TaskListReceive = 10425; IID_Server_TaskListReceive = 10425;
IID_Server_TaskListReceive_respond = 10426; IID_Server_TaskListReceive_respond = 10426;
IID_Server_FileReceive = 10427; IID_Server_FileSend = 10427;
IID_Server_FileReceive_respond = 10428; IID_Server_FileSend_respond = 10428;
IID_Server_TaskExecAnalysisResult = 105; IID_Server_FileReceive = 10429;
IID_Server_FileReceive_respond = 10430;
IID_Server_TaskExecAnalysisResult = 10501;
IID_Server_TaskExecAnalysisResult_respond = 10502; IID_Server_TaskExecAnalysisResult_respond = 10502;
IID_Server_TaskExecList = 10503; IID_Server_TaskExecList = 10503;
IID_Server_TaskExecList_respond = 10504;//list IID_Server_TaskExecList_respond = 10504;//list
...@@ -258,12 +260,13 @@ message Heartbeat ...@@ -258,12 +260,13 @@ message Heartbeat
message TDSCmd message TDSCmd
{ {
IID interface_id = 1; IID interface_id = 1;
uint32 dst_suid = 2; uint32 dst_suid = 2;
uint32 src_suid = 3; uint32 src_suid = 3;
uint32 forward_flag = 4; uint32 forward_flag = 4;
uint32 priority = 5; //报文优先级 可以优先发送 uint32 priority = 5; //报文优先级 可以优先发送
uint32 request_index = 6; uint64 request_index = 6;
google.protobuf.Timestamp ts = 7; uint32 operations_type =7;
repeated google.protobuf.Any parameters = 8; google.protobuf.Timestamp ts = 8;
} repeated google.protobuf.Any parameters = 9;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment