public void syncAll() { if (Is_calibrat_running) { return; } int clock; byte sno; for (int i = 0; i < 5; i++) { long etick; sno = recordTimeBroadcast(out etick); if (sync_nodes.All_nodes == null) { return; } sync_nodes.All_nodes[0].syncClu.read(); clock = sync_nodes.All_nodes[0].syncClu.getClockInt(sno); if (clock != -1) { masterSyncTo(etick, clock); ushort ms; byte us4; SyncCluster.intToClock(out ms, out us4, clock); syncToBroadcast(ms, us4, sno); write(debug, "Synchronize done"); return; } } sync_nodes.init(); return; }
public void syncAllBroadcast(int time, byte sno, dInfoOut details) { ushort ms; byte us4; SyncCluster.intToClock(out ms, out us4, time); syncToBroadcast(ms, us4, sno); if (details != null) { write(details, "#### Sync all by broadcast\n"); } }
public void syncAll(dInfoOut details) { long sync_elapsed_ticks; byte sno = recordTimeBroadcast(out sync_elapsed_ticks); int clock = getClockInt(sync_elapsed_ticks); ushort ms; byte us4; SyncCluster.intToClock(out ms, out us4, clock); syncToBroadcast(ms, us4, sno); if (details != null) { write(details, "#### Sync all by broadcast\n"); } }
public int syncAllAvariageUnicastDebug(dInfoOut details) { long sync_elapsed_ticks; byte sno = recordTimeBroadcast(out sync_elapsed_ticks); double totle_clock = 0; int success_count = 0; int fail_count = 0; Queue <BaseNode> sync_success_nodes = new Queue <BaseNode>(); write(details, "\n"); write(details, string.Format("Addr | ms1.024 | us4 | Totel int\n")); write(details, string.Format("----|----|----|----\n")); foreach (BaseNode node in bus) { if (node != null) { node.syncClu.read();//这个可以把所有节点的访问放在一起加快速度。 if (node.syncClu.sno != sno) { write(details, string.Format("Addr|not receive|x|x\n", node.Addr)); } else if ((node.syncClu.is_sync_miss != false)) { write(details, string.Format("Addr|sync miss|x|x\n", node.Addr)); } else { sync_success_nodes.Enqueue(node); int c = node.syncClu.getClockInt(); totle_clock += c; write(details, string.Format(" {0} | {1}.{2} | {3} | {4}\n", node.Addr, node.syncClu.ms / 1000, node.syncClu.ms % 1000, node.syncClu.us4, c)); success_count++; } } } if (success_count != 0) { int avariage = (int)Math.Round(totle_clock / success_count); ushort ms; byte us4; SyncCluster.intToClock(out ms, out us4, avariage); write(details, string.Format("avariage |{0}.{1} | {2} | {3}\n", ms / 1000, ms % 1000, us4, avariage)); write(details, "\n"); write(details, string.Format("+ {0}/{1} node accessed for sync!\n", success_count, success_count + fail_count)); foreach (BaseNode node in sync_success_nodes) { node.syncClu.syncTo(ms, us4, sno); } write(details, string.Format("\nOffset | OldTime | NewTime \n")); write(details, string.Format("----|----|----\n")); foreach (BaseNode node in sync_success_nodes) { node.debugClu.read(); write(details, string.Format(" {0} | {1} | {2} \n", (int)support.byteToUint32(node.debugClu.Bank, 0), (int)support.byteToUint32(node.debugClu.Bank, 4), (int)support.byteToUint32(node.debugClu.Bank, 8))); } write(details, "\n"); } return(fail_count); }
public void getSyncStatuc(dInfoOut details) { if (details == null) { throw new Exception("report sync status should write info to string"); } long sync_elapsed_ticks; byte sno = recordTimeBroadcast(out sync_elapsed_ticks); double totle_clock = 0; int success_count = 0; int fail_count = 0; Queue <BaseNode> sync_success_nodes = new Queue <BaseNode>(); foreach (BaseNode node in bus) { if (node != null) { node.syncClu.read();//这个可以把所有节点的访问放在一起加快速度。 if ((node.syncClu.sno == sno) && (node.syncClu.is_sync_miss == false)) { sync_success_nodes.Enqueue(node); int c = node.syncClu.getClockInt(); totle_clock += c; success_count++; } else { fail_count++; } } } if (success_count != 0) { write(details, "#### Get all time statuc \n"); write(details, string.Format("+ {0}/{1} node accessed for sync!\n", success_count, success_count + fail_count)); double avariage = totle_clock / success_count; ushort ms; byte us4; SyncCluster.intToClock(out ms, out us4, (int)Math.Round(totle_clock / success_count)); double diff_sum = 0; write(details, "\n"); write(details, string.Format("Addr | ms1.024 | us4 | Totel int|Diff\n")); write(details, string.Format("----|----|----|----|----\n")); write(details, string.Format("avariage |{0}.{1} | {2} | {3} | -- \n", ms / 1000, ms % 1000, us4, avariage.ToString("F3"))); foreach (BaseNode node in bus) { if (node != null) { if (node.syncClu.sno != sno) { write(details, string.Format("Addr|not receive|x|x|x\n", node.Addr)); } else if ((node.syncClu.is_sync_miss != false)) { write(details, string.Format("Addr|sync miss|x|x|x\n", node.Addr)); } else { double c = node.syncClu.getClockInt(); double diff = c - avariage; diff_sum += System.Math.Abs(diff); write(details, string.Format(" {0} | {1}.{2} | {3} | {4} | {5}\n", node.Addr, node.syncClu.ms / 1000, node.syncClu.ms % 1000, node.syncClu.us4, c, diff.ToString("F3"))); } } } write(details, "\n"); double diff_avariage = diff_sum / success_count; if (diff_avariage >= 1) { write(details, "+ Diff avariage out of range!\n"); } write(details, string.Format("+ Diff avariage is {0}\n", (diff_sum / success_count).ToString("F3"))); } else { write(details, "+ No node accessed ! \n"); } return; }
public int getAvariageTime(out BaseNode[] successed_node_array, out byte sno, dInfoOut details) { long sync_elapsed_ticks; sno = recordTimeBroadcast(out sync_elapsed_ticks); double totle_clock = 0; int avariage; Queue <BaseNode> sync_success_nodes = new Queue <BaseNode>(); foreach (BaseNode node in bus) { if (node != null) { node.syncClu.read();//这个可以把所有节点的访问放在一起加快速度。 if ((node.syncClu.sno == sno) && (node.syncClu.is_sync_miss == false)) { sync_success_nodes.Enqueue(node); totle_clock += node.syncClu.getClockInt(); } } } successed_node_array = sync_success_nodes.ToArray(); if (successed_node_array.Length != 0) { avariage = (int)Math.Round(totle_clock / successed_node_array.Length); } else { avariage = -1; } if (details != null) { write(details, "#### Get all recorded time\n"); write(details, string.Format("\nAddr | ms1.024 | us4 | Totel int\n")); write(details, string.Format("----|----|----|----\n")); if (sync_success_nodes.Count != 0) { ushort ms; byte us4; SyncCluster.intToClock(out ms, out us4, avariage); write(details, string.Format("avariage |{0}.{1} | {2} | {3}\n", ms / 1000, ms % 1000, us4, avariage)); foreach (BaseNode node in bus) { if (node != null) { if (node.syncClu.sno != sno) { write(details, string.Format("Addr|not receive|x|x\n", node.Addr)); } else if ((node.syncClu.is_sync_miss != false)) { write(details, string.Format("Addr|sync miss|x|x\n", node.Addr)); } else { int c = node.syncClu.getClockInt(); write(details, string.Format(" {0} | {1}.{2} | {3} | {4}\n", node.Addr, node.syncClu.ms / 1000, node.syncClu.ms % 1000, node.syncClu.us4, c)); } } } write(details, "\n"); } } return(avariage); }