Skip to content

Commit cea2c0c

Browse files
author
sripp
committed
suport SystemFunction CTU
1 parent 3fbd8f3 commit cea2c0c

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

TiaCodeGen.Tests/SampleTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,23 @@ public void TestCallWithTOn()
222222
var xml = block.GetCode();
223223
}
224224

225+
[Test]
226+
public void TestCallWithCTU()
227+
{
228+
var codeblock = new CodeBlock() { Safety = false };
229+
230+
var nw = new Network("Test2", "Test2en");
231+
232+
var f = new And(new Signal("aa"), new CTUCall("Hallo", r: new Signal("bbb", SignalType.Bool), pv: new Signal("2", SignalType.ConstantInt), q: new Coil(new Signal("ccc", SignalType.Bool))));
233+
nw.Add(f);
234+
235+
codeblock.Add(nw);
236+
237+
var block = new Block("Test", "blabla", codeblock);
238+
block.Interface = TestInterface;
239+
var xml = block.GetCode();
240+
}
241+
225242
[Test]
226243
public void TestCallWithTPAndDistributor()
227244
{

TiaCodegen/CodeGen/KopCodeHelper.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,10 @@ private void AddWires(IOperationOrSignal op)
691691
{
692692
_sb.AppendLine("<NameCon UId=\"" + next.OperationId + "\" Name=\"pre\" />" + " <!-- " + dstName + " -->");
693693
}
694+
else if (next is CTUCall)
695+
{
696+
_sb.AppendLine("<NameCon UId=\"" + next.OperationId + "\" Name=\"CU\" />" + " <!-- " + dstName + " -->");
697+
}
694698
else if (next is FunctionCall)
695699
{
696700
_sb.AppendLine("<NameCon UId=\"" + next.OperationId + "\" Name=\"" + (((FunctionCall)next).HasNoEn ? "in" : "en") + "\" />" + " <!-- " + dstName + " -->");

TiaCodegen/Commands/Functions/CTUCall.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ namespace TiaCodegen.Commands.Functions
88
public class CTUCall : SystemFunctionBlockCall
99
{
1010
public CTUCall(string instanceName,
11-
IOperationOrSignal cu = null,
1211
IOperationOrSignal r = null,
1312
IOperationOrSignal pv = null,
1413
IOperationOrSignal q = null,
1514
IOperationOrSignal cv = null) : base("CTU", instanceName, null)
1615
{
17-
Interface["CU"] = new IOperationOrSignalDirectionWrapper(cu, Direction.Input);
1816
Interface["R"] = new IOperationOrSignalDirectionWrapper(r, Direction.Input);
1917
Interface["PV"] = new IOperationOrSignalDirectionWrapper(pv, Direction.Input);
2018
Interface["Q"] = new IOperationOrSignalDirectionWrapper(q, Direction.Output);

0 commit comments

Comments
 (0)