Exemplo n.º 1
0
        protected InstructionLDParallel(IEditorItem parent, NodeInstruction instruction)
            : base(parent, m_InstructionType)
        {
            if (instruction == null)
            {
                var newInstruction = NodeInstruction.BuildWith(InstructionType);
                newInstruction = newInstruction.NodeInstructionChildren.Append(
                    InstructionLDSeries.EmptyRung());
                newInstruction = newInstruction.NodeInstructionChildren.Append(
                    InstructionLDSeries.EmptyRung());
                Instruction = newInstruction;
            }
            else
            {
                if (instruction.InstructionType != InstructionType)
                {
                    throw new InvalidOperationException("Tried to instantiate InstructionLDParallel but passed a different instruction type.");
                }
                Instruction = instruction;
            }

            // Build the context menu
            if (extensionService != null)
            {
                ContextMenu = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu);
                ContextMenuEnabled = true;
            }
        }
 private InstructionLDContactNC(IEditorItem parent, NodeInstruction instruction)
     : base(parent, m_InstructionType, instruction)
 {
     // Build the context menu
     if (extensionService != null)
     {
         ContextMenu = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu);
         ContextMenuEnabled = true;
     }
 }
        protected InstructionLDAbstractTimer(IEditorItem parent, NodeInstruction instruction, FieldInstructionType instructionType)
            : base(parent, instructionType)
        {
            if (instruction == null)
            {
                var newInstruction = NodeInstruction.BuildWith(InstructionType);
                // Output signal: Named boolean - the timer done signal
                newInstruction = newInstruction.NodeSignalChildren.Append(
                    NodeSignal.BuildWith(
                        new FieldSignalName(Resources.Strings.LD_Snap_Tmr_DefaultName),
                        new FieldDataType(FieldDataType.DataTypeEnum.BOOL),
                        new FieldBool(false), // not forced
                        FieldConstant.Constants.BOOL.LOW)
                    );
                newInstruction = newInstruction.NodeSignalChildren.Append(
                    NodeSignal.BuildWith(
                        new FieldSignalName(Resources.Strings.LD_Snap_Tmr_DefaultName + SEPARATOR + Resources.Strings.LD_Snap_Tmr_ElapsedName),
                        new FieldDataType(FieldDataType.DataTypeEnum.NUMBER),
                        new FieldBool(false), // not forced
                        FieldConstant.Constants.NUMBER.ZERO)
                    );
                // Input signal: setpoint
                newInstruction = newInstruction.NodeSignalInChildren.Append(
                    NodeSignalIn.BuildWith(
                        new FieldDataType(FieldDataType.DataTypeEnum.NUMBER),
                        new FieldConstant(FieldDataType.DataTypeEnum.NUMBER, 0)));
                Instruction = newInstruction;
            }
            else
            {
                if (instruction.InstructionType != InstructionType)
                {
                    throw new InvalidOperationException("Tried to instantiate a Timer but passed a different instruction type.");
                }
                Instruction = instruction;
            }

            // Build the context menu
            if (extensionService != null)
            {
                ContextMenu = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu);
                ContextMenuEnabled = true;
            }
        }
Exemplo n.º 4
0
        public static NodeInstruction BuildWith(FieldInstructionType InstructionType)
        {
            //build fields
            Dictionary <FieldIdentifier, FieldBase> mutableFields =
                new Dictionary <FieldIdentifier, FieldBase>();

            mutableFields.Add(new FieldIdentifier(m_InstructionTypeName), InstructionType);
            mutableFields.Add(new FieldIdentifier(m_CommentName), new FieldString());
            //Add Fields here: mutableFields.Add(new FieldIdentifier(m_CodeName), Code);

            //build children
            KeyedNodeCollection <NodeBase> mutableChildren =
                new KeyedNodeCollection <NodeBase>();
            //Add Children here: mutableChildren.Add(SomeChild);

            //build node
            NodeInstruction Builder = new NodeInstruction(
                new ReadOnlyDictionary <FieldIdentifier, FieldBase>(mutableFields),
                new ReadOnlyCollection <NodeBase>(mutableChildren));

            return(Builder);
        }
 protected InstructionLDAbstractContact(IEditorItem parent, FieldInstructionType instructionType, NodeInstruction instruction)
     : base(parent, instructionType)
 {
     if (instruction == null)
     {
         var newInstruction = NodeInstruction.BuildWith(InstructionType);
         // Input signal: (coil that we're a contact off) default to always false
         newInstruction = newInstruction.NodeSignalInChildren.Append(
             NodeSignalIn.BuildWith(
                 new FieldDataType(FieldDataType.DataTypeEnum.BOOL),
                 new FieldConstant(FieldDataType.DataTypeEnum.BOOL, false)));
         Instruction = newInstruction;
     }
     else
     {
         if (instructionType != instruction.InstructionType)
         {
             throw new ArgumentOutOfRangeException("Tried to instantiate a contact of type " +
                 instructionType.ToString() + " with an instruction of a different type.");
         }
         Instruction = instruction;
     }
 }
