/// <summary> /// CRQ指令 /// </summary> /// <param name="tgm"></param> /// <param name="tgd"></param> /// <returns></returns> public Telegram TelegramCRQ(Telegram tgm, TelegramData tgd) { tgm.TelegramData = "CRQ"; tgm.TelegramData += tgd.CraneNo; return tgm; }
/// <summary> /// STO指令 /// </summary> /// <param name="tgm"></param> /// <param name="tgd"></param> /// <returns></returns> public Telegram TelegramSTO(Telegram tgm, TelegramData tgd) { tgm.TelegramData = "STO"; tgm.TelegramData += tgd.CraneNo; return(tgm); }
/// <summary> /// CRQ指令 /// </summary> /// <param name="tgm"></param> /// <param name="tgd"></param> /// <returns></returns> public Telegram TelegramCRQ(Telegram tgm, TelegramData tgd) { tgm.TelegramData = "CRQ"; tgm.TelegramData += tgd.CraneNo; return(tgm); }
/// <summary> /// DER指令 /// </summary> /// <param name="tgm"></param> /// <param name="tgd"></param> /// <returns></returns> public Telegram TelegramDER(Telegram tgm, TelegramData tgd) { tgm.TelegramData = "DER"; tgm.TelegramData += tgd.CraneNo; tgm.TelegramData += tgd.AssignmentID; return(tgm); }
/// <summary> /// 报文方法 /// </summary> /// <param name="tgm">telegram</param> /// <param name="tgd">Application telegram data</param> /// <param name="tdd">TelegramDelegate传递方法名</param> public string DataFraming(string sequenceno ,TelegramData tgd, TelegramDataDelegate TelegramDelegate) { Telegram tgm = new Telegram(); //调用指令序号方法 tgm.RequestFlag = byte.Parse(sequenceno.Substring(0, 1)); tgm.SequenceNo = sequenceno.Substring(1, 4); tgm = TelegramDelegate(tgm, tgd); return tgm.ToString(); //发送报文 }
/// <summary> /// 报文方法 /// </summary> /// <param name="tgm">telegram</param> /// <param name="tgd">Application telegram data</param> /// <param name="tdd">TelegramDelegate传递方法名</param> public string DataFraming(string sequenceno, TelegramData tgd, TelegramDataDelegate TelegramDelegate) { Telegram tgm = new Telegram(); //调用指令序号方法 tgm.RequestFlag = byte.Parse(sequenceno.Substring(0, 1)); tgm.SequenceNo = sequenceno.Substring(1, 4); tgm = TelegramDelegate(tgm, tgd); return(tgm.ToString()); //发送报文 }
/// <summary> /// ARQ指令 /// </summary> /// <param name="tgm"></param> /// <param name="tgd"></param> /// <returns></returns> public Telegram TelegramARQ(Telegram tgm,TelegramData tgd) { tgm.TelegramData = "ARQ"; tgm.TelegramData += tgd.CraneNo; tgm.TelegramData += tgd.AssignmenID; tgm.TelegramData += tgd.AssignmentType; tgm.TelegramData += "00"; tgm.TelegramData += tgd.StartPosition; tgm.TelegramData += tgd.DestinationPosition; tgm.TelegramData += "REHIFUFU"; return tgm; }
/// <summary> /// ARQ指令 /// </summary> /// <param name="tgm"></param> /// <param name="tgd"></param> /// <returns></returns> public Telegram TelegramARQ(Telegram tgm, TelegramData tgd) { tgm.TelegramData = "ARQ"; tgm.TelegramData += tgd.CraneNo; tgm.TelegramData += tgd.AssignmentID; tgm.TelegramData += tgd.AssignmentType; tgm.TelegramData += "01"; tgm.TelegramData += tgd.StartPosition; tgm.TelegramData += tgd.DestinationPosition; tgm.TelegramData += "REHIFUFU"; return(tgm); }
/// <summary> /// Application telegram data解析 /// </summary> /// <param name="telegramData"></param> /// <returns></returns> public static TelegramData DataParse(string telegramData) { //指令类型 TelegramData tgd = new TelegramData(); string AssignmentType = telegramData.Substring(0, 3); tgd.TelegramType = (TelegramType)Enum.Parse(typeof(TelegramType), AssignmentType); tgd.CraneNo = telegramData.Substring(3, 2); tgd.AssignmentID = telegramData.Substring(5, 8); switch (AssignmentType) { case "ACK": tgd.FaultIndicator = telegramData.Substring(13, 1); tgd.SequenceNo = telegramData.Substring(14, 4); break; case "NCK": tgd.FaultIndicator = telegramData.Substring(13, 1); tgd.SequenceNo = telegramData.Substring(14, 4); break; case "ACP": tgd.CranePosition = telegramData.Substring(13, 12); tgd.RearForkLeft = telegramData.Substring(25, 2); tgd.RearForkRight = telegramData.Substring(27, 2); tgd.FrontForkLeft = telegramData.Substring(29, 2); tgd.FrontForkRight = telegramData.Substring(31, 2); tgd.ReturnCode = telegramData.Substring(33, 3); break; case "DEC": tgd.AssignmentID = telegramData.Substring(5, 8); tgd.ReturnCode = telegramData.Substring(13, 3); break; case "CSR": tgd.CraneMode = telegramData.Substring(13, 1); tgd.CranePosition = telegramData.Substring(14, 6); tgd.RearForkLeft = telegramData.Substring(20, 2); tgd.RearForkRight = telegramData.Substring(22, 2); tgd.FrontForkLeft = telegramData.Substring(24, 2); tgd.FrontForkRight = telegramData.Substring(26, 2); tgd.CurrentAisle = telegramData.Substring(28, 2); tgd.ReturnCode = telegramData.Substring(30, 3); break; } return(tgd); }
/// <summary> /// Application telegram data解析 /// </summary> /// <param name="telegramData"></param> /// <returns></returns> public static TelegramData DataParse(string telegramData) { //指令类型 TelegramData tgd = new TelegramData(); string AssignmentType = telegramData.Substring(0, 3); tgd.TelegramType = (TelegramType)Enum.Parse(typeof(TelegramType), AssignmentType); tgd.CraneNo = telegramData.Substring(3, 2); tgd.AssignmenID = telegramData.Substring(5, 8); switch (AssignmentType) { case "ACK": tgd.FaultIndicator = telegramData.Substring(13,1); tgd.SequenceNo = telegramData.Substring(14, 4); break; case "NCK": tgd.FaultIndicator = telegramData.Substring(13,1); tgd.SequenceNo = telegramData.Substring(14, 4); break; case "ACP": tgd.CranePosition = telegramData.Substring(13, 12); tgd.RearForkLeft = telegramData.Substring(25, 2); tgd.RearForkRight = telegramData.Substring(27, 2); tgd.FrontForkLeft = telegramData.Substring(29, 2); tgd.FrontForkRight = telegramData.Substring(31, 2); tgd.ReturnCode = telegramData.Substring(33, 3); break; case "DEC": tgd.ReturnCode = telegramData.Substring(13, 3); break; case "CSR": tgd.CraneMode = telegramData.Substring(13, 1); tgd.CranePosition = telegramData.Substring(14, 6); tgd.RearForkLeft = telegramData.Substring(20, 2); tgd.RearForkRight = telegramData.Substring(22, 2); tgd.FrontForkLeft = telegramData.Substring(24, 2); tgd.FrontForkRight = telegramData.Substring(26, 2); tgd.CurrentAisle = telegramData.Substring(28, 2); tgd.ReturnCode = telegramData.Substring(30, 3); break; } return tgd; }
/// <summary> /// STO指令 /// </summary> /// <param name="tgm"></param> /// <param name="tgd"></param> /// <returns></returns> public Telegram TelegramSTO(Telegram tgm, TelegramData tgd) { tgm.TelegramData = "STO"; tgm.TelegramData += tgd.CraneNo; return tgm; }
/// <summary> /// ACK指令 /// </summary> /// <param name="tgm"></param> /// <param name="tgd"></param> /// <returns></returns> public Telegram TelegramACK(Telegram tgm, TelegramData tgd) { tgm.TelegramData = "ACK0"; tgm.TelegramData += tgd.SequenceNo; return tgm; }
/// <summary> /// SYN指令 /// </summary> /// <param name="tgm"></param> /// <param name="tgd"></param> /// <returns></returns> public Telegram TelegramSYN(Telegram tgm, TelegramData tgd) { tgm.TelegramData = "SYN00000"; return tgm; }
/// <summary> /// DER指令 /// </summary> /// <param name="tgm"></param> /// <param name="tgd"></param> /// <returns></returns> public Telegram TelegramDER(Telegram tgm, TelegramData tgd) { tgm.TelegramData = "DER"; tgm.TelegramData += tgd.CraneNo; tgm.TelegramData += tgd.AssignmenID; return tgm; }
/// <summary> /// SYN指令 /// </summary> /// <param name="tgm"></param> /// <param name="tgd"></param> /// <returns></returns> public Telegram TelegramSYN(Telegram tgm, TelegramData tgd) { tgm.TelegramData = "SYN00000"; return(tgm); }
/// <summary> /// ACK指令 /// </summary> /// <param name="tgm"></param> /// <param name="tgd"></param> /// <returns></returns> public Telegram TelegramACK(Telegram tgm, TelegramData tgd) { tgm.TelegramData = "ACK0"; tgm.TelegramData += tgd.SequenceNo; return(tgm); }
/// <summary> /// DUM指令 /// </summary> /// <param name="tgm"></param> /// <param name="tgd"></param> /// <returns></returns> public Telegram TelegramDUM(Telegram tgm, TelegramData tgd) { tgm.TelegramData = "DUM00000"; return(tgm); }
/// <summary> /// DUM指令 /// </summary> /// <param name="tgm"></param> /// <param name="tgd"></param> /// <returns></returns> public Telegram TelegramDUM(Telegram tgm, TelegramData tgd) { tgm.TelegramData = "DUM00000"; return tgm; }