Ejemplo n.º 1
0
        public void download(string ipAddress, int rack, int slot, bool eraseCpu)
        {
            wCpuRunMode rm = wCpuRunMode.Unknown;
            bool        skippedSystemData = false;

            if (eraseCpu)
            {
                this.erase();
            }

            foreach (wCpuBlock b in this.blocks)
            {
                if (b.blockType == wBlockType.SDB && rm != wCpuRunMode.Stop && !skippedSystemData)
                {
                    rm = this.getCpuRunMode();
                    if (rm != wCpuRunMode.Stop)
                    {
                        string message = "The PLC needs to be stopped to load System Data" + System.Environment.NewLine;
                        message = message + "Would you like to stop the PLC?";
                        DialogResult dr = MessageBox.Show(message, "", MessageBoxButtons.YesNo);

                        if (dr == DialogResult.Yes)
                        {
                            this.setCpuRunMode(wCpuRunMode.Stop);
                        }
                        else
                        {
                            MessageBox.Show("System Data will not be loaded");
                        }
                    }
                }

                if (b.blockType == wBlockType.SDB && skippedSystemData)
                {
                    continue;
                }

                if (b.blockType != wBlockType.SFC && b.blockType != wBlockType.SFB)
                {
                    int result;
                    result = MyClient.Download(b.blockNumber, b.data, b.data.Length);
                    if (result == 0)
                    {
                        Console.WriteLine("Downloaded " + b.ToString());
                    }
                    else
                    {
                        string error = "Could not download  " + b.ToString();
                        throw new wPlcException(error, result);
                    }
                }
            }

            Console.Write("Download Complete");
        }
Ejemplo n.º 2
0
        public void downloadBlock(List <byte> b)
        {
            int result = MyClient.Download(-1, b.ToArray(), b.Count);

            if (result != 0)
            {
                string error = "Failed to download block";
                throw new wPlcException(error, result);
            }
            else
            {
                Console.WriteLine("Downloaded Block");
            }
        }