示例#1
0
        public void doCommand(string line)
        {
            OSW            osw;
            Match          match;
            processCommand commandDelegate;
            int            command;

            if (line.ToLower().Contains("bad") == true)
            {
                commandDelegate = receivedBad;
                commandDelegate(null);
                return;
            }
            match = Regex.Match(line,
                                @"(?<group>[0-9a-f]{4}) (?<callType>[ig]) (?<command>[0-9a-f]{4})",
                                RegexOptions.IgnoreCase);

            if (match == null)
            {
                return;
            }


            osw = new OSW(match.Groups["group"].Value,
                          match.Groups["callType"].Value,
                          match.Groups["command"].Value);

            //   Console.WriteLine("CMD PROC: command: {0:X4} group: {1:X4}",
            //       osw.command, osw.group);

            command = Convert.ToInt32(match.Groups["command"].Value, 16);

            if (commands.ContainsKey(match.Groups["command"].Value))
            {
                commandDelegate = commands[match.Groups["command"].Value];
            }
            else
            {
                if (isFrequency(command) == true)
                {
                    commandDelegate = receivedFrequency;
                }
                else
                {
                    commandDelegate = receivedOther;
                }
            }
            commandDelegate(osw);
        }
示例#2
0
        public override void received30b(OSW osw)
        {
            int radio = lastOSW.group;

            if (affiliations.ContainsKey(radio) &&
                affiliations[radio].kind == AffiliationType.affiliation)
            {
                affiliations[radio].kind = AffiliationType.deaffiliation;
                affiliations[radio].time = DateTime.Now;
                Console.WriteLine("{0} deaff.", radio);
                Program.WriteToDB(affiliations[radio]);
            }
            //Console.WriteLine("Received 308/30b");
            currentState = stateNormal;
        }
示例#3
0
        public void doCommand(string line)
        {
            OSW osw;
            Match match;
            processCommand commandDelegate;
            int command;

            if (line.ToLower().Contains("bad") == true)
            {
                commandDelegate = receivedBad;
                commandDelegate(null);
                return;
            }
            match = Regex.Match(line,
                @"(?<group>[0-9a-f]{4}) (?<callType>[ig]) (?<command>[0-9a-f]{4})",
                RegexOptions.IgnoreCase);

            if (match == null)
                return;

            osw = new OSW(match.Groups["group"].Value,
                match.Groups["callType"].Value,
                match.Groups["command"].Value);

             //   Console.WriteLine("CMD PROC: command: {0:X4} group: {1:X4}",
             //       osw.command, osw.group);

            command = Convert.ToInt32(match.Groups["command"].Value, 16);

            if (commands.ContainsKey(match.Groups["command"].Value))
            {
                commandDelegate = commands[match.Groups["command"].Value];

            }
            else
            {
                if (isFrequency(command) == true)
                {
                    commandDelegate = receivedFrequency;
                }
                else
                {
                    commandDelegate = receivedOther;
                }
            }
            commandDelegate(osw);
        }
示例#4
0
        public override void received310(OSW osw)
        {
            int radio = lastOSW.group;
            int group = osw.group;

            if ((group & 0x000f) != 0x0a)
            {
                StreamWriter sw = new StreamWriter("odd.txt", true);
                sw.WriteLine("Found odd group: {0:X4}", group);
                sw.Close();
            }
            group &= 0xfff0;

            if (affiliations.ContainsKey(radio))
            {
                if (affiliations[radio].kind == AffiliationType.affiliation)
                {
                    if (affiliations[radio].group == group)
                    {
                        currentState = stateNormal;
                        return;
                    }
                    else
                    {
                        affiliations.Remove(radio);
                    }
                }
                else
                {
                    if (affiliations[radio].kind == AffiliationType.deaffiliation)
                    {
                        affiliations.Remove(radio);
                    }
                }
            }

            Affiliation a = new Affiliation(AffiliationType.affiliation,
                                            group, lastOSW.group);

            Program.WriteToDB(a);
            affiliations.Add(radio, a);
            Console.WriteLine("Radio {0} aff--> {1}", radio, group);
            //Console.WriteLine("Received 308/310");
            currentState = stateNormal;
        }
示例#5
0
        public override void receivedFrequency(OSW osw)
        {
            int channel = osw.command;
            int radio   = lastOSW.group;
            int group   = osw.group & 0xfff0;

            if (calls.ContainsKey(group) == true)
            {
                if (calls[group].radio == radio)
                {
                    if (calls[group].time < DateTime.Now.AddSeconds(-2))
                    {
                        calls[group].time    = DateTime.Now;
                        calls[group].channel = channel;
                        Program.WriteToDB(calls[group]);
                    }
                    else
                    {
                        currentState = stateNormal;
                        return;
                    }
                }
                else
                {
                    calls[group].radio   = radio;
                    calls[group].channel = channel;
                    calls[group].time    = DateTime.Now;
                    Program.WriteToDB(calls[group]);
                }
            }

            else
            {
                Call c = new Call(group, radio, channel);
                calls.Add(group, c);
                Program.WriteToDB(c);
            }

            Console.WriteLine("Call on channel: {0} radio: {1} --> group: {2}", osw.command,
                              lastOSW.group, osw.group & 0xfff0);
            //Console.WriteLine("Received 308/Freq");
            currentState = stateNormal;
        }
