示例#1
0
 public override void NotifyThingLost(DiscoveredThing thing)
 {
     if (CameraThingy.IsRelated(thing))
     {
         CameraThingy.LostRelatedCamera(thing.Id);
     }
 }
示例#2
0
 public override void NotifyThingDiscovered(DiscoveredThing thing)
 {
     if (CameraThingy.IsRelated(thing))
     {
         CameraThingy.DiscoveredRelatedCamera(thing.Id, thing.ContextId);
     }
 }
示例#3
0
        public bool IsRelated(DiscoveredThing compareThing)
        {
            string parentContext1 = GetParentContext(compareThing.ContextId);
            string parentContext2 = GetParentContext(Thing.ContextId);
            bool   isRelated      = (String.Equals(parentContext1, parentContext2)) &&
                                    (String.Equals(compareThing.ClassId.KeyString, Thing.ClassId.KeyString)) &&
                                    (!String.Equals(compareThing.Id, Thing.Id));

            return(isRelated);
        }
        private void DisplayThing(DiscoveredThing thing)
        {
            string prefix          = "    ";
            bool   thingClassFound = false;
            int    retryCount      = 30;

            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(thing.ContextId);
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine(" [Thing]");
            Console.ResetColor();

            Console.WriteLine(prefix + "   Thing ID:    " + thing.Id);
            Console.WriteLine(prefix + "   Context:     " + thing.ContextId);
            Console.WriteLine(prefix + "   Description: " + thing.Description);

            while (!thingClassFound && retryCount-- > 0)
            {
                try
                {
                    var thingClassName = thing.ClassId.Name + ":" +
                                         thing.ClassId.Context + ":" +
                                         thing.ClassId.VersionTag;
                    var registry   = MyDataRiver.DiscoveredThingClassRegistry;
                    var thingClass = registry.FindThingClass(thingClassName);

                    DisplayThingClass(thingClass, prefix + "   ");
                    thingClassFound = true;
                }
                catch (Exception e)
                {
                    // ThingClass not found
                    Console.WriteLine("DisplayThing Exception caught: {0}", e);
                }

                // Sleep 100ms before retry
                System.Threading.Thread.Sleep(100);
            }

            if (!thingClassFound)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(prefix + "   ThingClass not found");
                Console.ResetColor();
            }
        }
 public override void NotifyThingLost(DiscoveredThing thing)
 {
     if (thing.ClassId.Name == "TemperatureSensor")
     {
         Console.ForegroundColor = ConsoleColor.Magenta;
         Console.WriteLine("Temperature sensor stopped: "
                           + thing.Description
                           + " ("
                           + thing.Id
                           + ")"
                           );
     }
     else
     {
         Console.ForegroundColor = ConsoleColor.DarkGray;
         Console.WriteLine("Other sensor stopped: "
                           + thing.ClassId.Name
                           + " ("
                           + thing.Id
                           + ")"
                           );
     }
     Console.ResetColor();
 }
 public override void NotifyThingDiscovered(DiscoveredThing thing)
 {
     if (thing.ClassId.Name == "TemperatureSensor")
     {
         Console.ForegroundColor = ConsoleColor.DarkGreen;
         Console.WriteLine("New temperature sensor discovered: "
                           + thing.Description
                           + " ("
                           + thing.Id
                           + ")"
                           );
     }
     else
     {
         Console.ForegroundColor = ConsoleColor.DarkGray;
         Console.WriteLine("New incompatible sensor type: "
                           + thing.ClassId.Name
                           + " ("
                           + thing.Id
                           + ")"
                           );
     }
     Console.ResetColor();
 }
示例#7
0
 public override void NotifyThingDiscovered(DiscoveredThing thing)
 {
     Globals.ThingContexts[thing.Id] = thing.ContextId;
 }
 public override void NotifyThingDiscovered(DiscoveredThing thing)
 {
     DisplayThing(thing);
 }