Exemplo n.º 1
0
 private void write(dInfoOut info, string st)
 {
     if (info != null)
     {
         info(st);
     }
 }
Exemplo n.º 2
0
 public void calibratClean(dInfoOut details)
 {
     write(details, "All calibration values clear to 0.\n");
     foreach (BaseNode node in bus)
     {
         node.syncClu.calibrationClu.calibration_value = 0;
         node.syncClu.calibrationClu.write();
     }
     return;
 }
Exemplo n.º 3
0
                public void syncAll2(dInfoOut details)
                {
                    BaseNode[] nodes;
                    byte       sno;
                    int        time = getAvariageTime(out nodes, out sno, details);

                    if (time != -1)
                    {
                        syncAllBroadcast(time, sno, details);
                    }
                    return;
                }
Exemplo n.º 4
0
                public void syncToAimNode2(byte aim_node_addr, dInfoOut details)
                {
                    byte sno;
                    int  time = getAimNodeTime(aim_node_addr, out sno, details);

                    if (time != -1)
                    {
                        syncAllBroadcast(time, sno, details);
                    }
                    // syncDebugAll(nodes,ref details);
                    return;
                }
Exemplo n.º 5
0
                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");
                    }
                }
Exemplo n.º 6
0
 public void calibratClean(dInfoOut details)
 {
     write(details, "All calibration values clear to 0.\n");
     if (sync_nodes.All_nodes == null)
     {
         return;
     }
     foreach (Node node in sync_nodes.All_nodes)
     {
         node.syncClu.calibrationClu.calibration_value = 0;
         node.syncClu.calibrationClu.write();
     }
     return;
 }
Exemplo n.º 7
0
 public void calibrat(dInfoOut cinfo = null)
 {
     if (Is_calibrat_running)
     {
         throw new ObjectDisposedException("Calibrat");
     }
     else
     {
         calibrat_info    = cinfo;
         abandon_calibrat = 0;
         calibratT        = new Thread(calibratThread);
         calibratT.Start();
         return;
     }
 }
Exemplo n.º 8
0
                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");
                    }
                }
Exemplo n.º 9
0
                public void syncDebugAll(BaseNode[] successed_node_array, dInfoOut details)
                {
                    if (details == null)
                    {
                        throw new Exception("report sync status should write info to string");
                    }
                    write(details, "#### debug check\n");
                    write(details, string.Format("\nAddr | Offset | OldTime | NewTime \n"));
                    write(details, string.Format("----|----|----|----\n"));
                    foreach (BaseNode node in successed_node_array)
                    {
                        node.debugClu.read();

                        write(details, string.Format(" {0} | {1} | {2} | {3} \n",
                                                     node.Addr,
                                                     (int)support.byteToUint32(node.debugClu.Bank, 0),
                                                     (int)support.byteToUint32(node.debugClu.Bank, 4),
                                                     (int)support.byteToUint32(node.debugClu.Bank, 8)));
                    }
                    write(details, "\n");
                }
Exemplo n.º 10
0
                public int getAimNodeTime(byte aim_node_addr, out byte sno, dInfoOut details)
                {
                    long sync_elapsed_ticks;

                    sno = recordTimeBroadcast(out sync_elapsed_ticks);
                    Queue <BaseNode> sync_success_nodes = new Queue <BaseNode>();

                    foreach (BaseNode node in bus)
                    {
                        if (node != null)
                        {
                            if (node.Addr == aim_node_addr)
                            {
                                node.syncClu.read();//这个可以把所有节点的访问放在一起加快速度。
                                if ((node.syncClu.sno == sno) && (node.syncClu.is_sync_miss == false))
                                {
                                    return(node.syncClu.getClockInt());
                                }
                            }
                        }
                    }
                    return(-1);
                }
Exemplo n.º 11
0
                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);
                }
Exemplo n.º 12
0
                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;
                }
Exemplo n.º 13
0
                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);
                }