Commit b2af52f6 by xjp0422

Heartmessage ReportLog

parent 48f9702c
No preview for this file type
......@@ -84,6 +84,7 @@
<ItemGroup>
<Compile Include="AGITopic.cs" />
<Compile Include="ModAgi.cs" />
<Compile Include="OAMDatastruct.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tdscmd.cs" />
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -64,7 +64,30 @@ namespace Mqtt_AGI
Console.WriteLine("MqttclientId:" + clientId);
//Console.WriteLine(Convert.ToString(subTopic,2).PadLeft(32,'0'));//32位 前面补0
}
static void heart_thread() {
//初始化包配置
while (true)
{
Heartbeat heartbeat = new Heartbeat();
heartbeat.Suid = Convert.ToUInt32(SerializeUid.SerilizeUid(LevelUid, systemID.AGI), 2);
heartbeat.IidList.Add(IID.AgiReport);
heartbeat.IidList.Add(IID.AgiReportRespond);
heartbeat.IidList.Add(IID.AgiTle);
heartbeat.IidList.Add(IID.AgiTleRespond);
TDSCmd MessageHeart = new TDSCmd();
MessageHeart.InterfaceId = IID.OamHeartBeatRx;
MessageHeart.DstSuid = Convert.ToUInt32(SerializeUid.SerilizeUid(LevelUid, systemID.OAM), 2);
MessageHeart.SrcSuid = Convert.ToUInt32(SerializeUid.SerilizeUid(LevelUid, systemID.AGI), 2);
MessageHeart.ForwardFlag = 0;//不需要转发
MessageHeart.Ts = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(DateTime.UtcNow);
//加载数据段
Any Parameter = Any.Pack(heartbeat);
MessageHeart.Parameters.Add(Parameter);
client.Publish(SerializeUid.SerilizeTopic(LevelTopic, systemID.OAM), MessageHeart.ToByteArray());
Thread.Sleep(1000 * 10);
}
}
static void client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e)
{
......@@ -165,8 +188,7 @@ namespace Mqtt_AGI
// Application.EnableVisualStyles();
// Application.SetCompatibleTextRenderingDefault(false);
// Application.Run(new Form1());
try
try
{
Level_Topic_Uid_init();
//从配置文件获取ip port
......@@ -184,7 +206,10 @@ namespace Mqtt_AGI
client.MqttMsgPublishReceived += client_MqttMsgPublishReceived;
//断线重连
client.ConnectionClosed += client_MqttConnectionClosed;
}
Thread thread = new Thread(heart_thread);
thread.Start();
Console.WriteLine("Heart thread start");
}
catch (Exception ex)
{
// continue;
......@@ -253,7 +278,7 @@ namespace Mqtt_AGI
client.Publish(SerializeUid.SerilizeTopic(LevelTopic, systemID.SERVER), MessageSend.ToByteArray());
Console.WriteLine("send topic:"+ SerializeUid.SerilizeTopic(LevelTopic, systemID.SERVER));
Console.WriteLine("Tle send topic:"+ SerializeUid.SerilizeTopic(LevelTopic, systemID.SERVER));
Console.WriteLine("pacakge length:" + MessageSend.ToByteArray().Length);
Console.WriteLine("Sucess send count:" + (++count));
Console.WriteLine("Content:" + MessageSend);
......@@ -570,28 +595,51 @@ namespace Mqtt_AGI
}
//protobuf begin
//初始化包配置
TDSCmd MessageSend = new TDSCmd();
MessageSend.InterfaceId = IID.AgiReportRespond;
MessageSend.DstSuid = Convert.ToUInt32(SerializeUid.SerilizeUid(LevelUid, systemID.SERVER),2);
MessageSend.SrcSuid = Convert.ToUInt32(SerializeUid.SerilizeUid(LevelUid, systemID.AGI),2);
MessageSend.ForwardFlag = 0;//不需要转发
TDSCmd MessageReport = new TDSCmd();
MessageReport.InterfaceId = IID.AgiReportRespond;
MessageReport.DstSuid = Convert.ToUInt32(SerializeUid.SerilizeUid(LevelUid, systemID.SERVER),2);
MessageReport.SrcSuid = Convert.ToUInt32(SerializeUid.SerilizeUid(LevelUid, systemID.AGI),2);
MessageReport.ForwardFlag = 0;//不需要转发
MessageReport.Ts = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(DateTime.UtcNow);
//加载数据段
Any Parameter = Any.Pack(CalcReport);
MessageSend.Parameters.Add(Parameter);
MessageReport.Parameters.Add(Parameter);
client.Publish(SerializeUid.SerilizeTopic(LevelTopic, systemID.SERVER), MessageSend.ToByteArray());
//protobuf end
client.Publish(SerializeUid.SerilizeTopic(LevelTopic, systemID.SERVER), MessageReport.ToByteArray());
//CalcRetJson.Add("tasks", ReportArray);
Console.WriteLine("send topic:" + SerializeUid.SerilizeTopic(LevelTopic, systemID.SERVER));
Console.WriteLine("pacakge length:"+ MessageSend.ToByteArray().Length);
Console.WriteLine("Report send topic:" + SerializeUid.SerilizeTopic(LevelTopic, systemID.SERVER));
Console.WriteLine("Report pacakge length:" + MessageReport.ToByteArray().Length);
//client.Publish("server/response/agi/json", System.Text.Encoding.Default.GetBytes(CalcRetJson.ToString())); //将任务星下点信息发布出去
Console.WriteLine("Sucess send count:" + (++count));
Console.WriteLine("Content:" + MessageSend);
Console.WriteLine("Content:" + MessageReport);
//Console.WriteLine(CalcRetJson.ToString());
//日志包
TDSCmd MessageLog = new TDSCmd();
Log log = new Log();
log.StationID = Convert.ToUInt32(SerializeUid.SerilizeUid(LevelUid, systemID.AGI), 2);
log.LogInfoCHN = line0;
log.LogInfoENG = line0;
log.Loglevel = LogLevel.Normal;
log.Manipunator = "system";
log.ReportTime = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(DateTime.UtcNow);
MessageLog.InterfaceId = IID.OamLogRx;
MessageLog.DstSuid = Convert.ToUInt32(SerializeUid.SerilizeUid(LevelUid, systemID.OAM), 2);
MessageLog.SrcSuid = Convert.ToUInt32(SerializeUid.SerilizeUid(LevelUid, systemID.AGI), 2);
MessageLog.Ts= Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(DateTime.UtcNow);
Any Logs = Any.Pack(log);
MessageLog.Parameters.Add(Logs);
client.Publish(SerializeUid.SerilizeTopic(LevelTopic, systemID.OAM), MessageLog.ToByteArray());
//protobuf end
Console.WriteLine("Log send topic:" + SerializeUid.SerilizeTopic(LevelTopic, systemID.OAM));
Console.WriteLine("Log pacakge length:" + MessageLog.ToByteArray().Length);
//client.Publish("server/response/agi/json", System.Text.Encoding.Default.GetBytes(CalcRetJson.ToString())); //将任务星下点信息发布出去
Console.WriteLine("Content:" + MessageLog);
//Console.WriteLine(CalcRetJson.ToString());
}
catch (Exception e)
{
......
dc8766d0c3caf9d64c8ee1044151fbc91b8aab4f
a360f56c7f9b6fa1faebc1d0938ef3026a2df3db

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.4
# Visual Studio Version 16
VisualStudioVersion = 16.0.32602.291
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mqtt_AGI", "Kepler_J20002TLE\Mqtt_AGI.csproj", "{D810F35A-990A-476B-85DB-394DFF6F4962}"
EndProject
......@@ -19,4 +19,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6910A09F-B004-43BC-A4A9-3756969B220B}
EndGlobalSection
EndGlobal
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
* @file OAM_datastruct.proto
* @brief TDSCmd define
* @author YueWang
* @version 1.0
* @date 2022-09-23
*/
syntax = "proto3";
//import "google/protobuf/any.proto";
option go_package = "../protogo";
import "google/protobuf/timestamp.proto";
import "TDSCmd.proto";
//alrm level
enum Level{
Defaul_Level = 0; //告警级别非下列两种时为0
Normal_Alarm = 1;
Critical_Alarm = 2;
}
//log level
enum LogLevel{
Default_LogLevel = 0; //log级别非下列三种时为0
Normal = 1;
Warning = 2;
Error = 3;
}
enum OperandType {
_DEFAULT = 0; //数值不是下列几种情况时,为0
_UINT = 1;
_INT = 2;
_STRING = 3;
_FLOAT = 4;
_DOUBLE = 5;
}
// operator
enum Operator{
Default_Operator = 0; //操作符为空时,Default_Operator为0
GreaterThan = 1;
GreaterThanOrEqualTo = 2;
EqualTo = 3;
LessThan = 4;
LessThanOrEqualTo = 5;
NotEqualTo = 6;
}
enum RelationOperator {
Default_RelationOperator = 0; //关系符为空时,Default_RelationOperator为0
AND = 1;
OR = 2;
}
//message return back to device when OAM receive the alarm info from device
message DeviceRet{
uint32 AlarmID = 1;//这个就OAM会用到
uint32 StationID = 2;
uint32 DeviceID = 3;
CodeValue CodeRet = 4;
string Message = 5;
}
//normal message respond back to UI OR Lower OAM
message Respond{
CodeValue CodeRet = 1;
string Message = 2;
}
//StationID is SUID of device,DeviceID is the sub device
message StationDevID{
uint32 StationID = 1;
uint32 DeviceID = 2;
}
//alarm attribution
message AlarmAttri
{
uint32 Id = 1;
uint32 AlarmID = 2;
Level AlarmLevel = 3;
string AlarmDescriptionCHN = 4;
string AlarmDescriptionENG = 5;
uint32 IsMon = 6;
google.protobuf.Timestamp CreateTime = 7;
}
//performance attribution
message PerAttri
{
uint32 Id = 1;
uint32 PerID = 2;
string DataCatlog = 3;
string FieldName = 4;
string PerDescriptionCHN = 5;
string PerDescriptionENG = 6;
OperandType FieldType = 7;
string FieldUnit = 8;
Operator Operator1 = 9;
string Operand1 = 10;
RelationOperator Relation = 11;
Operator Operator2 = 12;
string Operand2 = 13;
uint32 IsMon = 14;
Level PerAlarmLevel = 15;
string AlarmDesCHN = 16;
string AlarmDesENG = 17;
google.protobuf.Timestamp CreateTime = 18;
}
//current alarm
message CurrAlarm
{
uint32 Id = 1;
uint32 AlarmID = 2;
uint32 StationID = 3;
uint32 DeviceID = 4;
Level AlarmLevel = 5;
string AlarmDescriptionCHN = 6;
string AlarmDescriptionENG = 7;
google.protobuf.Timestamp ReportTime = 8;
}
// history of alarm
message HisAlarm
{
uint32 Id = 1;
uint32 AlarmID = 2;
uint32 StationID = 3;
uint32 DeviceID = 4;
Level AlarmLevel = 5;
string AlarmDescriptionCHN = 6;
string AlarmDescriptionENG = 7;
google.protobuf.Timestamp StartTime = 8;
google.protobuf.Timestamp EndTime = 9;
}
message SysStatus
{
uint32 StationID = 1;
uint32 DeviceID = 2;
Devistatus Status = 3;
google.protobuf.Timestamp ReportTime = 4;
}
message Log{
uint32 StationID = 1;
uint32 DeviceID = 2;
LogLevel Loglevel = 3;
string LogInfoCHN = 4;
string LogInfoENG = 5;
string Manipunator = 6;
google.protobuf.Timestamp ReportTime = 7 ;
}
message PerInfo{
uint32 Id = 1;
uint32 PerID = 2;
uint32 StationID = 3;
uint32 DeviceID = 4;
string DataCatlog = 5;
string FieldName = 6;
string FieldValue = 7;
string PerDescriptionCHN = 8;
string PerDescriptionENG = 9;
google.protobuf.Timestamp UpdateTime = 10 ;
}
message PerRequire{
string DataCatlog = 1;
string FieldName = 2;
uint32 IsMon = 3;
}
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: tdscmd.proto
// source: TDSCmd.proto
#ifndef GOOGLE_PROTOBUF_INCLUDED_tdscmd_2eproto
#define GOOGLE_PROTOBUF_INCLUDED_tdscmd_2eproto
#ifndef GOOGLE_PROTOBUF_INCLUDED_TDSCmd_2eproto
#define GOOGLE_PROTOBUF_INCLUDED_TDSCmd_2eproto
#include <limits>
#include <string>
......@@ -38,7 +38,7 @@
#include <google/protobuf/timestamp.pb.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
#define PROTOBUF_INTERNAL_EXPORT_tdscmd_2eproto
#define PROTOBUF_INTERNAL_EXPORT_TDSCmd_2eproto
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
......@@ -46,10 +46,10 @@ class AnyMetadata;
PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct TableStruct_tdscmd_2eproto {
struct TableStruct_TDSCmd_2eproto {
static const uint32_t offsets[];
};
extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_tdscmd_2eproto;
extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_TDSCmd_2eproto;
class Heartbeat;
struct HeartbeatDefaultTypeInternal;
extern HeartbeatDefaultTypeInternal _Heartbeat_default_instance_;
......@@ -185,6 +185,8 @@ enum IID : int {
IID_Server_MoreSettingDataSet_respond = 10608,
IID_Server_MoreSettingDataDel = 10609,
IID_Server_MoreSettingDataDel_respond = 10610,
IID_Server_MoreSettingRestoreDefault = 10611,
IID_Server_MoreSettingRestoreDefault_respond = 10612,
IID_Server_Login = 10701,
IID_Server_Login_respond = 10702,
IID_Server_UserCreate = 10703,
......@@ -205,11 +207,11 @@ enum IID : int {
IID_Device_Xpro_TX_cmd_respond = 30004,
IID_Device_Xpro_RX_cmd = 30005,
IID_Device_Xpro_RX_cmd_respond = 30006,
IID_AGI_Base = 4000,
IID_AGI_TLE = 4001,
IID_AGI_TLE_respond = 4002,
IID_AGI_Report = 4003,
IID_AGI_Report_respond = 4004,
IID_AGI_Base = 40000,
IID_AGI_TLE = 40001,
IID_AGI_TLE_respond = 40002,
IID_AGI_Report = 40003,
IID_AGI_Report_respond = 40004,
IID_OAM_Base = 50000,
IID_OAM_HeartBeat_RX = 50001,
IID_OAM_LOG_RX = 50003,
......@@ -519,7 +521,7 @@ class TestParams final :
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr key_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr value_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
friend struct ::TableStruct_tdscmd_2eproto;
friend struct ::TableStruct_TDSCmd_2eproto;
};
// -------------------------------------------------------------------
......@@ -542,7 +544,7 @@ public:
static bool ValidateValue(void*) { return true; }
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
friend struct ::TableStruct_tdscmd_2eproto;
friend struct ::TableStruct_TDSCmd_2eproto;
};
// -------------------------------------------------------------------
......@@ -732,7 +734,7 @@ class Heartbeat final :
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_ENUM> dev_status_;
uint32_t suid_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
friend struct ::TableStruct_tdscmd_2eproto;
friend struct ::TableStruct_TDSCmd_2eproto;
};
// -------------------------------------------------------------------
......@@ -970,7 +972,7 @@ class TDSCmd final :
uint32_t priority_;
uint32_t request_index_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
friend struct ::TableStruct_tdscmd_2eproto;
friend struct ::TableStruct_TDSCmd_2eproto;
};
// ===================================================================
......@@ -1473,4 +1475,4 @@ PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_tdscmd_2eproto
#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_TDSCmd_2eproto
......@@ -116,10 +116,9 @@ enum IID
IID_Server_MoreSettingDataSet_respond = 10608;
IID_Server_MoreSettingDataDel = 10609;
IID_Server_MoreSettingDataDel_respond = 10610;
// IID_Server_MoreSettingSend = 10611;
// IID_Server_MoreSettingSend_respond = 10612;
// IID_Server_MoreSettingReceive = 10613;
// IID_Server_MoreSettingReceive_respond = 10614;
IID_Server_MoreSettingRestoreDefault = 10611;
IID_Server_MoreSettingRestoreDefault_respond = 10612;
// user action
IID_Server_Login = 10701;
IID_Server_Login_respond = 10702;//data
......@@ -146,11 +145,11 @@ enum IID
IID_Device_Xpro_RX_cmd_respond = 30006; //用不上
//====================== AGI =============================
IID_AGI_Base=4000;
IID_AGI_TLE=4001;
IID_AGI_TLE_respond=4002;
IID_AGI_Report=4003;
IID_AGI_Report_respond=4004;
IID_AGI_Base=40000;
IID_AGI_TLE=40001;
IID_AGI_TLE_respond=40002;
IID_AGI_Report=40003;
IID_AGI_Report_respond=40004;
//====================== OAM =============================
IID_OAM_Base = 50000;
......
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