Exemplo n.º 1
0
        public void PreAction(GXActionArgs arg)
        {
            GXDLMSImageTransfer it = Target as GXDLMSImageTransfer;

            if (arg.Action == ActionType.Action)
            {
                if (arg.Index == 1)
                {
                    if (!updatingImage)
                    {
                        //Check that delay is correct and save it.
                        GetDelay(arg);
                        if (arg.Exception != null)
                        {
                            return;
                        }
                        Properties.Settings.Default.ImageDelay = (int)arg.Value / 1000;
                        GXImageDlg dlg = new GXImageDlg();
                        OnImageDialog(dlg, arg);
                        if (arg.Action == ActionType.None)
                        {
                            return;
                        }
                        arg.Index         = 5;
                        arg.Action        = ActionType.Read;
                        transformingImage = false;
                        updatingImage     = true;
                        return;
                    }
                    //Initiate the Image transfer process.
                    arg.Value       = it.ImageTransferInitiate(arg.Client, imageIdentifier, image.Length);
                    imageIdentifier = null;
                    updatingImage   = false;
                    statusReadCount = 0;
                }
                else if (arg.Index == 2)
                {
                    //Start image block transfer.
                    int imageBlockCount;
                    arg.Value = it.ImageBlockTransfer(arg.Client, image, out imageBlockCount);
                    OnDescription("Sending " + imageBlockCount + " blocks.");
                }
                else if (arg.Index == 3)
                {
                    arg.Value = it.ImageVerify(arg.Client);
                    OnDescription("Verifying image.");
                }
                else if (arg.Index == 4)
                {
                    arg.Value = it.ImageActivate(arg.Client);
                    OnDescription("Activating image.");
                }
            }
        }