Exemplo n.º 1
0
 public NodeInstruction SetInstructionType(FieldInstructionType InstructionType)
 {
     if (InstructionType == null)
     {
         throw new ArgumentNullException(m_InstructionTypeName);
     }
     return(new NodeInstruction(this.SetField(new FieldIdentifier(m_InstructionTypeName), InstructionType), ChildCollection));
 }
        public AbstractInstructionItem(IEditorItem parent, FieldInstructionType instructionType)
            : base(parent)
        {
            if (instructionType == null)
            {
                throw new ArgumentNullException("instructionType");
            }
            m_InstructionType = instructionType;

            PropertyChanged += new PropertyChangedEventHandler(AbstractEditorItem_PropertyChanged);
            parentChanged();
        }
        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 NodeInstruction SetInstructionType(FieldInstructionType InstructionType)
 {
     if (InstructionType == null)
     {
         throw new ArgumentNullException(m_InstructionTypeName);
     }
     return new NodeInstruction(this.SetField(new FieldIdentifier(m_InstructionTypeName), InstructionType), ChildCollection);
 }
Exemplo n.º 7
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 InstructionLDAbstractTimer(FieldInstructionType instructionType)
     : base(null, instructionType)
 {
 }
 protected InstructionLDAbstractContact(IEditorItem parent, FieldInstructionType instructionType)
     : base(parent, instructionType)
 {
 }
 public AbstractLDInstructionItem(IEditorItem parent, FieldInstructionType instructionType)
     : base(parent, instructionType)
 {
 }