Commit 931ab859 by xjp0422

no message

parent 2de43ab6
No preview for this file type
......@@ -30,12 +30,16 @@ namespace Mqtt_AGI
class SerializeUid
{
//生成对应系统 模块序列号
public static string SerilizeString(uint level1, uint level2, uint level3)
public static string Serilize_Init_Level_Uid(uint level1, uint level2, uint level3)
{
uint numtopic = 0;
numtopic = numtopic | (level1 << 28) | (level2 << 24) | (level3 << 20);
return Convert.ToString(numtopic, 2).PadLeft(32, '0');//uint转string 32位 前面补0
}
public static string Serilize_Init_Level_Topic(uint level1, uint level2, uint level3)
{
return "/" + Convert.ToUInt32(level1.ToString()) + "/" + Convert.ToUInt32(level2.ToString()) + "/" + Convert.ToUInt32(level3.ToString());
}
//由level_uid生成level_system_uid 和
public static string SerilizeTopic(string level_uid, systemID system)
......
......@@ -38,15 +38,15 @@ namespace Mqtt_AGI
//[DllImport("kernel32")]
//private static extern long WritePrivateProfileString(string section, string key, string value, string filePath);
//private static extern long WritePrivateProfileString(string section, string key, string value, string filePath);\
//win32 API 获取ini文件内容
[DllImport("kernel32")]
private static extern long GetPrivateProfileString(string section, string key, string defa, StringBuilder buffer, int size, string filePath);
static MqttClient client = null; //主机为IP时
//static string clientId = Guid.NewGuid().ToString();
static string ip, port;
static int count = 0;
static string LevelUid, LevelTopic;
static string clientId;
static string LevelUid, LevelTopic,clientId;
//获取配置信息中的站点等级信息 生成LevelUid
static void Level_Topic_Uid_init()
{
......@@ -58,8 +58,8 @@ namespace Mqtt_AGI
GetPrivateProfileString("role", "level2", "0", level2, 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())));
LevelTopic= "/" +Convert.ToUInt32(level1.ToString())+"/" +Convert.ToUInt32(level2.ToString())+ "/"+Convert.ToUInt32(level3.ToString());
LevelUid = 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()));
LevelUid = SerializeUid.Serilize_Init_Level_Uid(Convert.ToUInt32(level1.ToString()) , Convert.ToUInt32(level2.ToString()) , Convert.ToUInt32(level3.ToString()));
clientId = SerializeUid.SerilizeUid(LevelUid, systemID.AGI);
Console.WriteLine("MqttclientId:" + clientId);
//Console.WriteLine(Convert.ToString(subTopic,2).PadLeft(32,'0'));//32位 前面补0
......
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