Skip to content

Commit eb1a136

Browse files
author
sripp
committed
support periphery signals
1 parent a204f4f commit eb1a136

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

TiaCodeGen.Tests/SampleTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,5 +315,27 @@ public void MultipleOr()
315315
block.Interface = TestInterface;
316316
var xml = block.GetCode();
317317
}
318+
319+
[Test]
320+
public void PeripheryFixedSignal()
321+
{
322+
var codeblock = new CodeBlock() { Safety = false };
323+
324+
var nw = new Network("Test3", "Test3en");
325+
nw.Add(
326+
new Coil(
327+
new FixedPeripherySignal("=PBG10.6+FBG11-BV1:4"),
328+
new And(
329+
new Signal("1")
330+
)
331+
)
332+
);
333+
334+
codeblock.Add(nw);
335+
336+
var block = new Block("Test", "blabla", codeblock);
337+
block.Interface = TestInterface;
338+
var xml = block.GetCode();
339+
}
318340
}
319341
}

TiaCodegen/Commands/Signals/FixedSignal.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,10 @@ public FixedSignal(string name, SignalType signalType = SignalType.Bool, string
1111
base(name, signalType, customType)
1212
{ }
1313
}
14+
public class FixedPeripherySignal : FixedSignal
15+
{
16+
public FixedPeripherySignal(string name, SignalType signalType = SignalType.Bool, string customType = null) :
17+
base(name, signalType, customType)
18+
{ }
19+
}
1420
}

TiaCodegen/Commands/Signals/Signal.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,19 @@ public void AddXmlToStringBuilder(ulong id, StringBuilder sb)
369369
}
370370
else
371371
{
372-
sb.AppendLine("<Component Name=\"" + part + "\">");
372+
if (this is FixedPeripherySignal)
373+
{
374+
sb.AppendLine("<Component Name=\"" + part + "\" SimpleAccessModifier=\"Periphery\">");
375+
}
376+
else
377+
sb.AppendLine("<Component Name=\"" + part + "\">");
373378
}
374379
sb.AppendLine("</Component>");
375380
}
376-
sb.AppendLine("<Address Area=\"None\" Type=\"Bool\" BlockNumber=\"0\" BitOffset=\"0\" Informative=\"true\" />");
381+
if (this is FixedPeripherySignal)
382+
sb.AppendLine("<Address Area=\"PeripheryInput\" Type=\"Bool\" BitOffset=\"0\" Informative=\"true\" />");
383+
else
384+
sb.AppendLine("<Address Area=\"None\" Type=\"Bool\" BlockNumber=\"0\" BitOffset=\"0\" Informative=\"true\" />");
377385
sb.AppendLine("</Symbol>");
378386
sb.AppendLine("</Access>");
379387
}

0 commit comments

Comments
 (0)