private bool VerifyLine(Line line)
        {
            InstructionList instructions = new InstructionList();

            instructions.InsertAllWithClearBefore(line.Outputs);
            if (instructions.Count > 0)
            {
                if (!(instructions.Contains(OperationCode.OutputCoil) ||
                      instructions.Contains(OperationCode.Timer) ||
                      instructions.Contains(OperationCode.Counter) ||
                      instructions.Contains(OperationCode.Reset)))
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }


            if (!instructions.ContainsAllOperandos())
            {
                return(false);
            }

            if (!instructions.HasDuplicatedTimers(usedTimers))
            {
                return(false);
            }

            if (!instructions.HasDuplicatedCounters(usedCounters))
            {
                return(false);
            }

            instructions.InsertAllWithClearBefore(line.Instructions);

            if (instructions.Count > 0)
            {
                if (instructions.Contains(OperationCode.OutputCoil) ||
                    instructions.Contains(OperationCode.Timer) ||
                    instructions.Contains(OperationCode.Counter) ||
                    instructions.Contains(OperationCode.Reset))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public VisualInstructionUserControl InsertInstruction(bool after, LocalToInsertInstruction localToInsertInstruction, VisualInstructionUserControl visualInstruction, params OperationCode[] opCodes)
        {
            InstructionList instructions = new InstructionList();

            instructions.InsertAllWithClearBefore(opCodes);

            switch (localToInsertInstruction)
            {
            case LocalToInsertInstruction.Undefined:
                visualInstruction = InsertInstructionAtLocalToBeDefined(after, visualInstruction, instructions);
                break;

            case LocalToInsertInstruction.ConditionsAtLeft:
                visualInstruction = InsertConditionInstructionAtLeft(after, visualInstruction, instructions);
                break;

            case LocalToInsertInstruction.OutputsAtRight:
                visualInstruction = InsertOutputInstructionAtRight(after, visualInstruction, instructions);
                break;
            }
            return(visualInstruction);
        }
Ejemplo n.º 3
0
        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (IsLadderFormOpen())
            {
                if (projectForm.LadderForm.VisualInstruction != null)
                {
                    if (!projectForm.LadderForm.VisualInstruction.IsDisposed)
                    {
                        DataFormats.Format myFormat                = DataFormats.GetFormat("List<SimboloBasico>");
                        Object             returnObject            = null;
                        List <Instruction> instructionsSource      = new List <Instruction>();
                        InstructionList    instructionsDestination = new InstructionList();

                        IDataObject iData = Clipboard.GetDataObject();

                        // Determines whether the data is in a format you can use.
                        if (iData.GetDataPresent(myFormat.Name))
                        {
                            try
                            {
                                returnObject = iData.GetData(myFormat.Name);
                            }
                            catch
                            {
                                MessageBox.Show("Error");
                            }
                        }

                        instructionsSource = (List <Instruction>)returnObject;

                        instructionsDestination.InsertAllWithClearBefore(instructionsSource);

                        VisualInstructionUserControl visualInstruction = projectForm.LadderForm.SelectedVisualLine.InsertInstructionAtLocalToBeDefined(true, projectForm.LadderForm.VisualInstruction, instructionsDestination);
                        projectForm.LadderForm.ReorganizeLines();
                        visualInstruction.Select();
                    }
                }
            }
        }