-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c8879b
commit 341650a
Showing
8 changed files
with
262 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Diagnostics; | ||
|
||
namespace Avalon | ||
{ | ||
public class AddNumber : FunctionDefinition | ||
{ | ||
|
||
public AddNumber() | ||
{ | ||
Setup(); | ||
DefineFunction(); | ||
} | ||
|
||
void Setup() | ||
{ | ||
ExpectedParameters = new Dictionary<string, ReferenceTuple>() | ||
{ | ||
{ "a", new ReferenceTuple(StateMachineVariableType.Decimal, false) }, | ||
{ "b", new ReferenceTuple(StateMachineVariableType.Decimal, false) }, | ||
{ "out", new ReferenceTuple(StateMachineVariableType.Decimal, false, VariableIO.Out) } | ||
}; | ||
} | ||
|
||
protected override void DefineFunction() | ||
{ | ||
Name = nameof(AddNumber); | ||
Function = () => | ||
{ | ||
var a = Parameters["a"].GetDecimal(); | ||
var b = Parameters["b"].GetDecimal(); | ||
|
||
Debug.WriteLine($"{a} + {b} = {a + b}"); | ||
|
||
Parameters["out"].SetValue(a + b); | ||
|
||
return 1; | ||
}; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System.Diagnostics; | ||
|
||
namespace Avalon | ||
{ | ||
/// <summary> | ||
/// Divide Number Function Definition | ||
/// </summary> | ||
public class DivideNumber : FunctionDefinition | ||
{ | ||
|
||
|
||
public DivideNumber() | ||
{ | ||
Setup(); | ||
DefineFunction(); | ||
} | ||
|
||
void Setup() | ||
{ | ||
ExpectedParameters = new Dictionary<string, ReferenceTuple>() | ||
{ | ||
{ "a", new ReferenceTuple(StateMachineVariableType.Decimal, false) }, | ||
{ "b", new ReferenceTuple(StateMachineVariableType.Decimal, false) }, | ||
{ "out", new ReferenceTuple(StateMachineVariableType.Decimal, false, VariableIO.Out) } | ||
}; | ||
} | ||
|
||
protected override void DefineFunction() | ||
{ | ||
Name = nameof(DivideNumber); | ||
Function = () => | ||
{ | ||
var a = Parameters["a"].GetDecimal(); | ||
var b = Parameters["b"].GetDecimal(); | ||
|
||
if (b == 0) | ||
{ | ||
Debug.WriteLine("Cannot divide by zero"); | ||
return -1; | ||
} | ||
|
||
Debug.WriteLine($"{a} / {b} = {a / b}"); | ||
|
||
Parameters["out"].SetValue(a / b); | ||
|
||
return 1; | ||
}; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System.Diagnostics; | ||
|
||
namespace Avalon | ||
{ | ||
/// <summary> | ||
/// Multiply Number Function Definition | ||
/// </summary> | ||
public class MultiplyNumber : FunctionDefinition | ||
{ | ||
|
||
public MultiplyNumber() | ||
{ | ||
Setup(); | ||
DefineFunction(); | ||
} | ||
|
||
void Setup() | ||
{ | ||
ExpectedParameters = new Dictionary<string, ReferenceTuple>() | ||
{ | ||
{ "a", new ReferenceTuple(StateMachineVariableType.Decimal, false) }, | ||
{ "b", new ReferenceTuple(StateMachineVariableType.Decimal, false) }, | ||
{ "out", new ReferenceTuple(StateMachineVariableType.Decimal, false, VariableIO.Out) } | ||
}; | ||
} | ||
|
||
protected override void DefineFunction() | ||
{ | ||
Name = nameof(MultiplyNumber); | ||
Function = () => | ||
{ | ||
var a = Parameters["a"].GetDecimal(); | ||
var b = Parameters["b"].GetDecimal(); | ||
|
||
Debug.WriteLine($"{a} * {b} = {a * b}"); | ||
|
||
Parameters["out"].SetValue(a * b); | ||
|
||
return 1; | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System.Diagnostics; | ||
|
||
namespace Avalon | ||
{ | ||
/// <summary> | ||
/// Power Number Function Definition | ||
/// </summary> | ||
public class PowNumber : FunctionDefinition | ||
{ | ||
|
||
public PowNumber() | ||
{ | ||
Setup(); | ||
DefineFunction(); | ||
} | ||
|
||
void Setup() | ||
{ | ||
ExpectedParameters = new Dictionary<string, ReferenceTuple>() | ||
{ | ||
{ "a", new ReferenceTuple(StateMachineVariableType.Decimal, false) }, | ||
{ "b", new ReferenceTuple(StateMachineVariableType.Decimal, false) }, | ||
{ "out", new ReferenceTuple(StateMachineVariableType.Decimal, false, VariableIO.Out) } | ||
}; | ||
} | ||
|
||
protected override void DefineFunction() | ||
{ | ||
Name = nameof(PowNumber); | ||
Function = () => | ||
{ | ||
var a = Parameters["a"].GetDecimal(); | ||
var b = Parameters["b"].GetDecimal(); | ||
|
||
var pow = Math.Pow((double)a, (double)b); | ||
|
||
Debug.WriteLine($"{a} to the power of {b} = {pow}"); | ||
|
||
Parameters["out"].SetValue((decimal)pow); | ||
|
||
return 1; | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System.Diagnostics; | ||
|
||
namespace Avalon | ||
{ | ||
/// <summary> | ||
/// Subtact Number Function Definition | ||
/// </summary> | ||
public class SubtractNumber : FunctionDefinition | ||
{ | ||
|
||
public SubtractNumber() | ||
{ | ||
Setup(); | ||
DefineFunction(); | ||
} | ||
|
||
void Setup() | ||
{ | ||
ExpectedParameters = new Dictionary<string, ReferenceTuple>() | ||
{ | ||
{ "a", new ReferenceTuple(StateMachineVariableType.Decimal, false) }, | ||
{ "b", new ReferenceTuple(StateMachineVariableType.Decimal, false) }, | ||
{ "out", new ReferenceTuple(StateMachineVariableType.Decimal, false, VariableIO.Out) } | ||
}; | ||
} | ||
|
||
protected override void DefineFunction() | ||
{ | ||
Name = nameof(SubtractNumber); | ||
Function = () => | ||
{ | ||
var a = Parameters["a"].GetDecimal(); | ||
var b = Parameters["b"].GetDecimal(); | ||
|
||
Debug.WriteLine($"{a} + {b} = {a - b}"); | ||
|
||
Parameters["out"].SetValue(a - b); | ||
|
||
return 1; | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters