/// <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> /// 报文方法 /// </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; }
public static Telegram Parse(string telegram) { Telegram tgm = new Telegram(); tgm.STX = telegram.Substring(0, 1); tgm.RequestFlag = byte.Parse(telegram.Substring(1, 1)); tgm.SequenceNo = telegram.Substring(2, 4); tgm.Receiver = telegram.Substring(6, 6); tgm.Sender = telegram.Substring(12, 6); //字串 tgm.TelegramData = telegram.Substring(18, telegram.Length-21); //对象 tgm.TelegramData1 = DataParse(tgm.TelegramData); tgm.CRC = telegram.Substring(telegram.Length - 3, 2); tgm.ETX = telegram.Substring(telegram.Length - 1, 1); 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> /// 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> /// 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> /// DUM指令 /// </summary> /// <param name="tgm"></param> /// <param name="tgd"></param> /// <returns></returns> public Telegram TelegramDUM(Telegram tgm, TelegramData tgd) { tgm.TelegramData = "DUM00000"; return tgm; }