public ActionResult EditEnvironment(string id, string name, EnvironmentConfig model) { var item = GetConfigurationReader().GetConfiguration(id); var env = (from e in item.Environments where e.EnvironmentName == name select e).First(); env.EnvironmentName = model.EnvironmentName; if (env.Parameters == null) env.Parameters = new List<ConfigParameter>(); var keyName = Request.Form["keyName"]; var value = Request.Form["keyValue"]; if (keyName.ContainsCharacters()) { var param = (from p in env.Parameters where p.Name == keyName select p).FirstOrDefault(); if (param.IsNull()) { param = new ConfigParameter(); env.Parameters.Add(param); } param.Name = keyName; if (keyName.ToLower().Contains("password")) { param.Value = value.Encrypt("mayTheKeysSupportAllMyValues"); param.BinaryValue = param.Value.GetByteArray(); if(param.Value.Decrypt("mayTheKeysSupportAllMyValues")!=value) throw new StardustCoreException("Encryption validation failed!"); } else param.Value = value; } GetConfigurationReader().WriteConfigurationSet(item, id); ViewBag.Id = id; return RedirectToAction("EditEnvironment", new { id = id }); }
public ConfigValue GetValue(ConfigParameter parameter) { lock (_lockObject) { return GetValueWithoutLock(parameter); } }
internal override void SetResult(ConfigParameter parameterId, object val) { if (parameterId == ConfigParameter.InputEncoding) { this.inputEncoding = (Encoding)val; } base.SetResult(parameterId, val); }
void IResultsFeedback.Set(ConfigParameter parameterId, object val) { if (parameterId != ConfigParameter.InputEncoding) { return; } this.inputEncoding = (Encoding)val; }
public SchedulerWorkerService(ISchedulerService schedulerService, IOptions <ConfigParameter> options, IHostingEnvironment hostingEnvironment) { configParameter = options.Value; _schedulerService = schedulerService; _hostingEnvironment = hostingEnvironment; }
internal override void SetResult(ConfigParameter parameterId, object val) { if (parameterId == ConfigParameter.RtfCompressionMode) { this.compressionMode = (RtfCompressionMode)val; } base.SetResult(parameterId, val); }
public ConfigValue GetValue(ConfigParameter parameter) { var setting = ConfigurationManager.AppSettings[parameter.Name]; if (setting == null) { return new ConfigValue(parameter, null, false); } return new ConfigValue(parameter, setting, true); }
public static bool GetBoolValueOrDefault(this KeyedCollection <string, ConfigParameter> parameters, string parameterName, bool defaultValue) { if (!parameters.Contains(parameterName)) { return(defaultValue); } ConfigParameter p = parameters[parameterName]; return(p.Value == "1"); }
public ConfigParameterMenu(ConfigParameter parameter) { Verify.Argument.IsValidGitObject(parameter, "parameter"); _parameter = parameter; Items.Add(GuiItemFactory.GetUnsetParameterItem <ToolStripMenuItem>(parameter)); Items.Add(new ToolStripSeparator()); Items.Add(new ToolStripMenuItem(Resources.StrCopyToClipboard, null, GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrName, _parameter.Name), GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrValue, _parameter.Value))); }
public async Task Load(string root, ConfigParameter configParameter) { string pluginFolder = Path.Combine(root, "JobPlugins"); string[] filePaths = Directory.GetFiles(pluginFolder, "*.dll"); var JobList = new List <SchedulerJob>(); foreach (var filePath in filePaths) { var jobAssembly = Assembly.LoadFile(filePath); List <Type> jobTypes = jobAssembly.GetTypes().Where(x => x.GetInterface(nameof(ISchedulerJob)) != null).ToList(); await Task.Run(() => { foreach (Type jobType in jobTypes) { var jobInstance = (ISchedulerJob)Activator.CreateInstance(jobType); //PluginContext.Jobs.Add(new SchedulerJob //{ // Id = jobInstance.Guid, // JobType = jobType, // Instance = jobInstance, // Name = jobType.Name //}); JobList.Add(new SchedulerJob { IsActive = true, Id = jobInstance.Guid, Name = jobInstance.Name, }); } }); if (JobList != null && JobList.Count > 0) { var client = new RestClient(configParameter.jobApiUrl); var request = new RestRequest(configParameter.MethodName, Method.POST); request.AddJsonBody(JobList); // execute the request var response = client.Execute(request); Log.Information($"{response.StatusCode}"); } } await ExecuteScheduler(root, configParameter); }
public ConfigValue GetValue(ConfigParameter parameter) { Lock.EnterReadLock(); try { return GetValueWithoutLock(parameter); } finally { Lock.ExitReadLock(); } }
public static List<Thing> GatherThings(Transport trans) { //setup Camera thing #region Setup Camera thing { ConfigParameter conf = new ConfigParameter() { Name = "AccessUri", Value = "RasPiCamera://10.30.254.223", }; var thing = CameraThing = new Yodiwo.API.Plegma.Thing() { Type = "yodiwo.output.camera", Name = "RasPiCamera ", Config = null, UIHints = new ThingUIHints() { IconURI = "/Content/VirtualGateway/img/icon-thing-genericwebcam.png", }, }; VideoMediaDescriptor video = new VideoMediaDescriptor() { uri = "node://$NodeKey$/" + conf.Value, protocol = "http://", videoDevice = VideoIn.Node, }; thing.Ports = new List<Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output, Name = "Camera Feed", State = video.ToJSON(HtmlEncode: false), Type = Yodiwo.API.Plegma.ePortType.String, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") }, new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Input, Name = "Camera Filter", State = "0", Type = Yodiwo.API.Plegma.ePortType.String, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "1") } }; } #endregion Things.Add(CameraThing); return Things; }
public static List <Thing> GatherThings(Transport trans) { //setup Camera thing #region Setup Camera thing { ConfigParameter conf = new ConfigParameter() { Name = "AccessUri", Value = "RasPiCamera://10.30.254.223", }; var thing = CameraThing = new Yodiwo.API.Plegma.Thing() { Type = "yodiwo.output.camera", Name = "RasPiCamera ", Config = null, UIHints = new ThingUIHints() { IconURI = "/Content/VirtualGateway/img/icon-thing-genericwebcam.png", }, }; VideoMediaDescriptor video = new VideoMediaDescriptor() { uri = "node://$NodeKey$/" + conf.Value, protocol = "http://", videoDevice = VideoIn.Node, }; thing.Ports = new List <Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output, Name = "Camera Feed", State = video.ToJSON(HtmlEncode: false), Type = Yodiwo.API.Plegma.ePortType.String, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") }, new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Input, Name = "Camera Filter", State = "0", Type = Yodiwo.API.Plegma.ePortType.String, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "1") } }; } #endregion Things.Add(CameraThing); return(Things); }
internal override void SetResult(ConfigParameter parameterId, object val) { switch (parameterId) { case ConfigParameter.InputEncoding: this.inputEncoding = (Encoding)val; break; case ConfigParameter.OutputEncoding: this.outputEncoding = (Encoding)val; break; } base.SetResult(parameterId, val); }
public ConfigParameterMenu(ConfigParameterListItem listItem) { Verify.Argument.IsNotNull(listItem, "listItem"); Verify.Argument.IsValidGitObject(listItem.DataContext, "parameter"); _listItem = listItem; _parameter = listItem.DataContext; Items.Add(new ToolStripMenuItem(Resources.StrEditValue, CachedResources.Bitmaps["ImgConfigEdit"], (s, e) => listItem.StartValueEditor())); Items.Add(GuiItemFactory.GetUnsetParameterItem <ToolStripMenuItem>(_parameter)); Items.Add(new ToolStripSeparator()); Items.Add(new ToolStripMenuItem(Resources.StrCopyToClipboard, null, GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrName, _parameter.Name), GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrValue, _parameter.Value))); }
/// <summary> /// save all message in the selected dump layer /// </summary> /// <param name="ServiceInstanceID"></param> /// <param name="MessagesID"></param> /// <param name="btArtifact"></param> private static void SaveMessages(Guid ServiceInstanceID, IEnumerable <Guid> MessagesID, BTArtifactLogic btArtifact) { LogHelper.WriteInfo(ResourceLogic.GetString(ResourceKeyName.MessageSaving)); //retrieve the right layer ITransportLayer accessLayer = ConfigParameter.GettingTheRightLayer(); foreach (Guid gu in MessagesID) { //retrieving the message String sMessage = btArtifact.GetMessageBodyByMessageId(gu, ServiceInstanceID); //save the message accessLayer.SendMessage(sMessage, gu); //updatecounter PerfCounterAsync.UpdateStatistic(); } LogHelper.WriteInfo(ResourceLogic.GetString(ResourceKeyName.MessageSaved)); }
public ActionResult EditEnvironment(string id, string name, ServiceConfig model) { var item = GetConfigurationReader().GetConfiguration(id); var env = (from e in item.Services where e.ServiceName == name select e).First(); env.ServiceName = model.ServiceName; env.Username = model.Username; if (!model.PasswordIsUnchanged) { env.Password = model.Password; } if (env.Parameters == null) { env.Parameters = new List <ConfigParameter>(); } var keyName = Request.Form["keyName"]; var value = Request.Form["keyValue"]; if (keyName.ContainsCharacters()) { var param = (from p in env.Parameters where p.Name == keyName select p).FirstOrDefault(); if (param.IsNull()) { param = new ConfigParameter(); env.Parameters.Add(param); } param.Name = keyName; if (keyName.ToLower().Contains("password")) { param.Value = value.Encrypt("mayTheKeysSupportAllMyValues"); param.BinaryValue = param.Value.GetByteArray(); if (param.Value.Decrypt("mayTheKeysSupportAllMyValues") != value) { throw new StardustCoreException("Encryption validation failed!"); } } else { param.Value = value; } } GetConfigurationReader().WriteConfigurationSet(item, id); ViewBag.Id = id; return(RedirectToAction("EditEnvironment", new { id = id, name = model.ServiceName })); }
public ConfigValue GetValue(ConfigParameter parameter) { _lock.EnterReadLock(); try { var xmlConfig = LoadData(); var item = xmlConfig.GetItem(parameter.Name); if (item != null) { return new ConfigValue(parameter, item.Value, true); } return new ConfigValue(parameter, null, false); } finally { _lock.ExitReadLock(); } }
public static string GetStringValueOrDefault(this KeyedCollection <string, ConfigParameter> parameters, string parameterName, string defaultValue) { if (!parameters.Contains(parameterName)) { return(defaultValue); } ConfigParameter p = parameters[parameterName]; if (p.IsEncrypted) { return(p.SecureValue.ConvertToUnsecureString()); } else { return(p.Value); } }
public static int GetIntValueOrDefault(this KeyedCollection <string, ConfigParameter> parameters, string parameterName, int defaultValue) { if (!parameters.Contains(parameterName)) { return(defaultValue); } ConfigParameter p = parameters[parameterName]; if (int.TryParse(p.Value, out int result)) { return(result); } else { return(defaultValue); } }
static void Main() { try { //check configuration before starting if (ConfigParameter.IsConfigurationOk()) { #if DEBUG LogHelper.WriteInfo(ResourceLogic.GetString(ResourceKeyName.DebugMode)); //init counter PerfCounterAsync.InitPerformanceCounter(); InitializeWatcher(); Console.ReadLine(); PerfCounterAsync.Close(); #else System.ServiceProcess.ServiceBase[] ServicesToRun; // More than one user service may run in the same process. To add // another service to this process, change the following line to // create a second service object. For example, // // ServicesToRun = New System.ServiceProcess.ServiceBase[] {new Service1(), new MySecondUserService()}; // ServicesToRun = new System.ServiceProcess.ServiceBase[] { new ZombieManagementService() }; System.ServiceProcess.ServiceBase.Run(ServicesToRun); #endif } else { LogHelper.WriteError(ResourceLogic.GetString(ResourceKeyName.ErrorValidation)); } } catch (Exception ex) { LogHelper.WriteError(ResourceLogic.GetString(ResourceKeyName.StopService)); LogHelper.WriteError(ex); } }
/// <summary> /// Gets the password from the specified parameter /// </summary> /// <returns>The unencrypted password</returns> public string GetPassword() { string passphrase = string.Empty; if (this.config.Contains(MAParameterNames.PasswordOrPassphrase)) { ConfigParameter parameter = this.config[MAParameterNames.PasswordOrPassphrase]; if (parameter.IsEncrypted) { passphrase = parameter.SecureValue.ToUnsecureString(); } else { passphrase = parameter.Value; } } return(passphrase); }
static void Main(string[] args) { List <dynamic> resultsList = new List <dynamic>(); FimSync_Ezma.EzmaExtension tester = new EzmaExtension(); configCollection foo = new configCollection(); ConfigParameter cpBaseUri = new ConfigParameter("Base URI", _RESTBASEURL); ConfigParameter cpApi = new ConfigParameter("API Key", _APIKEY); ConfigParameter cpLang = new ConfigParameter("Language", _LANG); ConfigParameter cpLIMIT = new ConfigParameter("# of Pages to Return", _LIMITRTNPAGES); foo.Add(cpBaseUri); foo.Add(cpApi); foo.Add(cpLang); foo.Add(cpLIMIT); tester.GetSchema(foo); tester.OpenImportConnection(foo, new Schema(), new OpenImportConnectionRunStep()); tester.GetImportEntries(new GetImportEntriesRunStep()); tester.CloseImportConnection(new CloseImportConnectionRunStep()); Console.WriteLine("Press any key to stop..."); Console.ReadKey(); }
public void SetValue(ConfigParameter parameter, string value) { throw new NotSupportedException(); }
public void SetValue(ConfigParameter parameter, string value) { lock (_lockObject) { if (Parent != null) { Parent.SetValue(parameter, value); } _values[parameter] = new ConfigValue(parameter, value, true); } }
static void homegear_DeviceLinkConfigParameterUpdated(Homegear sender, Device device, Channel channel, Link link, ConfigParameter parameter) { Console.WriteLine("Link config parameter updated: Device type: \"" + device.TypeString + "\", ID: " + device.ID.ToString() + ", Channel: " + channel.Index.ToString() + ", Remote Peer: " + link.RemotePeerID.ToString() + ", Remote Channel: " + link.RemoteChannel.ToString() + ", Parameter Name: \"" + parameter.Name + "\", Value: " + parameter.ToString()); }
public static void CreateThings(Transport trans, Node node) { #region READ CONFIGURATION var SavedThingsConfig = ReadConfig(); if (SavedThingsConfig == null) { DebugEx.Assert("Could not retrieve or create config; startup failed"); return; } //use pin configuration from saved conf file var buzzerPin = SavedThingsConfig[typeof(Buzzer)].Pin; var rgbLedPin = SavedThingsConfig[typeof(RgbLed)].Pin; var soundSensorPin = SavedThingsConfig[typeof(SoundSensor)].Pin; var lightSensorPin = SavedThingsConfig[typeof(LightSensor)].Pin; var buttonPin = SavedThingsConfig[typeof(Button)].Pin; var rotaryAnglePin = SavedThingsConfig[typeof(RotaryAngleSensor)].Pin; var relayPin = SavedThingsConfig[typeof(Relay)].Pin; var htSensorPin = SavedThingsConfig[typeof(TempAndHumidity)].Pin; var ultrasonicPin = SavedThingsConfig[typeof(UltraSonicRanger)].Pin; var lcdPin = SavedThingsConfig[typeof(LCD)].Pin; //use sampling period configuration from saved conf file var gpio_Sampling = SavedThingsConfig[typeof(GPIO)].Period; var soundSensorSampling = SavedThingsConfig[typeof(SoundSensor)].Period; var lightSensorSampling = SavedThingsConfig[typeof(LightSensor)].Period; var buttonSampling = SavedThingsConfig[typeof(Button)].Period; var rotaryAngleSampling = SavedThingsConfig[typeof(RotaryAngleSensor)].Period; var relaySampling = SavedThingsConfig[typeof(Relay)].Period; var htSensorSampling = SavedThingsConfig[typeof(TempAndHumidity)].Period; var ultrasonicSampling = SavedThingsConfig[typeof(UltraSonicRanger)].Period; #endregion #region CREATE SENSORS /* A2MCU */ GPIO GPIO_2 = new GPIO(Pin.DigitalPin2, trans, gpio_Sampling); GPIO GPIO_3 = new GPIO(Pin.DigitalPin3, trans, gpio_Sampling); GPIO GPIO_4 = new GPIO(Pin.DigitalPin4, trans, gpio_Sampling); GPIO GPIO_5 = new GPIO(Pin.DigitalPin5, trans, gpio_Sampling); GPIO GPIO_6 = new GPIO(Pin.DigitalPin6, trans, gpio_Sampling); /* /A2MCU */ Buzzer buzzer = new Buzzer(GrovePiSensor.PinNameToPin[buzzerPin], trans); RgbLed rgbled = new RgbLed(GrovePiSensor.PinNameToPin[rgbLedPin], trans); SoundSensor soundSensor = new SoundSensor(GrovePiSensor.PinNameToPin[soundSensorPin], trans, soundSensorSampling); LightSensor lightSensor = new LightSensor(GrovePiSensor.PinNameToPin[lightSensorPin], trans, lightSensorSampling); Button button = new Button(GrovePiSensor.PinNameToPin[buttonPin], trans, buttonSampling); RotaryAngleSensor rotaryAngleSensor = new RotaryAngleSensor(GrovePiSensor.PinNameToPin[rotaryAnglePin], trans, rotaryAngleSampling); Relay relaySensor = new Relay(GrovePiSensor.PinNameToPin[relayPin], trans, relaySampling); TempAndHumidity htSensor = new TempAndHumidity(GrovePiSensor.PinNameToPin[htSensorPin], trans, htSensorSampling); UltraSonicRanger ultrasonicSensor = new UltraSonicRanger(GrovePiSensor.PinNameToPin[ultrasonicPin], trans, ultrasonicSampling); LCD lcd = new LCD(GrovePiSensor.PinNameToPin[lcdPin], trans); #endregion #region SETUP THINGS #region Setup A2MCU GPIO things List<Thing> gpio_things = new List<Thing>(); for (int i = 2; i <= 6; i++) { //var pinConfig = new ConfigParameter() { Name = "Pin", Value = buzzerPin }; var samplePeriodConfig = new ConfigParameter() { Name = "SamplePeriod", Value = gpio_Sampling.ToStringInvariant() }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "gpio_thing" + i), Type = ThingTypeLibrary.Gpio.Type + PlegmaAPI.ThingModelTypeSeparatorPlusDefault, Name = "GPIO_" + i, Config = new List<ConfigParameter>() { samplePeriodConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/Generic/gpio.png", }, }; thing.Ports = new List<Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Input, Name = "GPO", PortModelId = ModelTypeLibrary.GpioModel_Id, State = "false", Type = Yodiwo.API.Plegma.ePortType.Boolean, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "GPO") }, new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output, Name = "GPI", State = "false", PortModelId = ModelTypeLibrary.GpioModel_Id, Type = Yodiwo.API.Plegma.ePortType.Boolean, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "GPI") } }; thing = node.AddThing(thing); gpio_things.Add(thing); Things.Add(thing); } //gpio thing --> gpio sensor class GPIOs.Add(gpio_things.ElementAt(0), GPIO_2); GPIOs.Add(gpio_things.ElementAt(1), GPIO_3); GPIOs.Add(gpio_things.ElementAt(2), GPIO_4); GPIOs.Add(gpio_things.ElementAt(3), GPIO_5); GPIOs.Add(gpio_things.ElementAt(4), GPIO_6); //gpio thing --> generic sensor class Lookup.Add(gpio_things.ElementAt(0), GPIO_2); Lookup.Add(gpio_things.ElementAt(1), GPIO_3); Lookup.Add(gpio_things.ElementAt(2), GPIO_4); Lookup.Add(gpio_things.ElementAt(3), GPIO_5); Lookup.Add(gpio_things.ElementAt(4), GPIO_6); gpio_things.Clear(); #endregion //setup Buzzer thing #region Setup Buzzer thing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = buzzerPin }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "buzzerthing"), Type = ThingTypeLibrary.Buzzer.Type + PlegmaAPI.ThingModelTypeSeparatorPlusDefault, Name = "Buzzer", Config = new List<ConfigParameter>() { pinConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/buzzer.png", }, }; thing.Ports = new List<Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Input, Name = "BuzzerState", State = "false", PortModelId = ModelTypeLibrary.BuzzerModel_Id, Type = Yodiwo.API.Plegma.ePortType.Decimal, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; BuzzerThing = thing = node.AddThing(thing); } #endregion //setup RgbLed thing #region SetUp RgbLedThing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = rgbLedPin }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "RgbLedThing"), Type = ThingTypeLibrary.Lights.Type + PlegmaAPI.ThingModelTypeSeparator + ThingTypeLibrary.Lights_BooleanModelType, Name = "RgbLed", Config = new List<ConfigParameter>() { pinConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/Generic/thing-genericlight.png", }, }; thing.Ports = new List<Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Input, Name = "RgbLedState", State = "false", PortModelId = ModelTypeLibrary.OnOffLightModel_Id, Type = Yodiwo.API.Plegma.ePortType.Boolean, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; RgbLedThing = thing = node.AddThing(thing); } #endregion //setup SoundSensorThing #region SetUp SoundSensorThing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = soundSensorPin }; var samplePeriodConfig = new ConfigParameter() { Name = "SamplePeriod", Value = soundSensorSampling.ToStringInvariant() }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "SoundSensorThing"), Type = ThingTypeLibrary.SoundSensor.Type + PlegmaAPI.ThingModelTypeSeparatorPlusDefault, Name = "SoundSensor", Config = new List<ConfigParameter>() { pinConfig, samplePeriodConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/sound.png", }, }; thing.Ports = new List<Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output, Name = "Value", State = "0", PortModelId=ModelTypeLibrary.SoundSensorModel_Id, Type = Yodiwo.API.Plegma.ePortType.Integer, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; SoundSensorThing = thing = node.AddThing(thing); } #endregion //setup Light Sensor thing #region SetUp LightSensorThing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = lightSensorPin }; var samplePeriodConfig = new ConfigParameter() { Name = "SamplePeriod", Value = lightSensorSampling.ToStringInvariant() }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "LightSensorThing"), Type = ThingTypeLibrary.LightSensor.Type + PlegmaAPI.ThingModelTypeSeparator + ThingTypeLibrary.LightSensor_NonNormalizedModelType, Name = "LightSensor", Config = new List<ConfigParameter>() { pinConfig, samplePeriodConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/light.png", }, }; thing.Ports = new List<Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output, Name = "Lumens", State = "0", PortModelId = ModelTypeLibrary.Brightness_Id, Type = Yodiwo.API.Plegma.ePortType.Integer, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; LightSensorThing = thing = node.AddThing(thing); } #endregion //setup Button thing #region SetUp ButtonThing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = buttonPin }; var samplePeriodConfig = new ConfigParameter() { Name = "SamplePeriod", Value = buttonSampling.ToStringInvariant() }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "ButtonSensorThing"), Type = ThingTypeLibrary.Button.Type + PlegmaAPI.ThingModelTypeSeparatorPlusDefault, Name = "Button", Config = new List<ConfigParameter>() { pinConfig, samplePeriodConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/Generic/thing-genericbutton.png", }, }; thing.Ports = new List<Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output, Name = "ButtonState", State = "0", PortModelId= ModelTypeLibrary.ButtonModel_OnOffActuatorId, Type = Yodiwo.API.Plegma.ePortType.Boolean, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; ButtonSensorThing = thing = node.AddThing(thing); } #endregion //setup RotaryAngle Sensor thing #region SetUp RotaryAngleSensorThing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = rotaryAnglePin }; var samplePeriodConfig = new ConfigParameter() { Name = "SamplePeriod", Value = rotaryAngleSampling.ToStringInvariant() }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "RotaryAngleSensorThing"), Type = ThingTypeLibrary.Slider.Type + PlegmaAPI.ThingModelTypeSeparatorStr, Name = "Rotary Angle Sensor", Config = new List<ConfigParameter>() { pinConfig, samplePeriodConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/Generic/thing-slider.png", }, }; thing.Ports = new List<Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output, Name = "RotaryAngle", State = "0", PortModelId =ModelTypeLibrary.SliderModel_Id, Type = Yodiwo.API.Plegma.ePortType.Decimal, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; RotaryAngleSensorThing = thing = node.AddThing(thing); } #endregion #if false //setup Relay thing #region SetUp RelayThing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = relayPin }; var samplePeriodConfig = new ConfigParameter() { Name = "SamplePeriod", Value = relaySampling.ToStringInvariant() }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "RelaySensorThing"), Type = ThingTypeLibrary.SwitchActuator.Type + PlegmaAPI.ThingModelTypeSeparator + ThingTypeLibrary.SwitchActuator_RelayModelType, Name = "Relay", Config = new List<ConfigParameter>() { pinConfig, samplePeriodConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/relay.jpg", }, }; thing.Ports = new List<Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output, Name = "RelayState", PortModelId = ModelTypeLibrary.RelayModel_RelayId, State = "0", Type = Yodiwo.API.Plegma.ePortType.Integer, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; RelaySensorThing = thing = node.AddThing(thing); } #endregion #endif //setup Temperature and Humidity Sensor thing #region SetUp HTSensorThing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = htSensorPin }; var samplePeriodConfig = new ConfigParameter() { Name = "SamplePeriod", Value = htSensorSampling.ToStringInvariant() }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "HTSensorThing"), Type = ThingTypeLibrary.HTSensor.Type + PlegmaAPI.ThingModelTypeSeparatorPlusDefault, Name = "Temperature and Humidity Sensor", Config = new List<ConfigParameter>() { pinConfig, samplePeriodConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/ht.png", }, }; thing.Ports = new List<Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output, PortModelId = ModelTypeLibrary.HTSensorModel_TemperatureSensorId, Name = "HT", State = "0", Type = Yodiwo.API.Plegma.ePortType.Integer, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; HTSensorThing = thing = node.AddThing(thing); } #endregion //setup UltraSonic Sensor thing #region SetUp UltrasonicThing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = ultrasonicPin }; var samplePeriodConfig = new ConfigParameter() { Name = "SamplePeriod", Value = ultrasonicSampling.ToStringInvariant() }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "UltrasonicSensorThing"), Type = ThingTypeLibrary.ProximitySensor.Type + PlegmaAPI.ThingModelTypeSeparator + ThingTypeLibrary.ProximitySensor_UltrasonicModelType, Name = "Ultrasonic Sensor", Config = new List<ConfigParameter>() { pinConfig, samplePeriodConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/proximity.png", }, }; thing.Ports = new List<Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output, Name = "cm", State = "0", PortModelId = ModelTypeLibrary.UltrasonicSensorModel_Id, Type = Yodiwo.API.Plegma.ePortType.Integer, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; UltrasonicSensorThing = thing = node.AddThing(thing); } #endregion //setup LCD Sensor thing #region SetUp LCDThing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = lcdPin }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "LCDThing"), Type = ThingTypeLibrary.Lcd.Type + PlegmaAPI.ThingModelTypeSeparatorPlusDefault, Name = "LCD", Config = new List<ConfigParameter>() { pinConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/lcd.png", }, }; thing.Ports = new List<Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Input, Name = "Message", State = "0", PortModelId= ModelTypeLibrary.LcdModel_Id, Type = Yodiwo.API.Plegma.ePortType.String, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; LCDThing = thing = node.AddThing(thing); } #endregion #endregion #region LUT CRETION Things.Add(BuzzerThing); Things.Add(RgbLedThing); Things.Add(SoundSensorThing); Things.Add(LightSensorThing); Things.Add(ButtonSensorThing); Things.Add(RotaryAngleSensorThing); //Things.Add(RelaySensorThing); Things.Add(HTSensorThing); Things.Add(UltrasonicSensorThing); Things.Add(LCDThing); Lookup.Add(BuzzerThing, buzzer); Lookup.Add(RgbLedThing, rgbled); Lookup.Add(SoundSensorThing, soundSensor); Lookup.Add(LightSensorThing, lightSensor); Lookup.Add(ButtonSensorThing, button); Lookup.Add(RotaryAngleSensorThing, rotaryAngleSensor); //Lookup.Add(RelaySensorThing, relaySensor); Lookup.Add(HTSensorThing, htSensor); Lookup.Add(UltrasonicSensorThing, ultrasonicSensor); Lookup.Add(LCDThing, lcd); /* GroveSensors.Add(BuzzerThing.Name, buzzer); GroveSensors.Add(RgbLedThing.Name, rgbled); GroveSensors.Add(SoundSensorThing.Name, soundSensor); GroveSensors.Add(LightSensorThing.Name, lightSensor); GroveSensors.Add(ButtonSensorThing.Name, button); GroveSensors.Add(RotaryAngleSensorThing.Name, rotaryAngleSensor); GroveSensors.Add(RelaySensorThing.Name, relaySensor); GroveSensors.Add(HTSensorThing.Name, htSensor); GroveSensors.Add(UltrasonicSensorThing.Name, ultrasonicSensor); GroveSensors.Add(LCDThing.Name, lcd); */ #endregion #region REGISTER EVENTS foreach (var gpio in GPIOs.Values) gpio.OnGetContinuousDatacb += data => OnGetContinuousDatacb(gpio, data); soundSensor.OnGetContinuousDatacb += data => OnGetContinuousDatacb(soundSensor, data); lightSensor.OnGetContinuousDatacb += data => OnGetContinuousDatacb(lightSensor, data); button.OnGetContinuousDatacb += data => OnGetContinuousDatacb(button, data); rotaryAngleSensor.OnGetContinuousDatacb += data => OnGetContinuousDatacb(rotaryAngleSensor, data); relaySensor.OnGetContinuousDatacb += data => OnGetContinuousDatacb(relaySensor, data); htSensor.OnGetContinuousDatacb += data => OnGetContinuousDatacb(htSensor, data); ultrasonicSensor.OnGetContinuousDatacb += data => OnGetContinuousDatacb(ultrasonicSensor, data); #endregion }
public void SetValue(ConfigParameter parameter, string value) { if (Parent != null) { Parent.SetValue(parameter, value); } Lock.EnterWriteLock(); try { Values[parameter] = new ConfigValue(parameter, value, true); } finally { Lock.ExitWriteLock(); } }
public void SetValue(ConfigParameter parameter, string value) { _lock.EnterWriteLock(); try { var xmlConfig = LoadData(); var item = xmlConfig.GetItem(parameter.Name, create: true); item.Value = value; item.Type = parameter.ParameterType; SaveData(xmlConfig); } finally { _lock.ExitWriteLock(); } }
private async Task ExecuteScheduler(string root, ConfigParameter configParameter) { //var _scheduler = await new StdSchedulerFactory().GetScheduler(); NameValueCollection configuration = new NameValueCollection { { "quartz.scheduler.instanceName", "LocalServer" }, { "quartz.scheduler.instanceId", "LocalServer" }, { "quartz.jobStore.type", "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" }, //{ "quartz.jobStore.useProperties", "true" }, { "quartz.jobStore.dataSource", "default" }, { "quartz.jobStore.tablePrefix", "QRTZ_" }, { "quartz.dataSource.default.connectionString", configParameter.SchedulerConStr }, { "quartz.dataSource.default.provider", "SqlServer" }, { "quartz.serializer.type", "binary" } }; configuration["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz"; configuration["quartz.threadPool.threadCount"] = "5"; configuration["quartz.threadPool.threadPriority"] = "Normal"; //configuration["quartz.plugin.recentHistory.type"] = "Quartz.Plugins.RecentHistory.ExecutionHistoryPlugin, Quartz.Plugins.RecentHistory"; //configuration["quartz.plugin.recentHistory.storeType"] = "Quartz.Plugins.RecentHistory.Db.DbExecutionHistoryStore, SelfHosting.Services"; IScheduler _scheduler = null; try { ISchedulerFactory schedulerFactory = _serviceProvider.GetRequiredService <ISchedulerFactory>(); _scheduler = await schedulerFactory.GetScheduler(); //_scheduler = await new StdSchedulerFactory(configuration).GetScheduler(); //var executionHistoryPlugin = new ExecutionHistoryPlugin() {Name = "ExecutionHistoryPlugin",StoreType = typeof(DbExecutionHistoryStore) }; //_scheduler.ListenerManager.AddJobListener(executionHistoryPlugin); //_scheduler.JobFactory = new JobFactory(_serviceProvider); } catch (Exception exs) { throw; } //Zamanlayıcı başlatıyoruz. //await _scheduler.Start(); Log.Information("Scheduler Başlatıldı"); // Çalışacak olan Müşteri joblarını Apimize istekte bulunarak alıyoruz. var client = new RestClient(configParameter.jobApiUrl); var request = new RestRequest(configParameter.MethodName, Method.GET); request.AddHeader("Content-Type", "application/json"); var tcs = new TaskCompletionSource <IRestResponse>(); client.ExecuteAsync(request, response => { tcs.SetResult(response); }); await tcs.Task; var customerJobs = JsonConvert.DeserializeObject <List <CustomerJob> >(tcs.Task.Result.Content); Log.Information($"{customerJobs.Count} adet customer job alındı"); customerJobs.ForEach(async customerJob => { // Uygun Job ı Abstract Factory Method ile alıyoruz. //var currentJob = CheckSelectJob(customerJob.Job.Id); ///Her bir job için uniq bir key olması lazım yoksa runtime hatası alırız. var jobName = $"{ConstantHelper.JobNamePrefix}{customerJob.Id}"; var jobGroup = $"{ConstantHelper.JobGroupPrefix}{customerJob.Id}"; var jobKey = new JobKey(jobName, jobGroup); //Scheduler'a eklenen bir job'ı tekrar eklememek için check ediyoruz. varsa aynı job'ı tekrar kurmayacak. var exists = await _scheduler.CheckExists(jobKey); if (!exists) { //Çalışacak olan joblara dışarıdan parametre vermemizi sağlar Execute olmadan bu parametreleri alıp işleyebiliriz. JobDataMap jobdataMap = new JobDataMap(); // Job parametrelerini Execute Scheduler'a parametre olarak geçiyoruz. Execute tetiklendiğinde kullanabilmek için //TODO ??? //jobdataMap.Add("BaseUrl", customerJob.Job.BaseUrl); //jobdataMap.Add("EndPoint", customerJob.Job.EndPoint); if (customerJob.CustomerJobParameters == null) { customerJob.CustomerJobParameters = new List <CustomerJobParameter>(); } customerJob.CustomerJobParameters.Add(new CustomerJobParameter() { ParamKey = ConstantHelper.SchedulerJobHelper.CustomerJobIdKey, ParamValue = customerJob.Id.ToString(), ParamSource = customerJob.Customer.CustomerCode }); var customerJobParameters = JsonConvert.SerializeObject(customerJob.CustomerJobParameters.Select(x => new AssignJobParameterItem() { ParamKey = x.ParamKey, ParamSource = x.ParamSource, ParamValue = x.ParamValue }).ToList()); var customerJobSubs = JsonConvert.SerializeObject(customerJob.CustomerJobSubscribers.Select(x => new AssignJobSubscriberItem() { Subscriber = x.Subscriber, SubscriberType = x.SubscriberType, Description = x.Description }).ToList()); jobdataMap.Add(ConstantHelper.SchedulerJobHelper.SchedulerJobDataMapHelper.SchedulerJobNameKey, customerJob.Job.Name); jobdataMap.Add(ConstantHelper.SchedulerJobHelper.SchedulerJobDataMapHelper.SchedulerJobPathRootKey, root); jobdataMap.Add(ConstantHelper.SchedulerJobHelper.SchedulerJobDataMapHelper.SchedulerJobParametersKey, customerJobParameters); jobdataMap.Add(ConstantHelper.SchedulerJobHelper.SchedulerJobDataMapHelper.SchedulerJobSubscribersKey, customerJobSubs); IJobDetail jobDetail = JobBuilder.Create <JobExecuter.JobExecuter>().WithIdentity(jobName, jobGroup).Build(); /*Uniq oluşturduğumuz keyleri burada kullanıyoruz ve Build ile Joblarımızı çalıştıracak olan JobExecuter sınıfını * ayağa kaldırıyoruz. */ var triggerBuilder = TriggerBuilder.Create() .WithIdentity(jobName, jobGroup) .UsingJobData(jobdataMap); if (string.IsNullOrEmpty(customerJob.Cron) == false) { triggerBuilder = triggerBuilder.WithCronSchedule(customerJob.Cron);//Zamanlayıcımızı Trigger içerisinde belirtip hangi zaman diliminde çalışacağını belirtiyoruz. } if (customerJob.StartDate.HasValue) { triggerBuilder.StartAt(customerJob.StartDate.Value); } if (customerJob.EndDate.HasValue) { triggerBuilder.EndAt(customerJob.EndDate.Value); } ITrigger jobTrigger = triggerBuilder.Build(); var result = await _scheduler.ScheduleJob(jobDetail, jobTrigger); } }); }
protected ParameterValue(ConfigParameter configParameter, object untypedValue) { ConfigParameter = configParameter; UntypedValue = untypedValue; }
protected void AddPluginParameter(ConfigParameter pluginParameter) { _PluginParameters.Add(pluginParameter); }
protected void AddConfigParameter(ConfigParameter configParameter) { _ConfigParameters.Add(configParameter); }
public static void CreateThings(Transport trans, Node node) { #region READ CONFIGURATION var SavedThingsConfig = ReadConfig(); if (SavedThingsConfig == null) { DebugEx.Assert("Could not retrieve or create config; startup failed"); return; } //use pin configuration from saved conf file var buzzerPin = SavedThingsConfig[typeof(Buzzer)].Pin; var rgbLedPin = SavedThingsConfig[typeof(RgbLed)].Pin; var soundSensorPin = SavedThingsConfig[typeof(SoundSensor)].Pin; var lightSensorPin = SavedThingsConfig[typeof(LightSensor)].Pin; var buttonPin = SavedThingsConfig[typeof(Button)].Pin; var rotaryAnglePin = SavedThingsConfig[typeof(RotaryAngleSensor)].Pin; var relayPin = SavedThingsConfig[typeof(Relay)].Pin; var htSensorPin = SavedThingsConfig[typeof(TempAndHumidity)].Pin; var ultrasonicPin = SavedThingsConfig[typeof(UltraSonicRanger)].Pin; var lcdPin = SavedThingsConfig[typeof(LCD)].Pin; //use sampling period configuration from saved conf file var gpio_Sampling = SavedThingsConfig[typeof(GPIO)].Period; var soundSensorSampling = SavedThingsConfig[typeof(SoundSensor)].Period; var lightSensorSampling = SavedThingsConfig[typeof(LightSensor)].Period; var buttonSampling = SavedThingsConfig[typeof(Button)].Period; var rotaryAngleSampling = SavedThingsConfig[typeof(RotaryAngleSensor)].Period; var relaySampling = SavedThingsConfig[typeof(Relay)].Period; var htSensorSampling = SavedThingsConfig[typeof(TempAndHumidity)].Period; var ultrasonicSampling = SavedThingsConfig[typeof(UltraSonicRanger)].Period; #endregion #region CREATE SENSORS /* A2MCU */ GPIO GPIO_2 = new GPIO(Pin.DigitalPin2, trans, gpio_Sampling); GPIO GPIO_3 = new GPIO(Pin.DigitalPin3, trans, gpio_Sampling); GPIO GPIO_4 = new GPIO(Pin.DigitalPin4, trans, gpio_Sampling); GPIO GPIO_5 = new GPIO(Pin.DigitalPin5, trans, gpio_Sampling); GPIO GPIO_6 = new GPIO(Pin.DigitalPin6, trans, gpio_Sampling); /* /A2MCU */ Buzzer buzzer = new Buzzer(GrovePiSensor.PinNameToPin[buzzerPin], trans); RgbLed rgbled = new RgbLed(GrovePiSensor.PinNameToPin[rgbLedPin], trans); SoundSensor soundSensor = new SoundSensor(GrovePiSensor.PinNameToPin[soundSensorPin], trans, soundSensorSampling); LightSensor lightSensor = new LightSensor(GrovePiSensor.PinNameToPin[lightSensorPin], trans, lightSensorSampling); Button button = new Button(GrovePiSensor.PinNameToPin[buttonPin], trans, buttonSampling); RotaryAngleSensor rotaryAngleSensor = new RotaryAngleSensor(GrovePiSensor.PinNameToPin[rotaryAnglePin], trans, rotaryAngleSampling); Relay relaySensor = new Relay(GrovePiSensor.PinNameToPin[relayPin], trans, relaySampling); TempAndHumidity htSensor = new TempAndHumidity(GrovePiSensor.PinNameToPin[htSensorPin], trans, htSensorSampling); UltraSonicRanger ultrasonicSensor = new UltraSonicRanger(GrovePiSensor.PinNameToPin[ultrasonicPin], trans, ultrasonicSampling); LCD lcd = new LCD(GrovePiSensor.PinNameToPin[lcdPin], trans); #endregion #region SETUP THINGS #region Setup A2MCU GPIO things List <Thing> gpio_things = new List <Thing>(); for (int i = 2; i <= 6; i++) { //var pinConfig = new ConfigParameter() { Name = "Pin", Value = buzzerPin }; var samplePeriodConfig = new ConfigParameter() { Name = "SamplePeriod", Value = gpio_Sampling.ToStringInvariant() }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "gpio_thing" + i), Type = ThingTypeLibrary.Gpio.Type + PlegmaAPI.ThingModelTypeSeparatorPlusDefault, Name = "GPIO_" + i, Config = new List <ConfigParameter>() { samplePeriodConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/Generic/gpio.png", }, }; thing.Ports = new List <Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Input, Name = "GPO", PortModelId = ModelTypeLibrary.GpioModel_Id, State = "false", Type = Yodiwo.API.Plegma.ePortType.Boolean, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "GPO") }, new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output, Name = "GPI", State = "false", PortModelId = ModelTypeLibrary.GpioModel_Id, Type = Yodiwo.API.Plegma.ePortType.Boolean, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "GPI") } }; thing = node.AddThing(thing); gpio_things.Add(thing); Things.Add(thing); } //gpio thing --> gpio sensor class GPIOs.Add(gpio_things.ElementAt(0), GPIO_2); GPIOs.Add(gpio_things.ElementAt(1), GPIO_3); GPIOs.Add(gpio_things.ElementAt(2), GPIO_4); GPIOs.Add(gpio_things.ElementAt(3), GPIO_5); GPIOs.Add(gpio_things.ElementAt(4), GPIO_6); //gpio thing --> generic sensor class Lookup.Add(gpio_things.ElementAt(0), GPIO_2); Lookup.Add(gpio_things.ElementAt(1), GPIO_3); Lookup.Add(gpio_things.ElementAt(2), GPIO_4); Lookup.Add(gpio_things.ElementAt(3), GPIO_5); Lookup.Add(gpio_things.ElementAt(4), GPIO_6); gpio_things.Clear(); #endregion //setup Buzzer thing #region Setup Buzzer thing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = buzzerPin }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "buzzerthing"), Type = ThingTypeLibrary.Buzzer.Type + PlegmaAPI.ThingModelTypeSeparatorPlusDefault, Name = "Buzzer", Config = new List <ConfigParameter>() { pinConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/buzzer.png", }, }; thing.Ports = new List <Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Input, Name = "BuzzerState", State = "false", PortModelId = ModelTypeLibrary.BuzzerModel_Id, Type = Yodiwo.API.Plegma.ePortType.Decimal, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; BuzzerThing = thing = node.AddThing(thing); } #endregion //setup RgbLed thing #region SetUp RgbLedThing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = rgbLedPin }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "RgbLedThing"), Type = ThingTypeLibrary.Lights.Type + PlegmaAPI.ThingModelTypeSeparator + ThingTypeLibrary.Lights_BooleanModelType, Name = "RgbLed", Config = new List <ConfigParameter>() { pinConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/Generic/thing-genericlight.png", }, }; thing.Ports = new List <Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Input, Name = "RgbLedState", State = "false", PortModelId = ModelTypeLibrary.OnOffLightModel_Id, Type = Yodiwo.API.Plegma.ePortType.Boolean, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; RgbLedThing = thing = node.AddThing(thing); } #endregion //setup SoundSensorThing #region SetUp SoundSensorThing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = soundSensorPin }; var samplePeriodConfig = new ConfigParameter() { Name = "SamplePeriod", Value = soundSensorSampling.ToStringInvariant() }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "SoundSensorThing"), Type = ThingTypeLibrary.SoundSensor.Type + PlegmaAPI.ThingModelTypeSeparatorPlusDefault, Name = "SoundSensor", Config = new List <ConfigParameter>() { pinConfig, samplePeriodConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/sound.png", }, }; thing.Ports = new List <Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output, Name = "Value", State = "0", PortModelId = ModelTypeLibrary.SoundSensorModel_Id, Type = Yodiwo.API.Plegma.ePortType.Integer, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; SoundSensorThing = thing = node.AddThing(thing); } #endregion //setup Light Sensor thing #region SetUp LightSensorThing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = lightSensorPin }; var samplePeriodConfig = new ConfigParameter() { Name = "SamplePeriod", Value = lightSensorSampling.ToStringInvariant() }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "LightSensorThing"), Type = ThingTypeLibrary.LightSensor.Type + PlegmaAPI.ThingModelTypeSeparator + ThingTypeLibrary.LightSensor_NonNormalizedModelType, Name = "LightSensor", Config = new List <ConfigParameter>() { pinConfig, samplePeriodConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/light.png", }, }; thing.Ports = new List <Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output, Name = "Lumens", State = "0", PortModelId = ModelTypeLibrary.Brightness_Id, Type = Yodiwo.API.Plegma.ePortType.Integer, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; LightSensorThing = thing = node.AddThing(thing); } #endregion //setup Button thing #region SetUp ButtonThing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = buttonPin }; var samplePeriodConfig = new ConfigParameter() { Name = "SamplePeriod", Value = buttonSampling.ToStringInvariant() }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "ButtonSensorThing"), Type = ThingTypeLibrary.Button.Type + PlegmaAPI.ThingModelTypeSeparatorPlusDefault, Name = "Button", Config = new List <ConfigParameter>() { pinConfig, samplePeriodConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/Generic/thing-genericbutton.png", }, }; thing.Ports = new List <Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output, Name = "ButtonState", State = "0", PortModelId = ModelTypeLibrary.ButtonModel_OnOffActuatorId, Type = Yodiwo.API.Plegma.ePortType.Boolean, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; ButtonSensorThing = thing = node.AddThing(thing); } #endregion //setup RotaryAngle Sensor thing #region SetUp RotaryAngleSensorThing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = rotaryAnglePin }; var samplePeriodConfig = new ConfigParameter() { Name = "SamplePeriod", Value = rotaryAngleSampling.ToStringInvariant() }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "RotaryAngleSensorThing"), Type = ThingTypeLibrary.Slider.Type + PlegmaAPI.ThingModelTypeSeparatorStr, Name = "Rotary Angle Sensor", Config = new List <ConfigParameter>() { pinConfig, samplePeriodConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/Generic/thing-slider.png", }, }; thing.Ports = new List <Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output, Name = "RotaryAngle", State = "0", PortModelId = ModelTypeLibrary.SliderModel_Id, Type = Yodiwo.API.Plegma.ePortType.Decimal, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; RotaryAngleSensorThing = thing = node.AddThing(thing); } #endregion #if false //setup Relay thing #region SetUp RelayThing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = relayPin }; var samplePeriodConfig = new ConfigParameter() { Name = "SamplePeriod", Value = relaySampling.ToStringInvariant() }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "RelaySensorThing"), Type = ThingTypeLibrary.SwitchActuator.Type + PlegmaAPI.ThingModelTypeSeparator + ThingTypeLibrary.SwitchActuator_RelayModelType, Name = "Relay", Config = new List <ConfigParameter>() { pinConfig, samplePeriodConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/relay.jpg", }, }; thing.Ports = new List <Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output, Name = "RelayState", PortModelId = ModelTypeLibrary.RelayModel_RelayId, State = "0", Type = Yodiwo.API.Plegma.ePortType.Integer, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; RelaySensorThing = thing = node.AddThing(thing); } #endregion #endif //setup Temperature and Humidity Sensor thing #region SetUp HTSensorThing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = htSensorPin }; var samplePeriodConfig = new ConfigParameter() { Name = "SamplePeriod", Value = htSensorSampling.ToStringInvariant() }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "HTSensorThing"), Type = ThingTypeLibrary.HTSensor.Type + PlegmaAPI.ThingModelTypeSeparatorPlusDefault, Name = "Temperature and Humidity Sensor", Config = new List <ConfigParameter>() { pinConfig, samplePeriodConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/ht.png", }, }; thing.Ports = new List <Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output, PortModelId = ModelTypeLibrary.HTSensorModel_TemperatureSensorId, Name = "HT", State = "0", Type = Yodiwo.API.Plegma.ePortType.Integer, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; HTSensorThing = thing = node.AddThing(thing); } #endregion //setup UltraSonic Sensor thing #region SetUp UltrasonicThing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = ultrasonicPin }; var samplePeriodConfig = new ConfigParameter() { Name = "SamplePeriod", Value = ultrasonicSampling.ToStringInvariant() }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "UltrasonicSensorThing"), Type = ThingTypeLibrary.ProximitySensor.Type + PlegmaAPI.ThingModelTypeSeparator + ThingTypeLibrary.ProximitySensor_UltrasonicModelType, Name = "Ultrasonic Sensor", Config = new List <ConfigParameter>() { pinConfig, samplePeriodConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/proximity.png", }, }; thing.Ports = new List <Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output, Name = "cm", State = "0", PortModelId = ModelTypeLibrary.UltrasonicSensorModel_Id, Type = Yodiwo.API.Plegma.ePortType.Integer, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; UltrasonicSensorThing = thing = node.AddThing(thing); } #endregion //setup LCD Sensor thing #region SetUp LCDThing { var pinConfig = new ConfigParameter() { Name = "Pin", Value = lcdPin }; var thing = new Yodiwo.API.Plegma.Thing() { ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "LCDThing"), Type = ThingTypeLibrary.Lcd.Type + PlegmaAPI.ThingModelTypeSeparatorPlusDefault, Name = "LCD", Config = new List <ConfigParameter>() { pinConfig }, UIHints = new ThingUIHints() { IconURI = "/Content/img/icons/lcd.png", }, }; thing.Ports = new List <Yodiwo.API.Plegma.Port>() { new Yodiwo.API.Plegma.Port() { ioDirection = Yodiwo.API.Plegma.ioPortDirection.Input, Name = "Message", State = "0", PortModelId = ModelTypeLibrary.LcdModel_Id, Type = Yodiwo.API.Plegma.ePortType.String, PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0") } }; LCDThing = thing = node.AddThing(thing); } #endregion #endregion #region LUT CRETION Things.Add(BuzzerThing); Things.Add(RgbLedThing); Things.Add(SoundSensorThing); Things.Add(LightSensorThing); Things.Add(ButtonSensorThing); Things.Add(RotaryAngleSensorThing); //Things.Add(RelaySensorThing); Things.Add(HTSensorThing); Things.Add(UltrasonicSensorThing); Things.Add(LCDThing); Lookup.Add(BuzzerThing, buzzer); Lookup.Add(RgbLedThing, rgbled); Lookup.Add(SoundSensorThing, soundSensor); Lookup.Add(LightSensorThing, lightSensor); Lookup.Add(ButtonSensorThing, button); Lookup.Add(RotaryAngleSensorThing, rotaryAngleSensor); //Lookup.Add(RelaySensorThing, relaySensor); Lookup.Add(HTSensorThing, htSensor); Lookup.Add(UltrasonicSensorThing, ultrasonicSensor); Lookup.Add(LCDThing, lcd); /* * GroveSensors.Add(BuzzerThing.Name, buzzer); * GroveSensors.Add(RgbLedThing.Name, rgbled); * GroveSensors.Add(SoundSensorThing.Name, soundSensor); * GroveSensors.Add(LightSensorThing.Name, lightSensor); * GroveSensors.Add(ButtonSensorThing.Name, button); * GroveSensors.Add(RotaryAngleSensorThing.Name, rotaryAngleSensor); * GroveSensors.Add(RelaySensorThing.Name, relaySensor); * GroveSensors.Add(HTSensorThing.Name, htSensor); * GroveSensors.Add(UltrasonicSensorThing.Name, ultrasonicSensor); * GroveSensors.Add(LCDThing.Name, lcd); */ #endregion #region REGISTER EVENTS foreach (var gpio in GPIOs.Values) { gpio.OnGetContinuousDatacb += data => OnGetContinuousDatacb(gpio, data); } soundSensor.OnGetContinuousDatacb += data => OnGetContinuousDatacb(soundSensor, data); lightSensor.OnGetContinuousDatacb += data => OnGetContinuousDatacb(lightSensor, data); button.OnGetContinuousDatacb += data => OnGetContinuousDatacb(button, data); rotaryAngleSensor.OnGetContinuousDatacb += data => OnGetContinuousDatacb(rotaryAngleSensor, data); relaySensor.OnGetContinuousDatacb += data => OnGetContinuousDatacb(relaySensor, data); htSensor.OnGetContinuousDatacb += data => OnGetContinuousDatacb(htSensor, data); ultrasonicSensor.OnGetContinuousDatacb += data => OnGetContinuousDatacb(ultrasonicSensor, data); #endregion }
private ConfigValue GetValueWithoutLock(ConfigParameter parameter) { ConfigValue value; if (_values.TryGetValue(parameter, out value)) { return value; } if (Parent == null) { // No parent and no value return new ConfigValue(parameter, null, false); } value = Parent.GetValue(parameter); _values.Add(parameter, value); return value; }
public static ErrorCode SetParameterInt32(void *handle, ConfigParameter paramId, int value) { return(driver.c_SparkMax_SetParameterInt32(handle, paramId, value)); }
public double Value => IsValid() ? (IsNull() ? throw new InvalidValueException(ConfigParameter, "null") : Converter.TextToDouble(Text).Value) : throw new InvalidValueException(ConfigParameter, Text);
internal virtual void SetResult(ConfigParameter parameterId, object val) { }
public static ErrorCode GetParameterUint32(void *handle, ConfigParameter paramId, uint *value) { return(driver.c_SparkMax_GetParameterUint32(handle, paramId, value)); }
public ConfigValue(ConfigParameter param, string value, bool hasValue) { Parameter = param; Value = value; HasValue = hasValue; }
void IResultsFeedback.Set(ConfigParameter parameterId, object val) { SetResult(parameterId, val); }
public static ErrorCode GetParameterBool(void *handle, ConfigParameter paramId, byte *value) { return(driver.c_SparkMax_GetParameterBool(handle, paramId, value)); }