public static void WriteToDB(Affiliation a)
        {
            string commandString =
                String.Format(
                "insert into affiliation(affiliated, [datetime], [milliseconds], radio, [group]) " +
                "values ({0}, '{1}', {2}, {3}, {4})",
                a.kind == AffiliationType.affiliation ? 1 : 0,
                a.time, a.time.Millisecond, a.radio, a.group);

            //Console.WriteLine(commandString);
            OdbcCommand command = new OdbcCommand(commandString, connection);
            command.ExecuteNonQuery();
        }
        public static void WriteToDB(Affiliation a)
        {
            string commandString =
                String.Format(
                    "insert into affiliation(affiliated, [datetime], [milliseconds], radio, [group]) " +
                    "values ({0}, '{1}', {2}, {3}, {4})",
                    a.kind == AffiliationType.affiliation ? 1 : 0,
                    a.time, a.time.Millisecond, a.radio, a.group);

            //Console.WriteLine(commandString);
            OdbcCommand command = new OdbcCommand(commandString, connection);

            command.ExecuteNonQuery();
        }
Exemple #3
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;
        }
        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;
        }