Example #1
0
        private void downloadToPlcToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Do you want to erase the existing PLC program first?", "Erase PLC?", MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes)
            {
                try
                {
                    MyCpu.erase();
                }
                catch (wPlcException ex)
                {
                    showErrorForException(ex);
                }
            }

            wldFile w      = new wldFile();
            bool    result = w.openFromFile();

            if (result == true)
            {
                List <Tuple <wSubBlockType, int, List <byte> > > blockList = w.decode();
                try
                {
                    foreach (Tuple <wSubBlockType, int, List <byte> > b in blockList)
                    {
                        MyCpu.downloadBlock(b.Item3);
                    }
                }
                catch (wPlcException ex)
                {
                    showErrorForException(ex);
                }
                MessageBox.Show("Program sucessfullly downloaded to PLC");
            }
            else
            {
                MessageBox.Show("Error opening WLD file");
            }
            refreshCpuInformation();
        }
Example #2
0
 public wCpu(wldFile w)
 {
     blocks = new List<wCpuBlock>();
 }
Example #3
0
 private void saveToDiskToolStripMenuItem_Click(object sender, EventArgs e)
 {
     wldFile w = new wldFile(MyCpu);
     w.save();
 }
Example #4
0
 private void downloadToPlcToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DialogResult dr = MessageBox.Show("Do you want to erase the existing PLC program first?", "Erase PLC?", MessageBoxButtons.YesNo);
     if (dr == DialogResult.Yes)
     {
         try
         {
             MyCpu.erase();
         }
         catch (wPlcException ex)
         {
             showErrorForException(ex);
         }
     }
     
     wldFile w = new wldFile();
     bool result = w.openFromFile();
     
     if (result == true)
     {
         List<Tuple<wSubBlockType, int, List<byte>>> blockList = w.decode();
         try
         {
             foreach (Tuple<wSubBlockType, int, List<byte>> b in blockList)
             {
                 MyCpu.downloadBlock(b.Item3);
             }
         }
         catch (wPlcException ex)
         {
             showErrorForException(ex);
         }
         MessageBox.Show("Program sucessfullly downloaded to PLC");
     }
     else
     {
         MessageBox.Show("Error opening WLD file");
     }
     refreshCpuInformation();
 }
Example #5
0
        private void saveToDiskToolStripMenuItem_Click(object sender, EventArgs e)
        {
            wldFile w = new wldFile(MyCpu);

            w.save();
        }
Example #6
0
 public wCpu(wldFile w)
 {
     blocks = new List <wCpuBlock>();
 }