Skip to content
Permalink
Browse files

updated docs

  • Loading branch information...
p3root committed Feb 27, 2019
1 parent 3ed4ef2 commit a6f20779596a94738a0974dff601af649b0b1d43
@@ -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
{
/// <summary>
/// unique guid for the input value
/// </summary>
public static readonly Guid RuleInput1 = new Guid("38b8e905-ece3-4878-96f3-22466e779099");
/// <summary>
/// unique id for the output value
/// </summary>
public static readonly Guid RuleOutput = new Guid("eeac47eb-ad93-432c-8317-c9ee7e322d22");
/// <summary>
/// Rule name, used for logging
/// </summary>
public override string RuleName => "Math.Ceiling";
/// <summary>
/// Version
/// </summary>
public override Version RuleVersion => new Version(1, 0, 0, 0);
/// <summary>
/// Unique id for the rule block
/// </summary>
public override Guid RuleGuid => new Guid("0cdecb57-326a-4f8d-9474-e31cb515964c");
/// <summary>
/// Init method to provide localization data
/// </summary>
/// <param name="provider"></param>
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"));
}
/// <summary>
/// Init method for your rule design
/// </summary>
/// <param name="factory"></param>
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);
}
/// <summary>
/// Init method to create a instance of your rule
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
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);
}
/// <summary>
/// Callback when a input value has changed, you can calculate multiple output values at once, and return a list of changed output values
/// </summary>
/// <param name="instance">The input value which has changed</param>
/// <param name="source">The source from where the value is dispatched</param>
/// <param name="value">The value itself</param>
/// <returns></returns>
protected override IList<IRuleOutputChanged> 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
{
/// <summary>
/// unique guid for the input value
/// </summary>
public static readonly Guid RuleInput1 = new Guid("38b8e905-ece3-4878-96f3-22466e779099");
/// <summary>
/// unique id for the output value
/// </summary>
public static readonly Guid RuleOutput = new Guid("eeac47eb-ad93-432c-8317-c9ee7e322d22");
/// <summary>
/// Rule name, used for logging
/// </summary>
public override string RuleName => "Math.Ceiling";
/// <summary>
/// Version
/// </summary>
public override Version RuleVersion => new Version(1, 0, 0, 0);
/// <summary>
/// Unique id for the rule block
/// </summary>
public override Guid RuleGuid => new Guid("0cdecb57-326a-4f8d-9474-e31cb515964c");
/// <summary>
/// Init method to provide localization data
/// </summary>
/// <param name="provider"></param>
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"));
}
/// <summary>
/// Init method for your rule design
/// </summary>
/// <param name="factory"></param>
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);
}
/// <summary>
/// Init method to create a instance of your rule
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
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);
}
/// <summary>
/// Callback when a input value has changed, you can calculate multiple output values at once, and return a list of changed output values
/// </summary>
/// <param name="instance">The input value which has changed</param>
/// <param name="source">The source from where the value is dispatched</param>
/// <param name="value">The value itself</param>
/// <returns></returns>
protected override IList<IRuleOutputChanged> 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)));
}
}
```
@@ -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
- name: Introduction
href: intro.md

- name: CLI
href: automatica-cli.md

- name: Drivers
href: drivers.md

- name: Logics
href: logics.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.
@@ -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)

0 comments on commit a6f2077

Please sign in to comment.
You can’t perform that action at this time.