Exemplo n.º 6
0
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return CreateForLD(parent, instruction);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Just a static method that the rest of this assembly can call
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="instruction"></param>
 /// <returns></returns>
 public static IInstructionItem CreateForLD(IEditorItem parent, NodeInstruction instruction)
 {
     return new InstructionLDSeries(parent, instruction);
 }
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return new InstructionLDStringContains(parent, instruction);
 }
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return new InstructionLDGreaterThanOrEqual(parent, instruction);
 }
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return new InstructionLDChooseNumber(parent, instruction);
 }
Exemplo n.º 11
0
 protected InstructionLDSubtract(IEditorItem parent, NodeInstruction instruction)
     : base(parent, m_InstructionType, instruction, Resources.Strings.LD_Snap_Subtract_DefaultName, false,
     Resources.Strings.LD_Snap_Subtract_InstructionName,
     Resources.Strings.LD_Snap_Subtract_FirstSignalName, Resources.Strings.LD_Snap_Subtract_SecondSignalName)
 {
 }
Exemplo n.º 12
0
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return new InstructionLDRisingEdge(parent, instruction);
 }
Exemplo n.º 13
0
 private InstructionLDCntDN(IEditorItem parent, NodeInstruction instruction)
     : base(parent, instruction, m_InstructionType)
 {
 }
Exemplo n.º 14
0
 protected InstructionLDLessThan(IEditorItem parent, NodeInstruction instruction)
     : base(parent, m_InstructionType, instruction, false,
     Resources.Strings.LD_Snap_LessThan_InstructionName,
     Resources.Strings.LD_Snap_LessThan_FirstSignalName, Resources.Strings.LD_Snap_LessThan_SecondSignalName)
 {
 }
Exemplo n.º 15
0
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return new InstructionLDParallel(parent, instruction);
 }
Exemplo n.º 16
0
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return new InstructionLDLessThan(parent, instruction);
 }
Exemplo n.º 17
0
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return new InstructionLDMultiply(parent, instruction);
 }
Exemplo n.º 18
0
 protected InstructionLDSeries(IEditorItem parent, NodeInstruction instruction)
     : base(parent, m_InstructionType)
 {
     if (instruction == null)
     {
         Instruction = EmptyRung();
     }
     else
     {
         if (instruction.InstructionType != InstructionType)
         {
             throw new InvalidOperationException("Tried to instantiate InstructionLDSeries but passed a different instruction type.");
         }
         Instruction = instruction;
     }
 }
Exemplo n.º 19
0
        protected InstructionLDSetReset(IEditorItem parent, NodeInstruction instruction)
            : base(parent, m_InstructionType)
        {
            if (instruction == null)
            {
                var newInstruction = NodeInstruction.BuildWith(InstructionType);
                // Output signal: Named boolean - the latched state
                newInstruction = newInstruction.NodeSignalChildren.Append(
                    NodeSignal.BuildWith(
                        new FieldSignalName(Resources.Strings.LD_Snap_SetReset_DefaultName),
                        new FieldDataType(FieldDataType.DataTypeEnum.BOOL),
                        new FieldBool(false), // not forced
                        FieldConstant.Constants.BOOL.LOW)
                    );
                // Input signal: reset
                newInstruction = newInstruction.NodeSignalInChildren.Append(
                    NodeSignalIn.BuildWith(
                        new FieldDataType(FieldDataType.DataTypeEnum.BOOL),
                        new FieldConstant(FieldDataType.DataTypeEnum.BOOL, false)));
                Instruction = newInstruction;
            }
            else
            {
                if (instruction.InstructionType != InstructionType)
                {
                    throw new InvalidOperationException("Tried to instantiate a SetReset but passed a different instruction type.");
                }
                Instruction = instruction;
            }

            // Build the context menu
            if (extensionService != null)
            {
                ContextMenu = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu);
                ContextMenuEnabled = true;
            }
        }
