Exemplo n.º 1
0
        private void t3000EditorTestToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ProgramEditorForm prgf      = new ProgramEditorForm();
            ControlPointInfo  pintinfor = new ControlPointInfo();

            pintinfor.Label      = "PS";
            pintinfor.AutoManual = "Auto";
            pintinfor.Value      = "A1_ON";
            pintinfor.FullLabel  = "PUMP1 STATUS";
            pintinfor.Units      = "";
            prgf.AddControlPoint(IdentifierTypes.INS, pintinfor, 1);
            pintinfor.Label      = "P2S";
            pintinfor.AutoManual = "Auto";
            pintinfor.Value      = "A2_OFF";
            pintinfor.FullLabel  = "PUMP2 STATUS";
            pintinfor.Units      = "";
            prgf.AddControlPoint(IdentifierTypes.INS, pintinfor, 2);

            pintinfor.Label      = "P1";
            pintinfor.AutoManual = "";
            pintinfor.Value      = "A1_OFF";
            pintinfor.FullLabel  = "CIRC PUMP1";
            pintinfor.Units      = "";
            prgf.AddControlPoint(IdentifierTypes.OUTS, pintinfor, 1);
            pintinfor.Label      = "P2";
            pintinfor.AutoManual = "Auto";
            pintinfor.Value      = "A2_ON";
            pintinfor.FullLabel  = "CIRC PUMP2";
            pintinfor.Units      = "";
            prgf.AddControlPoint(IdentifierTypes.OUTS, pintinfor, 2);

            pintinfor.Label      = "PFAIL";
            pintinfor.AutoManual = "Auto";
            pintinfor.Value      = "Alarm";
            pintinfor.FullLabel  = "PUMP1 MODE";
            pintinfor.Units      = "Normal/Alarm";
            prgf.AddControlPoint(IdentifierTypes.VARS, pintinfor, 1);
            pintinfor.Label      = "P2FAIL";
            pintinfor.AutoManual = "Auto";
            pintinfor.Value      = "Alarm";
            pintinfor.FullLabel  = "PUMP2 MODE";
            pintinfor.Units      = "Normal/Alarm";
            prgf.AddControlPoint(IdentifierTypes.VARS, pintinfor, 2);

            pintinfor.Label      = "LEADPMP";
            pintinfor.AutoManual = "Manual";
            pintinfor.Value      = "A1_ON";
            pintinfor.FullLabel  = "LEAD PUMP";
            pintinfor.Units      = "A1_ON/A1_OFF";
            prgf.AddControlPoint(IdentifierTypes.VARS, pintinfor, 3);
            prgf.SetIndefier();

            prgf.SetCode(@"10 IF TIME-ON   (  P1 )  > 00:00:10 AND NOT PS THEN START PFAIL 
 ");


            prgf.Show();
        }
Exemplo n.º 2
0
        private void EditCodeColumn(object sender, EventArgs e)
        {
            try
            {
                var row = view.CurrentRow;
                Index_EditProgramCode = row.GetValue <int>(NumberColumn) - 1;

                var form = new ProgramEditorForm();
                form.Caption = $"Edit Code: Panel 1 - Program {Index_EditProgramCode } - Label {Prg.Programs[Index_EditProgramCode].Description}";

                Console.WriteLine("--------------ORIGINAL CODE-------------------");
                ConsolePrintBytes(Codes[Index_EditProgramCode].Code, "Original");
                form.SetCode(Codes[Index_EditProgramCode].ToString());


                #region Create local copy of identifiers from control points
                foreach (var vars in Prg.Variables)
                {
                    form.Identifiers.Add(vars.Label);
                }
                foreach (var ins in Prg.Inputs)
                {
                    form.Identifiers.Add(ins.Label, IdentifierTypes.INS);
                }
                foreach (var outs in Prg.Outputs)
                {
                    form.Identifiers.Add(outs.Label, IdentifierTypes.OUTS);
                }
                foreach (var prgs in Prg.Programs)
                {
                    form.Identifiers.Add(prgs.Label, IdentifierTypes.PRGS);
                }
                foreach (var schs in Prg.Schedules)
                {
                    form.Identifiers.Add(schs.Label, IdentifierTypes.SCHS);
                }
                foreach (var hols in Prg.Holidays)
                {
                    form.Identifiers.Add(hols.Label, IdentifierTypes.HOLS);
                }

                #endregion


                //Override Send Event Handler and encode program into bytes.
                form.Send     += Form_Send;
                form.MdiParent = this.MdiParent;

                form.Show();
                //if (form.ShowDialog() != DialogResult.OK) return;
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }
        private void EditCodeColumn(object sender, EventArgs e)
        {
            try
            {
                var row = view.CurrentRow;
                Index_EditProgramCode = row.GetValue <int>(NumberColumn) - 1;

                var form = new ProgramEditorForm();
                form.Caption = $"Edit Code: Panel 1 - Program {Index_EditProgramCode } - Label {SelectedPrg.Programs[Index_EditProgramCode].Description}";

                Debug.WriteLine("--------------ORIGINAL CODE-------------------");
                CoderHelper.ConsolePrintBytes(Codes[Index_EditProgramCode].Code, "Original");

                Decoder DECODER = new Decoder();

                DECODER.SetControlPoints(SelectedPrg);
                string ProgramText = DECODER.DecodeBytes(Codes[Index_EditProgramCode].Code);

                Debug.WriteLine("--------------NEW PROGRAM TEXT-------------------");
                Debug.WriteLine(ProgramText);

                //STEP 1: create a local copy of all identifiers
                form.Identifiers = DECODER.Identifiers;

                //STEP 2: Create a local copy for Control Basic program text
                form.SetCode(ProgramText);

                //STEP 3: Override Send Event Handler and encode program into bytes.
                form.Send += Form_Send;

                //STEP 4: Who's your daddy?!!
                form.MdiParent = this.MdiParent;


                form.Show();
                //if (form.ShowDialog() != DialogResult.OK) return;
            }
            catch (Exception exception)
            {
                MessageBoxUtilities.ShowException(exception);
            }
        }