Exemplo n.º 1
0
        public void CreateSequencerPlcBlockTest()
        {
            var blockName = "my_sequencer";
            var mainMethodImplementation = "IF TRUE THEN; END_IF;";
            var actual = PlcBlockHelpers.CreateSequencerPlcBlock(blockName, mainMethodImplementation);

            Assert.AreEqual($"FUNCTION_BLOCK {blockName} EXTENDS TcoCore.TcoSequencer", actual.POU.Declaration);
            Assert.AreEqual($"{mainMethodImplementation}",
                            actual.POU.Method.Where(p => p.Name == "Main").FirstOrDefault().Implementation.ST);
        }
Exemplo n.º 2
0
        public void EmitPlcBlockFileTest()
        {
            var blockName = "my_sequencer";
            var mainMethodImplementation = "IF TRUE THEN; END_IF;";
            var block      = PlcBlockHelpers.CreateSequencerPlcBlock(blockName, mainMethodImplementation);
            var outputFile = Path.Combine(outputFiles, $"{blockName}.TcPOU");

            if (File.Exists(outputFile))
            {
                File.Delete(outputFile);
            }

            Assert.IsFalse(File.Exists(outputFile));

            PlcBlockHelpers.EmitPlcBlockFile(outputFile, block);

            Assert.IsTrue(File.Exists(outputFile));
        }