Ejemplo n.º 1
0
        public byte GetLiVnModeByte(LeapIndicator li, int vn, Mode mode)
        {
            var intermediateResult = 0;

            switch (li)
            {
            case LeapIndicator.LastMinuteHas61Seconds: { intermediateResult += 64; break; }

            case LeapIndicator.LastMinuteHas59Seconds: { intermediateResult += 128; break; }

            case LeapIndicator.ClockUnsynchronized: { intermediateResult += 192; break; }

            case LeapIndicator.NoLeapSecondAdjustment:
            default: { break; }
            }
            switch (vn)
            {
            case 1: { intermediateResult += 8; break; }

            case 2: { intermediateResult += 16; break; }

            case 3: { intermediateResult += 24; break; }

            case 4: { intermediateResult += 32; break; }

            case 5: { intermediateResult += 40; break; }

            case 6: { intermediateResult += 48; break; }

            case 7: { intermediateResult += 56; break; }

            default: { break; }
            }
            switch (mode)
            {
            case Mode.SymmetricActive: { intermediateResult += 1; break; }

            case Mode.SymmetricPassive: { intermediateResult += 2; break; }

            case Mode.Client: { intermediateResult += 3; break; }

            case Mode.Server: { intermediateResult += 4; break; }

            case Mode.Broadcast: { intermediateResult += 5; break; }

            case Mode.NtpControlMessage: { intermediateResult += 6; break; }

            case Mode.ReservedPrivateUse: { intermediateResult += 7; break; }

            case Mode.Reserved:
            default: { break; }
            }
            byte result = (byte)intermediateResult;

            return(result);
        }
Ejemplo n.º 2
0
            public void SetLeapIndicator(LeapIndicator leapIndicator)
            {
                switch (leapIndicator)
                {
                case LeapIndicator.NoWarining:
                    flags |= 0b00000000;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(leapIndicator), leapIndicator, null);
                }
            }
Ejemplo n.º 3
0
 public static string GetName(LeapIndicator LeapIndicatorEnum)
 {
     switch (LeapIndicatorEnum)
     {
         case LeapIndicator.NoWarning:
             return "No Warning";
         case LeapIndicator.LastMinute61Seconds:
             return "Last Minute 61 Seconds";
         case LeapIndicator.LastMinute59Seconds:
             return "Last Minute 59 Seconds";
         case LeapIndicator.Alarm:
             return "Alarm - Clock Not Synchronized";
         default:
             return "Unknown";
     }
 }
Ejemplo n.º 4
0
        public static string GetName(LeapIndicator LeapIndicatorEnum)
        {
            switch (LeapIndicatorEnum)
            {
            case LeapIndicator.NoWarning:
                return("No Warning");

            case LeapIndicator.LastMinute61Seconds:
                return("Last Minute 61 Seconds");

            case LeapIndicator.LastMinute59Seconds:
                return("Last Minute 59 Seconds");

            case LeapIndicator.Alarm:
                return("Alarm - Clock Not Synchronized");

            default:
                return("Unknown");
            }
        }