public override string ToString() { try { StringBuilder sb = new StringBuilder(); sb.Append("【" + EnumUtils.GetDescription(typeof(WaterBaseProtocol.AFN), AFN) + "】:"); sb.Append("【流水号】:" + SerialNumber + ","); sb.Append("【发报时间】:" + SendTime.ToString("yyyy-MM-dd HH:mm:ss") + ","); return(sb.ToString().TrimEnd(',')); } catch { return("【" + EnumUtils.GetDescription(typeof(WaterBaseProtocol.AFN), AFN) + "】:" + " ToString error"); } }
public string WriteMsg() { UserData = ""; UserData += SerialNumber.ToString("X").PadLeft(4, '0'); UserData += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); foreach (Identifier iden in List_Identifier) { if (iden != null) { UserData += iden.GetHexStrHead(); } } UserDataBytes = HexStringUtility.HexStringToByteArray(UserData); return(WriteMsgBase()); }
public string WriteMsg() { if (Values == null || Values.Length != 12) { return("雨量预警阈值读取非法!"); } UserDataAll = ""; UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0'); UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); UserDataAll += "01"; UserDataAll += Values[0].ToString("X").PadLeft(2, '0'); UserDataAll += Values[1].ToString("X").PadLeft(2, '0'); UserDataAll += Values[2].ToString("X").PadLeft(2, '0'); UserDataAll += "03"; UserDataAll += Values[3].ToString("X").PadLeft(2, '0'); UserDataAll += Values[4].ToString("X").PadLeft(2, '0'); UserDataAll += Values[5].ToString("X").PadLeft(2, '0'); UserDataAll += "06"; UserDataAll += Values[6].ToString("X").PadLeft(2, '0'); UserDataAll += Values[7].ToString("X").PadLeft(2, '0'); UserDataAll += Values[8].ToString("X").PadLeft(2, '0'); UserDataAll += "12"; UserDataAll += Values[9].ToString("X").PadLeft(2, '0'); UserDataAll += Values[10].ToString("X").PadLeft(2, '0'); UserDataAll += Values[11].ToString("X").PadLeft(2, '0'); byte[] UserDataBytesAllTmp; WaterBaseMessage[] MsgListTmp; string msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp); if (msg == "") { UserDataBytesAll = UserDataBytesAllTmp; MsgList = MsgListTmp; } else { if (ShowLog) { logHelper.Error(msg); } } return(msg); }
public string WriteMsg() { UserData = ""; UserData += SerialNumber.ToString("X").PadLeft(4, '0'); UserData += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); foreach (RTUParam rp in List_RTUParam) { string HexStr = rp.GetHexStr(); if (HexStr.Length >= 4) { UserData += rp.GetHexStr(); } } UserDataBytes = HexStringUtility.HexStringToByteArray(UserData); return(WriteMsgBase()); }
public string WriteMsg() { UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0'); UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); UserDataAll += Iden_F1.GetHexStr(); int count = (Ps.Length - 1) / 8 + 1; UserData += Ps.Length.ToString("X").PadLeft(2, '0'); string s = ""; for (int i = 0; i < Ps.Length; i++) { if (Ps[i]) { s = "1" + s; } else { s = "0" + s; } } s = s.PadLeft(8 * ((count - 1) / 8 + 1), '0'); UserData += HexStringUtility.BinStringToHexString(s); byte[] UserDataBytesAllTmp; WaterBaseMessage[] MsgListTmp; string msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp); if (msg == "") { UserDataBytesAll = UserDataBytesAllTmp; MsgList = MsgListTmp; } else { if (ShowLog) { logHelper.Error(msg); } } return(msg); }
public override string ToString() { try { // string RTypeStr = "未知" + ; //if (RType == 1) RTypeStr = "雨量站"; //else if (RType == 2) RTypeStr = "水位站"; //else if (RType == 3) RTypeStr = "雨量水位站"; StringBuilder sb = new StringBuilder(); sb.Append("【" + EnumUtils.GetDescription(typeof(WaterBaseProtocol.AFN), AFN) + "】:"); sb.Append("【流水号】:" + SerialNumber + ","); sb.Append("【发报时间】:" + SendTime.ToString("yyyy-MM-dd HH:mm:ss") + ","); // sb.Append("【遥测站类型】:" + RTypeStr + ","); // sb.Append("【是否发送短信】:" + (IsSend == 1 ? "发送" : "不发") + ","); return(sb.ToString().TrimEnd(',')); } catch { return("【" + EnumUtils.GetDescription(typeof(WaterBaseProtocol.AFN), AFN) + "】:" + " ToString error"); } }
public string WriteMsg() { if (Phone.Trim().Length > 11) { return("预警责任人号码修改非法!"); } if (Phone.Trim() != "" && Tools.GetTest(Phone.Trim()) != "数字") { return("预警责任人号码修改非法!"); } UserData = ""; UserData += SerialNumber.ToString("X").PadLeft(4, '0'); UserData += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); UserData += OrderNum.ToString("X").PadLeft(2, '0'); UserData += HexStringUtility.StrToHexString(Phone.Trim()); UserDataBytes = HexStringUtility.HexStringToByteArray(UserData); return(WriteMsgBase()); }
public string WriteMsg() { UserData = ""; UserData += SerialNumber.ToString("X").PadLeft(4, '0'); UserData += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); if (PlayCount < 1) { PlayCount = 1; } if (PlayCount > 255) { PlayCount = 255; } UserData += PlayCount.ToString("X").PadLeft(2, '0'); if (PlayRole < 1) { PlayRole = 1; } if (PlayRole > 15) { PlayRole = 15; } if (PlaySpeed < 1) { PlaySpeed = 1; } if (PlaySpeed > 15) { PlaySpeed = 15; } UserData += PlaySpeed.ToString("X") + PlayRole.ToString("X"); if (PlayContext.Length > 400) { PlayContext = PlayContext.Substring(0, 400); } UserData += HexStringUtility.StrToHexString(PlayContext.Trim()); UserDataBytes = HexStringUtility.HexStringToByteArray(UserData); return(WriteMsgBase()); }
public string WriteMsg() { UserData = ""; UserData += SerialNumber.ToString("X").PadLeft(4, '0'); UserData += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); int count = Ps.Length < PsOpen.Length ? Ps.Length : PsOpen.Length; UserData += count.ToString("X").PadLeft(2, '0'); string s = ""; for (int i = 0; i < count; i++) { if (Ps[i]) { s = "1" + s; } else { s = "0" + s; } } s = s.PadLeft(8 * ((count - 1) / 8 + 1), '0'); UserData += HexStringUtility.BinStringToHexString(s); for (int i = 0; i < count; i++) { if (PsOpen[i] <= 9999) { UserData += PsOpen[i].ToString().PadLeft(4, '0'); } else if (PsOpen[i] > 9999) { UserData += PsOpen[i].ToString().Substring(PsOpen[i].ToString().Length - 4); } } UserDataBytes = HexStringUtility.HexStringToByteArray(UserData); return(WriteMsgBase()); }
public override string ToString() { try { StringBuilder sb = new StringBuilder(); sb.Append("【" + EnumUtils.GetDescription(typeof(WaterBaseProtocol.AFN), AFN) + "】:"); sb.Append("【流水号】:" + SerialNumber + ","); sb.Append("【发报时间】:" + SendTime.ToString("yyyy-MM-dd HH:mm:ss") + ","); if (List_Identifier != null && List_Identifier.Count > 0) { foreach (Identifier iden in List_Identifier) { sb.Append(iden.ToString()); } } return(sb.ToString().TrimEnd(',')); } catch { return("【" + EnumUtils.GetDescription(typeof(WaterBaseProtocol.AFN), AFN) + "】:" + " ToString error"); } }
public override string ToString() { try { StringBuilder sb = new StringBuilder(); sb.Append("【" + EnumUtils.GetDescription(typeof(WaterBaseProtocol.AFN), AFN) + "】:"); sb.Append("【流水号】:" + SerialNumber + ","); sb.Append("【发报时间】:" + SendTime.ToString("yyyy-MM-dd HH:mm:ss") + ","); sb.Append("【遥测终端】:" + Iden_F1.ToString() + ","); if (Ps != null && Ps.Length > 0) { for (int i = 0; i < Ps.Length; i++) { sb.Append("【" + (i + 1) + "号泵】:" + (Ps[i] ? "开" : "关") + ","); } } return(sb.ToString().TrimEnd(',')); } catch { return("【" + EnumUtils.GetDescription(typeof(WaterBaseProtocol.AFN), AFN) + "】:" + " ToString error"); } }
public override string ToString() { try { StringBuilder sb = new StringBuilder(); sb.Append("【" + EnumUtils.GetDescription(typeof(WaterBaseProtocol.AFN), AFN) + "】:"); sb.Append("【流水号】:" + SerialNumber + ","); sb.Append("【发报时间】:" + SendTime.ToString("yyyy-MM-dd HH:mm:ss") + ","); if (iden_F2 != null) { sb.Append("【数据内容】:" + HexStringUtility.HexStringToStr(iden_F2.Content) + ","); } else { sb.Append("数据解析失败!"); } return(sb.ToString().TrimEnd(',')); } catch { return("【" + EnumUtils.GetDescription(typeof(WaterBaseProtocol.AFN), AFN) + "】:" + " ToString error"); } }
public string WriteMsg() { UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0'); UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); byte[] UserDataBytesAllTmp; WaterBaseMessage[] MsgListTmp; string msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp); if (msg == "") { UserDataBytesAll = UserDataBytesAllTmp; MsgList = MsgListTmp; } else { if (ShowLog) { logHelper.Error(msg); } } return(msg); }
public string WriteMsg() { if (Iden_04 == null) { return("时间步长码出错"); } UserDataAll = ""; UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0'); UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); /* * UserDataAll += HexStringUtility.ByteArrayToHexString(new byte[] { 0xF1, 0xF1 }); * UserDataAll += RemoteStation.PadLeft(10, '0'); * UserDataAll += StationType.ToString("X").PadLeft(2, '0'); * */ UserDataAll += Iden_F1.GetHexStr(); /* * UserDataAll += HexStringUtility.ByteArrayToHexString(new byte[] { 0xF0, 0xF0 }); * UserDataAll += ObsTime.ToString("yyMMddHHmm").PadLeft(10, '0'); * */ UserDataAll += Iden_F0.GetHexStr(); UserDataAll += Iden_04.GetHexStr(); if (Idens != null && Idens.Count > 0) { UserDataAll += Idens[0].GetHexStrHead(); if (Idens[0].GetKey() != (byte)Identifier_Standard._FF) { foreach (Identifier obj in Idens) { UserDataAll += obj.GetHexStr().Substring(4); } } else { foreach (Identifier obj in Idens) { UserDataAll += obj.GetHexStr().Substring(6); } } } else { return("无有效数据"); } byte[] UserDataBytesAllTmp; WaterBaseMessage[] MsgListTmp; string msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp); if (msg == "") { UserDataBytesAll = UserDataBytesAllTmp; MsgList = MsgListTmp; } else { if (ShowLog) { logHelper.Error(msg); } } return(msg); }
public override string ToString() { try { return("【" + EnumUtils.GetDescription(typeof(WaterBaseProtocol.AFN), AFN) + "】:" + "【流水号】:" + SerialNumber + ",【发报时间】:" + SendTime.ToString("yyyy-MM-dd HH:mm:ss")); } catch { return("【" + EnumUtils.GetDescription(typeof(WaterBaseProtocol.AFN), AFN) + "】:" + " ToString error"); } }
public string WriteMsg() { UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0'); UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); UserDataBytesAll = HexStringUtility.HexStringToByteArray(UserDataAll); DataBeginChar = (byte)WaterBaseProtocol.DataBeginChar.STX; if (UserDataBytesAll.Length > WaterBaseProtocol.PocketSize) { TotalPackage = (UserDataBytesAll.Length - 1) / WaterBaseProtocol.PocketSize + 1; DataBeginChar = (byte)WaterBaseProtocol.DataBeginChar.SYN; } else { TotalPackage = 1; } MsgList = new WaterBaseMessage[TotalPackage]; for (int i = 0; i < TotalPackage; i++) { WaterBaseMessage bm = new WaterBaseMessage(); bm.CenterStation = this.CenterStation; bm.RemoteStation = this.RemoteStation; bm.PW = this.PW; bm.AFN = this.AFN; bm.UpOrDown = this.UpOrDown; bm.TotalPackage = this.TotalPackage; bm.CurrentPackage = i + 1; bm.DataBeginChar = this.DataBeginChar; byte[] bs = null; if (i == TotalPackage - 1) { bs = new byte[UserDataBytesAll.Length - WaterBaseProtocol.PocketSize * i]; DataEndChar = (byte)WaterBaseProtocol.DataEndChar_Up.ETX; } else { bs = new byte[WaterBaseProtocol.PocketSize]; DataEndChar = (byte)WaterBaseProtocol.DataEndChar_Up.ETB; } bm.DataEndChar = this.DataEndChar; Array.Copy(UserDataBytesAll, WaterBaseProtocol.PocketSize * i, bs, 0, bs.Length); bm.UserDataBytes = bs; //bm.UserData = HexStringUtility.ByteArrayToHexString(bs); string msg = bm.WriteMsgBase(); if (msg == "") { MsgList[i] = bm; } else { MsgList = null; if (ShowLog) { logHelper.Error((i + 1) + ":" + msg); } return((i + 1) + ":" + msg); } } return(""); }
void OnGUI() { AscensionNetworkInternal.DebugDrawer.IsEditor(false); { Rect r = new Rect(10, Screen.height - 30, Screen.width - 20, 20); DrawBackground(r); r.xMin += 5; r.yMin += 5; GUILayout.BeginArea(r); GUILayout.BeginHorizontal(); GUILayout.Label("Ascension Performance: ", LabelStyleBold); string pollTime = PollTime.ToString().PadLeft(3, '0'); string sendTime = SendTime.ToString().PadLeft(3, '0'); //GUILayout.Label("Send: " + System.Math.Round(Core.SendTime.TotalMilliseconds, 2)); //GUILayout.Label("Auto: " + System.Math.Round(Core.AutoscopeTime.TotalMilliseconds, 2)); //GUILayout.Label("Poll: " + System.Math.Round(Core.PollNetworkTime.TotalMilliseconds, 2)); //GUILayout.Label("Callbacks: " + System.Math.Round(Core.InvokeRemoteSceneCallbacksTime.TotalMilliseconds, 2)); //GUILayout.Label("StepLocal: " + System.Math.Round(Core.SimulateLocalAndControlledEntitiesTime.TotalMilliseconds, 2)); //GUILayout.Label("Step: " + System.Math.Round(Core.StepNonControlledRemoteEntitiesTime.TotalMilliseconds, 2)); //GUILayout.Label("Adjust: " + System.Math.Round(Core.AdjustEstimatedRemoteFramesTime.TotalMilliseconds, 2)); GUILayout.Label(string.Format("Poll {0} ms", pollTime), LabelStyleColor(GetColor(PollTime, 16))); GUILayout.Label(string.Format("Send {0} ms", sendTime), LabelStyleColor(GetColor(SendTime, 16))); GUILayout.Label(string.Format("Active Entities {0}", Core.entities.Count(x => !x.IsFrozen)), LabelStyle); GUILayout.Label(string.Format("Frozen Entities {0}", Core.entities.Count(x => x.IsFrozen)), LabelStyle); // GUILayout.EndHorizontal(); GUILayout.EndArea(); } { Camera c = Camera.main; if (!c) { return; } //Hover //Vector3 mp; //mp = c.ScreenToViewportPoint(Input.mousePosition); //mp.z = 0; foreach (Entity en in Core.entitiesThawed) { DrawEntity(en.UnityObject); } //Hover Entity hover = Core.entitiesThawed .Where(x => ignoreList.Contains(x.NetworkId) == false) .Where(x => c.WorldToViewportPoint(x.UnityObject.transform.position).ViewPointIsOnScreen()) .Where(x => { Vector3 m; m = Input.mousePosition; m.z = 0; Vector3 p; p = c.WorldToScreenPoint(x.UnityObject.transform.position); p.z = 0; return((m - p).sqrMagnitude < (32 * 32)); }) .OrderBy(x => { Vector3 center = new Vector3(0.5f, 0.5f, 0f); Vector3 vp; vp = c.WorldToViewportPoint(x.UnityObject.transform.position); vp.z = 0; return((center - vp).sqrMagnitude); }) .FirstOrDefault(); locked = hover; if (Input.GetKeyDown(KeyCode.End)) { //locked = hover; } Entity entity = locked ? locked : hover; //Center of the Screen if (Input.GetKeyDown(KeyCode.Home)) { locked = Core.entities .Where(x => ignoreList.Contains(x.NetworkId) == false) .Where(x => c.WorldToViewportPoint(x.UnityObject.transform.position).ViewPointIsOnScreen()) .OrderBy(x => { Vector3 center = new Vector3(0.5f, 0.5f, 0f); Vector3 vp; vp = c.WorldToViewportPoint(x.UnityObject.transform.position); vp.z = 0; return((center - vp).sqrMagnitude); }) .FirstOrDefault(); } if (locked && mouseOver) { Rect r = new Rect(Screen.width - 410, 10, 400, Screen.height - 20); DrawBackground(r); r.xMin += 10; r.xMax -= 10; r.yMin += 10; r.yMax -= 10; GUILayout.BeginArea(r); debugInfoScroll = GUILayout.BeginScrollView(debugInfoScroll, false, false, GUIStyle.none, GUIStyle.none); GUILayout.BeginVertical(); var state = (NetworkState)locked.Serializer; if (Input.GetKeyDown(KeyCode.L)) { AscensionNetworkInternal.DebugDrawer.SelectGameObject(locked.UnityObject.gameObject); } LabelBold("Entity Info"); LabelField("Name", locked.UnityObject.gameObject.name); LabelField("Network Id", locked.NetworkId); LabelField("Is Frozen", locked.IsFrozen); LabelField("Animator", state.Animator == null ? "NULL" : state.Animator.gameObject.name); LabelField("Entity Parent", locked.HasParent ? locked.Parent.UnityObject.ToString() : "NULL"); //LabelField("Transform Parent", entity.UnityObject.transform.parent == null ? "NULL" : entity.UnityObject.transform.parent.GetComponent<AscensionEntity>().ToString()); LabelField("Has Control", locked.HasControl); if (state.Animator != null) { for (int i = 0; i < state.Animator.layerCount; ++i) { LabelField(" Layer", state.Animator.GetLayerName(i)); #if UNITY_5 || UNITY5 var clips = state.Animator.GetCurrentAnimatorClipInfo(i); #else var clips = state.Animator.GetCurrentAnimationClipState(i); #endif foreach (var clip in clips) { LabelField(" Clip", string.Format("{0} (weight: {1})", clip.clip.name, clip.weight)); } } } if (locked.IsOwner) { LabelBold(""); LabelBold("Connection Priorities"); foreach (Connection cn in AscensionNetwork.Connections) { LabelField("Connection#" + cn.ConnectionId, cn.entityChannel.GetPriority(locked).ToString()); } } if (locked.IsOwner == false) { LabelBold(""); LabelBold("Frame Info"); LabelField("Buffer Count", state.Frames.Count); LabelField("Latest Received Number", state.Frames.Last.Frame); LabelField("Diff (Should be < 0)", AscensionNetwork.ServerFrame - state.Frames.Last.Frame); } LabelBold(""); LabelBold("World Info"); LabelField("Position", locked.UnityObject.transform.position); LabelField("Distance From Camera", (c.transform.position - locked.UnityObject.transform.position).magnitude); locked.Serializer.DebugInfo(); GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndArea(); } if (Input.GetKey(KeyCode.PageUp)) { debugInfoScroll.y = Mathf.Max(debugInfoScroll.y - 10, 0); } if (Input.GetKey(KeyCode.PageDown)) { debugInfoScroll.y = Mathf.Min(debugInfoScroll.y + 10, 2000); } } }
//public volatile bool IsSending; public override string ToString() { return(string.Format("{0}: {1} {2}", SendTime.ToString("HH:mm:ss.fff"), Caption, GetHashCode())); }
public override string ToString() => $"Sender = {SenderName?.ToString()}{SenderCId?.ToString()} , Source EP = {SourceEP?.ToString()} , " + $"White Source EP = {WhiteSourceEP?.ToString()} , Destination EP = {DestinationEP?.ToString()} , " + $"Destination = {DestinationName?.ToString()} , Text = {Text?.ToString()} , Send Time = {SendTime.ToString()}";