/// <summary> /// 插入一个时间标签,如果id已存在或者不为0则是更新 /// </summary> /// <param name="timeMark"></param> public void AddTimeMark(TimeMark timeMark) { if (timeMark.ID == 0) { _db.Insert(timeMark); } else { _db.InsertOrReplace(timeMark); } }
private void AddZoomedTimeRow(long timeStart, long timeEnd, string row) { itnotify.AddTimeToZoomedTimeList(row); TimeMark tm = new TimeMark(); tm.t0 = timeStart; tm.t1 = timeEnd; tm.desc = row; listMark.Add(tm); }
/// <summary> /// Adds a point to the trail. Points are added if they are minVertexDistance from the last point. /// </summary> /// <param name="point">Point.</param> public void AddPoint(Vector3 point, float pointTime, float currentTime) { // update trail? if (Vector3.Distance(point, lastPoint) < minVertexDistance) { return; } // add a time marker? if (timeMarkerPrefab != null) { if ((pointTime - lastTimeMark) > timeMarkInterval) { // add a time marker TimeMark mark = new TimeMark(); mark.marker = Instantiate(timeMarkerPrefab); if (ge.markerParent != null) { mark.marker.transform.SetParent(ge.markerParent.transform); } mark.marker.transform.position = point; mark.time = pointTime; timeMarks.Add(mark); lastTimeMark = pointTime; // align the game object so it's Z axis is along the trajectory Vector3 trajVector = point - lastPoint; mark.marker.transform.rotation = Quaternion.FromToRotation(Vector3.forward, trajVector); if (textPrefab != null && canvas != null) { mark.textObject = Instantiate(textPrefab); mark.textObject.transform.position = point; Text text = mark.textObject.GetComponent <Text>(); text.text = string.Format("{0:F1}", pointTime); mark.textObject.transform.SetParent(canvas.transform); if (rotateText) { mark.textObject.transform.rotation = mark.marker.transform.rotation; } } } } lastPoint = point; // add new point to traj TrajPoint tp = new TrajPoint(point, pointTime); points.Add(tp); }
public async Task <ApiResult> UpdateTableTotal([JsonData] TimeMark timeMark) { if (!CheckLogin(HttpContext)) { return(ApiResult.Fail); } try { await DB.Instance.UpdateTotalAsync(timeMark); } catch (Exception e) { return(new ApiResult(e)); } return(ApiResult.Success); }
private long AddTimeRow(long tNext, CPUState[] state) { TimeMark tm = new TimeMark(); tm.t0 = tNext - 100000; tm.t1 = tNext; string line = ComputeTimeRow(tNext - 100000, tNext, state); tm.desc = line; itnotify.AddTimeToTimeList(line); tNext += 100000; offsets.Add(stm.Position); listInitialTime.Add(tm); return(tNext); }
public string ComputeDelays(int delaySize) { ThreadStat[] stats = NewThreadStats(); bool[] threadFilters = itparms.GetThreadFilters(); int idCSwitch = atomsRecords.Lookup("CSwitch"); StringWriter sw = new StringWriter(); sw.WriteLine("{0,15} {1,15} {2,15} {3,30} {4,5} {5,-60}", "Delay Start", "Delay End", "Delay Duration", "Process Name ( ID )", "TID", "Threadproc"); sw.WriteLine("{0,15} {1,15} {2,15} {3,30} {4,5} {5,-60}", "-----------", "---------", "--------------", "-------------------", "---", "----------"); listDelays = new List <TimeMark>(); int totalDelays = 0; long totalDelay = 0; long T0 = itparms.T0; for (int i = 0; i < stats.Length; i++) { stats[i].time = Math.Max(T0, threads[i].timestamp); } ETWLineReader l = StandardLineReader(); foreach (ByteWindow b in l.Lines()) { if (l.idType != idCSwitch) { continue; } int oldTid = b.GetInt(fldCSwitchOldTID); int idxOld = FindThreadInfoIndex(l.t, oldTid); stats[idxOld].time = l.t; int newTid = b.GetInt(fldCSwitchNewTID); int idxNew = FindThreadInfoIndex(l.t, newTid); int waitTime = (int)(l.t - stats[idxNew].time); if (waitTime <= 0) { continue; } if (!threadFilters[idxNew]) { continue; } totalDelays++; totalDelay += waitTime; if (waitTime > delaySize) { TimeMark tm = new TimeMark(); tm.t0 = l.t - waitTime; tm.t1 = l.t; string process = ByteWindow.MakeString(threads[idxNew].processPid); string threadproc = ByteWindow.MakeString(threads[idxNew].threadproc); tm.desc = String.Format("{0,15:n0} {1,15:n0} {2,15:n0} {3,30} {4,5} {5,-60}", tm.t0, tm.t1, waitTime, process, newTid, threadproc); sw.WriteLine(tm.desc); listDelays.Add(tm); } } sw.WriteLine(); sw.WriteLine("Total Delays: {0:n0} Total Delay Time {1:n0}", totalDelays, totalDelay); return(sw.ToString()); }
public void AddTimeMark(TimeMark mark) { timeMarksScale.Marks.Add(mark); this.InvalidateVisual(); }
/// <summary> /// Adds a point to the trail. Points are added if they are minVertexDistance from the last point. /// </summary> /// <param name="point">Point.</param> public void AddPoint(Vector3 point, float pointTime, float currentTime) { // remove any points older than current time while ((points.Count > 0) && (points[0].worldTime < currentTime)) { points.RemoveAt(0); } // add/remove a time marker? if (timeMarkerPrefab != null) { if ((pointTime - lastTimeMark) > timeMarkInterval) { // add a time marker TimeMark mark = new TimeMark(); mark.marker = Instantiate(timeMarkerPrefab); if (GravityEngine.Instance().markerParent != null) { mark.marker.transform.SetParent(GravityEngine.Instance().markerParent.transform); } mark.marker.transform.position = point; mark.time = pointTime; timeMarks.Add(mark); lastTimeMark = pointTime; // align the game object so it's Z axis is along the trajectory Vector3 trajVector = point - lastPoint; mark.marker.transform.rotation = Quaternion.FromToRotation(Vector3.forward, trajVector); if (textPrefab != null && canvas != null) { mark.textObject = Instantiate(textPrefab); mark.textObject.transform.position = point; Text text = mark.textObject.GetComponent <Text>(); text.text = string.Format("{0:F1}", pointTime); mark.textObject.transform.SetParent(canvas.transform); if (rotateText) { mark.textObject.transform.rotation = mark.marker.transform.rotation; } } // Mark need to keep an absolute reference // TODO: Add to some common object // mark.marker.transform.SetParent(something); } // remove any old time markers while ((timeMarks.Count > 0) && (timeMarks[0].time < currentTime)) { Destroy(timeMarks[0].marker); if (timeMarks[0].textObject != null) { Destroy(timeMarks[0].textObject); } timeMarks.RemoveAt(0); } } // update trail? if (Vector3.Distance(point, lastPoint) < minVertexDistance) { return; } lastPoint = point; // add new point to traj TrajPoint tp = new TrajPoint(point, pointTime); points.Add(tp); }
public void Listen() { UdpClient reciever = new UdpClient(Config.C_port); IPEndPoint remoteIP = null; try { while (true) { byte[] data = reciever.Receive(ref remoteIP); Message message = Serialiser <Message> .Deserialise(data); switch (message.Type) { case MessageType.AsToC: TicketGrantingTicket = DES.Decrypt(message.Data[0].ToArray(), Config.K_C); K_C_TGS = Helper.RecoverData(new List <byte>(DES.Decrypt(message.Data[1].ToArray(), Config.K_C))); var a = Encoding.UTF8.GetString(K_C_TGS); Print("AS to C complete!"); message = new Message(MessageType.СToTgs); message.Data.Add(new List <byte>(TicketGrantingTicket)); TimeMark mark = new TimeMark() { C = Login, T = DateTime.Now }; var Aut1 = Helper.ExtendData(Serialiser <TimeMark> .Serialise(mark)); message.Data.Add(new List <byte>(DES.Encrypt(Aut1, K_C_TGS))); message.Data.Add(new List <byte>(Encoding.UTF8.GetBytes(Config.SS_ID))); message.Send(TGSEndPoint); break; case MessageType.TgsToC: TicketGrantingService = DES.Decrypt(message.Data[0].ToArray(), K_C_TGS); K_C_SS = Helper.RecoverData(new List <byte>(DES.Decrypt(message.Data[1].ToArray(), K_C_TGS))); Message msg = new Message(MessageType.CToSs); msg.Data.Add(new List <byte>(TicketGrantingService)); mark = new TimeMark() { C = Login, T = DateTime.Now }; var Aut2 = Helper.ExtendData(Serialiser <TimeMark> .Serialise(mark)); T4 = mark.T; msg.Data.Add(new List <byte>(DES.Encrypt(Aut2, K_C_SS))); msg.Send(SSEndPoint); Print("TGS to C complete"); break; case MessageType.SsToC: var t = DES.Decrypt(message.Data[0].ToArray(), K_C_SS); var checkT_bytes = Helper.RecoverData(new List <byte>(t)); var asd = Encoding.UTF8.GetString(checkT_bytes); var checkT = Serialiser <long> .Deserialise(checkT_bytes); if (T4.Ticks + 1 == checkT) { Console.WriteLine($"Success."); } break; case MessageType.TicketNotValid: Console.WriteLine("Ticket is not valid"); break; case MessageType.AccessDenied: Console.WriteLine("Access denied!"); break; default: Console.WriteLine("Invalid type of message"); break; } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// 插入一个时间标签,如果id已存在或者不为0则是更新 /// </summary> /// <param name="timeMark"></param> public Task AddTimeMarkAsync(TimeMark timeMark) { return(Task.Factory.StartNew(() => AddTimeMark(timeMark))); }
/// <summary> /// 根据时间标签中的信息更新统计数据,不检查时间合法性 /// </summary> /// <param name="timeMark">时间标签</param> public Task UpdateTotalAsync(TimeMark timeMark) { return(Task.Factory.StartNew(() => { UpdateTotal(timeMark); })); }