示例#6
0
        public override void received30b(OSW osw)
        {
            int radio = lastOSW.group;

            if (affiliations.ContainsKey(radio) &&
                affiliations[radio].kind == AffiliationType.affiliation)
            {
                affiliations[radio].kind = AffiliationType.deaffiliation;
                affiliations[radio].time = DateTime.Now;
                Console.WriteLine("{0} deaff.", radio);
                Program.WriteToDB(affiliations[radio]);

            }
            //Console.WriteLine("Received 308/30b");
            currentState = stateNormal;
        }
示例#7
0
        /*       public  State308()
        {
            commands = new Dictionary<string, processCommand>();

            commands.Add("bad", receivedBad);
            commands.Add("0308", received308);
            commands.Add("0310", received310);
            commands.Add("030b", received30b);

        } */
        public override void received308(OSW osw)
        {
            currentState = stateNormal;
        }
示例#8
0
 public virtual void receivedOther(OSW osw)
 {
     //Console.WriteLine("Other: cmd: {0:X4}, group: {1:X4}", osw.command, osw.group);
     currentState = stateNormal;
 }
示例#9
0
 public virtual void receivedFrequency(OSW osw)
 {
     //Console.WriteLine("Freq.");
     currentState = stateNormal;
 }
示例#10
0
 public virtual void receivedBad(OSW osw)
 {
     //Console.WriteLine("Bad");
     currentState = stateBad;
 }
示例#11
0
 public virtual void receivedOther(OSW osw)
 {
     //Console.WriteLine("Other: cmd: {0:X4}, group: {1:X4}", osw.command, osw.group);
     currentState = stateNormal;
 }
示例#12
0
 public virtual void receivedFrequency(OSW osw)
 {
     //Console.WriteLine("Freq.");
     currentState = stateNormal;
 }
示例#13
0
 public virtual void received30b(OSW osw)
 {
     //Console.WriteLine("30b");
     currentState = stateNormal;
 }
示例#14
0
 public virtual void received308(OSW osw)
 {
     //Console.WriteLine("308");
     lastOSW      = osw;
     currentState = state308;
 }
示例#15
0
 public virtual void receivedBad(OSW osw)
 {
     //Console.WriteLine("Bad");
     currentState = stateBad;
 }
示例#16
0
        public override void received310(OSW osw)
        {
            int radio = lastOSW.group;
            int group = osw.group;

            if ((group & 0x000f) != 0x0a)
            {
                StreamWriter sw = new StreamWriter("odd.txt", true);
                sw.WriteLine("Found odd group: {0:X4}", group);
                sw.Close();
            }
            group &= 0xfff0;

            if (affiliations.ContainsKey(radio))
            {
                if (affiliations[radio].kind == AffiliationType.affiliation)
                {
                    if (affiliations[radio].group == group)
                    {
                        currentState = stateNormal;
                        return;
                    }
                    else
                    {
                        affiliations.Remove(radio);
                    }
                }
                else
                {
                    if (affiliations[radio].kind == AffiliationType.deaffiliation)
                    {
                        affiliations.Remove(radio);
                    }
                }
            }

            Affiliation a = new Affiliation(AffiliationType.affiliation,
                group, lastOSW.group);
            Program.WriteToDB(a);
            affiliations.Add(radio, a);
            Console.WriteLine("Radio {0} aff--> {1}", radio, group);
            //Console.WriteLine("Received 308/310");
            currentState = stateNormal;
        }
示例#17
0
        public override void receivedFrequency(OSW osw)
        {
            int channel = osw.command;
            int radio = lastOSW.group;
            int group = osw.group & 0xfff0;

            if (calls.ContainsKey(group) == true)
            {
                if (calls[group].radio == radio)
                {
                    if (calls[group].time < DateTime.Now.AddSeconds(-2))
                    {
                        calls[group].time = DateTime.Now;
                        calls[group].channel = channel;
                        Program.WriteToDB(calls[group]);
                    }
                    else
                    {
                        currentState = stateNormal;
                        return;
                    }

                }
                else
                {
                    calls[group].radio = radio;
                    calls[group].channel = channel;
                    calls[group].time = DateTime.Now;
                    Program.WriteToDB(calls[group]);
                }
            }

            else
            {
                Call c = new Call(group, radio, channel);
                calls.Add(group, c);
                Program.WriteToDB(c);
            }

            Console.WriteLine("Call on channel: {0} radio: {1} --> group: {2}", osw.command,
                lastOSW.group, osw.group & 0xfff0);
            //Console.WriteLine("Received 308/Freq");
            currentState = stateNormal;
        }
示例#18
0
 public virtual void received310(OSW osw)
 {
     //Console.WriteLine("***310");
     currentState = stateNormal;
 }
示例#19
0
 public virtual void received308(OSW osw)
 {
     //Console.WriteLine("308");
     lastOSW = osw;
     currentState = state308;
 }
示例#20
0
        /*       public  State308()
         *     {
         *         commands = new Dictionary<string, processCommand>();
         *
         *         commands.Add("bad", receivedBad);
         *         commands.Add("0308", received308);
         *         commands.Add("0310", received310);
         *         commands.Add("030b", received30b);
         *
         *     } */

        public override void received308(OSW osw)
        {
            currentState = stateNormal;
        }