Exemplo n.º 20
0
 public InstructionGroupExecutorContextLD ScanInstruction(NodeRuntimeApplication rta, NodeInstruction instruction, InstructionGroupExecutorContextLD context)
 {
     var retVal = new InstructionGroupExecutorContextLD(false);
     if (m_instructionExecutors.ContainsKey(instruction.InstructionType))
     {
         var executor = m_instructionExecutors[instruction.InstructionType];
         retVal = executor.ScanInstruction(rta, instruction, context);
     }
     else
     {
         // FIXME - throw some kind of exception?
     }
     return retVal;
 }
Exemplo n.º 21
0
 /// <summary>
 /// You can use this to change the Instruction property including doing all
 /// the legwork for the Undo/Redo framework, but only if the change *doesn't*
 /// involve editing the NodeInstructionChildren (child instructions)
 /// </summary>
 /// <param name="newInstruction"></param>
 protected void SimpleUndoableInstructionEdit(NodeInstruction newInstruction, string undoDescription)
 {
     var undoActions = new Collection<Action>();
     var doActions = new Collection<Action>();
     var saveNewInstruction = newInstruction;
     var origInstruction = Instruction;
     doActions.Add(() => Instruction = saveNewInstruction);
     undoActions.Add(() => Instruction = origInstruction);
     Do(new UndoMemento(this, ActionType.EDIT, undoDescription, undoActions, doActions));
 }
Exemplo n.º 22
0
 private InstructionLDRisingEdge(IEditorItem parent, NodeInstruction instruction)
     : base(parent, instruction, m_InstructionType)
 {
 }
 protected InstructionLDGreaterThanOrEqual(IEditorItem parent, NodeInstruction instruction)
     : base(parent, m_InstructionType, instruction, false,
     Resources.Strings.LD_Snap_GreaterThanOrEqual_InstructionName,
     Resources.Strings.LD_Snap_GreaterThanOrEqual_FirstSignalName, Resources.Strings.LD_Snap_GreaterThanOrEqual_SecondSignalName)
 {
 }
Exemplo n.º 24
0
        public static NodeInstruction BuildWith(FieldInstructionType InstructionType)
        {
            //build fields
            Dictionary<FieldIdentifier, FieldBase> mutableFields =
                new Dictionary<FieldIdentifier, FieldBase>();
            mutableFields.Add(new FieldIdentifier(m_InstructionTypeName), InstructionType);
            mutableFields.Add(new FieldIdentifier(m_CommentName), new FieldString());
            //Add Fields here: mutableFields.Add(new FieldIdentifier(m_CodeName), Code);

            //build children
            KeyedNodeCollection<NodeBase> mutableChildren =
                new KeyedNodeCollection<NodeBase>();
            //Add Children here: mutableChildren.Add(SomeChild);

            //build node
            NodeInstruction Builder = new NodeInstruction(
                new ReadOnlyDictionary<FieldIdentifier, FieldBase>(mutableFields),
                new ReadOnlyCollection<NodeBase>(mutableChildren));

            return Builder;
        }
 protected InstructionLDChooseNumber(IEditorItem parent, NodeInstruction instruction)
     : base(parent, m_InstructionType, instruction, Resources.Strings.LD_Snap_ChooseNumber_DefaultName, false,
     Resources.Strings.LD_Snap_ChooseNumber_InstructionName,
     Resources.Strings.LD_Snap_ChooseNumber_FirstSignalName, Resources.Strings.LD_Snap_ChooseNumber_SecondSignalName)
 {
 }
Exemplo n.º 26
0
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return new InstructionLDSetReset(parent, instruction);
 }
Exemplo n.º 27
0
 public virtual IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     throw new NotImplementedException();
 }