예제 #1
0
        public bool DeleteThingWrapper(OWLOSThingWrapper ThingWrapper)
        {
            foreach (OWLOSConnection connection in ThingWrapper.Thing.config.connections)
            {
                connection.enable = false;
            }

            config.ThingsConfig.Remove(ThingWrapper.Thing.config);
            OWLOSThingWrappers.Remove(ThingWrapper);

            OnDeleteThingWrapper?.Invoke(ThingWrapper, new EventArgs());

            return(true);
        }
예제 #2
0
        public OWLOSThingWrapper CreateThingWrapper()
        {
            OWLOSThingConfig _OWLOSThingConfig = CreateThingConnection();

            OWLOSThingWrapper ThingWrapper = new OWLOSThingWrapper(this)
            {
                Thing = new OWLOSThing(_OWLOSThingConfig)
            };

            OWLOSThingWrappers.Add(ThingWrapper);
            NewThing(new OWLOSThingWrapperEventArgs(ThingWrapper));

            return(ThingWrapper);
        }
예제 #3
0
 public void Load()
 {
     if (File.Exists("config.json"))
     {
         string JSONConfig = File.ReadAllText("config.json");
         config = JsonConvert.DeserializeObject <ThingsManagerConfig>(JSONConfig);
     }
     else //reset config
     {
         CreateThingConnection();
     }
     //Save each time before development - add new fields to JSON
     Save();
     foreach (OWLOSThingConfig _OWLOSThingConfig in config.ThingsConfig)
     {
         OWLOSThingWrapper ThingWrapper = new OWLOSThingWrapper(this)
         {
             Thing = new OWLOSThing(_OWLOSThingConfig)
         };
         OWLOSThingWrappers.Add(ThingWrapper);
         NewThing(new OWLOSThingWrapperEventArgs(ThingWrapper));
     }
 }
예제 #4
0
 public OWLOSThingWrapperEventArgs(OWLOSThingWrapper ThingWrapper)
 {
     this.ThingWrapper = ThingWrapper;
 }