diff --git a/src/automatica.core/Automatica.Core.Doc/dev/rules.md b/src/automatica.core/Automatica.Core.Doc/dev/logics.md similarity index 96% rename from src/automatica.core/Automatica.Core.Doc/dev/rules.md rename to src/automatica.core/Automatica.Core.Doc/dev/logics.md index f67492c88..625aeebe2 100644 --- a/src/automatica.core/Automatica.Core.Doc/dev/rules.md +++ b/src/automatica.core/Automatica.Core.Doc/dev/logics.md @@ -1,106 +1,106 @@ -# Automatica.Core.Rule -## How to -The RuleFactory is your entry point to Automtaica.Core. See the [API](/api/Automatica.Core.Rule.RuleFactory.html). - -Here is a simple example on how to create a rule block using a ceileing function. - -### RuleFactory -In the RuleFactory you design how the rule block looks. How many & which inputs, outputs and parameters. - -```C# -public class CeilingRuleFactory : RuleFactory -{ - /// - /// unique guid for the input value - /// - public static readonly Guid RuleInput1 = new Guid("38b8e905-ece3-4878-96f3-22466e779099"); - - /// - /// unique id for the output value - /// - public static readonly Guid RuleOutput = new Guid("eeac47eb-ad93-432c-8317-c9ee7e322d22"); - - /// - /// Rule name, used for logging - /// - public override string RuleName => "Math.Ceiling"; - - /// - /// Version - /// - public override Version RuleVersion => new Version(1, 0, 0, 0); - - /// - /// Unique id for the rule block - /// - public override Guid RuleGuid => new Guid("0cdecb57-326a-4f8d-9474-e31cb515964c"); - - /// - /// Init method to provide localization data - /// - /// - public override void InitLocalization(ILocalizationProvider provider) - { - string directory = new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName; - provider.AddLocalization(Path.Combine(directory, "Math-de.json"), CultureInfo.GetCultureInfo("de-DE")); - provider.AddLocalization(Path.Combine(directory, "Math-en.json"), CultureInfo.GetCultureInfo("en-US")); - } - - /// - /// Init method for your rule design - /// - /// - public override void InitTemplates(IRuleTemplateFactory factory) - { - factory.CreateRuleTemplate(RuleGuid, "MATH.CEILING.NAME", "MATH.CEILING.DESCRIPTION", - "math.ceiling", "MATH.NAME", 100, 100); - - factory.CreateRuleInterfaceTemplate(RuleInput1, "I1", "MATH.CEILING.INPUT.DESCRIPTION", RuleGuid, RuleInterfaceDirection.Input, 1, 1); - - factory.CreateRuleInterfaceTemplate(RuleOutput, "O", "MATH.CEILING.OUTPUT.DESCRIPTION", RuleGuid, RuleInterfaceDirection.Output, 0, 1); - } - - /// - /// Init method to create a instance of your rule - /// - /// - /// - public override IRule CreateRuleInstance(IRuleContext context) - { - return new CeilingRule(context); - } -} -``` - -### Rule implementation -```C# -public class CeilingRule : Automatica.Core.Rule.Rule -{ - private double _i1 = 0.0; - - private readonly RuleInterfaceInstance _output; - - public CeilingRule(IRuleContext context) : base(context) - { - _output = context.RuleInstance.RuleInterfaceInstance.SingleOrDefault(a => - a.This2RuleInterfaceTemplate == CeilingRuleFactory.RuleOutput); - } - - /// - /// Callback when a input value has changed, you can calculate multiple output values at once, and return a list of changed output values - /// - /// The input value which has changed - /// The source from where the value is dispatched - /// The value itself - /// - protected override IList InputValueChanged(RuleInterfaceInstance instance, IDispatchable source, object value) - { - if (instance.This2RuleInterfaceTemplate == CeilingRuleFactory.RuleInput1 && value != null) - { - _i1 = Convert.ToDouble(value); - } - - return SingleOutputChanged(new RuleOutputChanged(_output, System.Math.Ceiling(_i1))); - } -} -``` +# Automatica.Core.Logic +## How to +The RuleFactory is your entry point to Automtaica.Core. See the [API](/api/Automatica.Core.Rule.RuleFactory.html). + +Here is a simple example on how to create a rule block using a ceileing function. + +### RuleFactory +In the RuleFactory you design how the rule block looks. How many & which inputs, outputs and parameters. + +```C# +public class CeilingRuleFactory : RuleFactory +{ + /// + /// unique guid for the input value + /// + public static readonly Guid RuleInput1 = new Guid("38b8e905-ece3-4878-96f3-22466e779099"); + + /// + /// unique id for the output value + /// + public static readonly Guid RuleOutput = new Guid("eeac47eb-ad93-432c-8317-c9ee7e322d22"); + + /// + /// Rule name, used for logging + /// + public override string RuleName => "Math.Ceiling"; + + /// + /// Version + /// + public override Version RuleVersion => new Version(1, 0, 0, 0); + + /// + /// Unique id for the rule block + /// + public override Guid RuleGuid => new Guid("0cdecb57-326a-4f8d-9474-e31cb515964c"); + + /// + /// Init method to provide localization data + /// + /// + public override void InitLocalization(ILocalizationProvider provider) + { + string directory = new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName; + provider.AddLocalization(Path.Combine(directory, "Math-de.json"), CultureInfo.GetCultureInfo("de-DE")); + provider.AddLocalization(Path.Combine(directory, "Math-en.json"), CultureInfo.GetCultureInfo("en-US")); + } + + /// + /// Init method for your rule design + /// + /// + public override void InitTemplates(IRuleTemplateFactory factory) + { + factory.CreateRuleTemplate(RuleGuid, "MATH.CEILING.NAME", "MATH.CEILING.DESCRIPTION", + "math.ceiling", "MATH.NAME", 100, 100); + + factory.CreateRuleInterfaceTemplate(RuleInput1, "I1", "MATH.CEILING.INPUT.DESCRIPTION", RuleGuid, RuleInterfaceDirection.Input, 1, 1); + + factory.CreateRuleInterfaceTemplate(RuleOutput, "O", "MATH.CEILING.OUTPUT.DESCRIPTION", RuleGuid, RuleInterfaceDirection.Output, 0, 1); + } + + /// + /// Init method to create a instance of your rule + /// + /// + /// + public override IRule CreateRuleInstance(IRuleContext context) + { + return new CeilingRule(context); + } +} +``` + +### Rule implementation +```C# +public class CeilingRule : Automatica.Core.Rule.Rule +{ + private double _i1 = 0.0; + + private readonly RuleInterfaceInstance _output; + + public CeilingRule(IRuleContext context) : base(context) + { + _output = context.RuleInstance.RuleInterfaceInstance.SingleOrDefault(a => + a.This2RuleInterfaceTemplate == CeilingRuleFactory.RuleOutput); + } + + /// + /// Callback when a input value has changed, you can calculate multiple output values at once, and return a list of changed output values + /// + /// The input value which has changed + /// The source from where the value is dispatched + /// The value itself + /// + protected override IList InputValueChanged(RuleInterfaceInstance instance, IDispatchable source, object value) + { + if (instance.This2RuleInterfaceTemplate == CeilingRuleFactory.RuleInput1 && value != null) + { + _i1 = Convert.ToDouble(value); + } + + return SingleOutputChanged(new RuleOutputChanged(_output, System.Math.Ceiling(_i1))); + } +} +``` diff --git a/src/automatica.core/Automatica.Core.Doc/dev/toc.yml b/src/automatica.core/Automatica.Core.Doc/dev/toc.yml index 20abb515a..77455c494 100644 --- a/src/automatica.core/Automatica.Core.Doc/dev/toc.yml +++ b/src/automatica.core/Automatica.Core.Doc/dev/toc.yml @@ -1,11 +1,11 @@ -- name: Introduction - href: intro.md - -- name: CLI - href: automatica-cli.md - -- name: Drivers - href: drivers.md - -- name: Rules - href: rules.md \ No newline at end of file +- name: Introduction + href: intro.md + +- name: CLI + href: automatica-cli.md + +- name: Drivers + href: drivers.md + +- name: Logics + href: logics.md \ No newline at end of file diff --git a/src/automatica.core/Automatica.Core.Doc/index.md b/src/automatica.core/Automatica.Core.Doc/index.md index c7e2c73d0..5c4b4f1b5 100644 --- a/src/automatica.core/Automatica.Core.Doc/index.md +++ b/src/automatica.core/Automatica.Core.Doc/index.md @@ -1,12 +1,15 @@ -# Automatica.Core (YaaS) -Automatica.Core is a building management software written in .NET Core. - -## Why YaaS? (Yet another automation server) -My intention in Automatica.Core was to build a system which can run on different hardware and different operating sytems. In case of a "Smart Home" you can run Automatica.Core on a RaspberryPi using the image in the download section. -In case of a shopping mall where you have 10.000 or event more datapoints to manage, you can run Automatica.Core on a Windows or a Linux x64 machine. - -## Why a new automation server? -Because I can :) And I don't like the other systems available on the market. - -## Developers -See the [developer docu](dev/intro.md) for more info. +# Automatica.Core +Automatica.Core is a building management software written in .NET Core. + +## Why another building automation system? +My intention in Automatica.Core was to build a system which can run on different hardware and different operating sytems. In case of a "Smart Home" you can run Automatica.Core on a RaspberryPi using the image in the download section. +In case of a shopping mall where you have 10.000 or event more datapoints to manage, you can run Automatica.Core on a Windows or a Linux x64 machine. + +Also a big reason why I used .NET C# - it is easy to unterstand. Everybody who knows C# can write drivers/logics for the system. + + +## Why a new automation server? +Because I can :) And I don't like the other systems available on the market. + +## Developers +See the [developer docu](dev/intro.md) for more info. diff --git a/src/automatica.core/Automatica.Core.Doc/user/intro.md b/src/automatica.core/Automatica.Core.Doc/user/intro.md index 0685509a7..d509001a3 100644 --- a/src/automatica.core/Automatica.Core.Doc/user/intro.md +++ b/src/automatica.core/Automatica.Core.Doc/user/intro.md @@ -1,12 +1,22 @@ -# End-User Documentation -# How does Automatica.Core works? -Automatica.Core works like a charm. But see more at [How-To](tutorials/index.md) - -## Prebuilt Drivers & Rules -There is a enormous set of prebuilt drivers and rules. - -### Drivers -[Drivers](drivers) - -### Rules +# End-User Documentation +# How does Automatica.Core works? +Automatica.Core works like a charm. But see more at [How-To](tutorials/index.md) + +## Login +The default credentials are + +~~~ +Username: sa +Password: sa +~~~ + +I would recommend to change this after the first login! + +## Prebuilt Drivers & Rules +There is a enormous set of prebuilt drivers and rules. + +### Drivers +[Drivers](drivers) + +### Rules [Rules](rules) \ No newline at end of file