Esempio n. 1
0
        private IEnumerable <CompiledInstruction> compileInstructionGroup(
            NodeInstructionGroup instructionGroup,
            SignalTable signalTable)
        {
            if (instructionGroup == null)
            {
                throw new ArgumentNullException("instructionGroup");
            }
            if (signalTable == null)
            {
                throw new ArgumentNullException("signalTable");
            }
            var result = new List <CompiledInstruction>();

            if (instructionGroup.Language.ToString() !=
                SoapBox.Snap.LD.Extensions.Workbench.Documents.PageEditor_.InstructionGroupItems.LD)
            {
                throw new ArgumentOutOfRangeException("Can only compile ladder logic");
            }

            foreach (var instruction in instructionGroup.NodeInstructionChildren)
            {
                result.AddRange(compileInstruction(instruction, signalTable));
            }

            return(result);
        }
Esempio n. 2
0
        private void ScanInstructionGroup(NodeRuntimeApplication rta, NodeInstructionGroup instructionGroup)
        {
            string         language = instructionGroup.Language.ToString();
            IGroupExecutor executor = null;

            if (m_groupExecutors.ContainsKey(language))
            {
                executor = m_groupExecutors[language];
            }
            else
            {
                // this only instantiates new language modules if we're actually using that language
                foreach (var executorSearch in groupExecutorsImported)
                {
                    if (executorSearch.Metadata.Language == language)
                    {
                        executor = executorSearch.Value;
                        m_groupExecutors.Add(language, executor);
                        break;
                    }
                }
            }

            if (executor != null)
            {
                executor.ScanInstructionGroup(rta, instructionGroup);
            }
            else
            {
                // FIXME - should report the error - we can't execute it
            }
        }
Esempio n. 3
0
 public void MoveSelectedDown()
 {
     if (runtimeService.DisconnectDialog(this))
     {
         if (onlyOneGroupSelected())
         {
             var ig = findFirstSelectedInstructionGroup();
             if (ig != null)
             {
                 var igNode = ig.InstructionGroup; // the node getting moved
                 NodeInstructionGroup igAfterNode = null;
                 bool found = false;
                 foreach (var igTest in WorkingCopy.NodeInstructionGroupChildren.Items)
                 {
                     if (igTest == igNode)
                     {
                         found = true;
                     }
                     else if (found)
                     {
                         igAfterNode = igTest;
                         break;
                     }
                 }
                 if (igAfterNode != null)
                 {
                     NodePage newPage;
                     newPage = WorkingCopy.NodeInstructionGroupChildren.Remove(igNode);
                     newPage = newPage.NodeInstructionGroupChildren.InsertAfter(igAfterNode, igNode);
                     simplePageEdit(newPage, Resources.Strings.PageEditor_UndoDescription_MoveGroupDown);
                 }
             }
         }
     }
 }
 public InstructionGroupDummy(IEditorItem parent, NodeInstructionGroup instructionGroup)
     : base(parent)
 {
     if (instructionGroup == null)
     {
         throw new ArgumentNullException();
     }
     m_instructionGroup = instructionGroup;
 }
Esempio n. 5
0
        private static NodeInstructionGroup emptyNode()
        {
            var newInstructionGroup = NodeInstructionGroup.BuildWith(
                new FieldIdentifier(Extensions.Workbench.Documents.PageEditor_.InstructionGroupItems.LD));

            newInstructionGroup = newInstructionGroup.NodeInstructionChildren.Append(
                InstructionLDSeries.EmptyRung()); // empty rungs are just a Series instruction
            return(newInstructionGroup);
        }
Esempio n. 6
0
        public void ScanInstructionGroup(NodeRuntimeApplication rta, NodeInstructionGroup instructionGroup)
        {
            var contextIterator = new InstructionGroupExecutorContextLD(true); // rung condition at the beginning of a rung is always true

            // A rung only ever has one series instruction as a child, so the foreach is kind of overkill, but should work
            foreach (var instruction in instructionGroup.NodeInstructionChildren)
            {
                contextIterator = ScanInstruction(rta, instruction, contextIterator);
            }
        }
Esempio n. 7
0
 internal InstructionGroupLD(IEditorItem parent, NodeInstructionGroup instructionGroup)
     : base(parent)
 {
     if (instructionGroup == null)
     {
         // a new group
         InstructionGroup = emptyNode();
     }
     else
     {
         if (instructionGroup.Language != Extensions.Workbench.Documents.PageEditor_.InstructionGroupItems.LD)
         {
             throw new InvalidOperationException("instructionGroup");
         }
         InstructionGroup = instructionGroup;
     }
 }
 public override NodeInstructionGroup CreateEmptyNode()
 {
     return(NodeInstructionGroup.BuildWith(new Protocol.Base.FieldIdentifier(string.Empty)));
 }
 public override IInstructionGroupItem Create(IEditorItem parent, NodeInstructionGroup instructionGroup)
 {
     return(new InstructionGroupDummy(parent, instructionGroup));
 }
Esempio n. 10
0
 public virtual IInstructionGroupItem Create(IEditorItem parent, NodeInstructionGroup instructionGroup)
 {
     return(null);
 }