コード例 #1
0
        public void PreAction(GXActionArgs arg)
        {
            DialogResult ret;

            if (arg.Action == ActionType.Action)
            {
                if (arg.Index == 1)
                {
                    //Synchronize current time
                    ret = GXHelpers.ShowMessageBox(this, "Are you sure that you want to synchronize current time to the meter?", "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    if (ret == DialogResult.Yes)
                    {
                        arg.Value = (sbyte)0;
                    }
                    arg.Handled = ret != DialogResult.Yes;
                }
                else if (arg.Index == 2)
                {
                    OnShowDialog(arg);
                }
                else if (arg.Index == 3)
                {
                    OnShowDialog(arg);
                }
            }
        }
コード例 #2
0
        public void PreAction(GXActionArgs arg)
        {
            DialogResult ret;

            //Update secret.
            if (arg.Index == 5)
            {
                ret = GXHelpers.ShowMessageBox(this, Properties.Resources.SecretSetWarning, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (ret == DialogResult.Yes)
                {
                    if (SecretTB.Text.Length == 0)
                    {
                        throw new ArgumentException("Invalid password.");
                    }
                    if (SecretAsciiCb.Checked)
                    {
                        arg.Value = SecretTB.Text;
                    }
                    else
                    {
                        arg.Value = GXDLMSTranslator.HexToBytes(SecretTB.Text);
                    }
                }
                arg.Handled = ret != DialogResult.Yes;
            }
        }
コード例 #3
0
        public void PreAction(GXActionArgs arg)
        {
            arg.Value = (sbyte)0;
            DialogResult ret;

            switch (arg.Index)
            {
            case 1:
            case 2:
                OnShowDlg(arg);
                break;

            case 3:
                ret         = GXHelpers.ShowMessageBox(this, Properties.Resources.CaptureWarning, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                arg.Handled = ret != DialogResult.Yes;
                break;

            case 4:
                ret         = GXHelpers.ShowMessageBox(this, Properties.Resources.ResetAlarm, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                arg.Handled = ret != DialogResult.Yes;
                break;

            case 5:
                ret         = GXHelpers.ShowMessageBox(this, Properties.Resources.SynchronizeClock, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                arg.Handled = ret != DialogResult.Yes;
                break;

            case 6:
            case 7:
                OnShowDlg(arg);
                break;
            }
        }
コード例 #4
0
 public void PostAction(GXActionArgs arg)
 {
     if (arg.Exception == null)
     {
         GXHelpers.ShowMessageBox(this, Properties.Resources.ActionImplemented, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     arg.Action = ActionType.None;
 }
コード例 #5
0
 public void PostAction(GXActionArgs arg)
 {
     if (arg.Exception == null)
     {
         GXHelpers.ShowMessageBox(this, Properties.Resources.ActionImplemented, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     arg.Action    = ActionType.None;
     arg.Rebooting = arg.Target.LogicalName == "0.0.10.0.0.255";
 }
コード例 #6
0
 public void PreAction(GXActionArgs arg)
 {
     if (GXHelpers.ShowMessageBox(this, Properties.Resources.ActivatePassiveCalendar, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information) == DialogResult.Yes)
     {
         arg.Value = (sbyte)0;
     }
     else
     {
         arg.Action = ActionType.None;
     }
 }
        public void PreAction(GXActionArgs arg)
        {
            arg.Value = (sbyte)0;
            DialogResult ret;

            if (arg.Index == 1)
            {
                //Reset.
                ret         = GXHelpers.ShowMessageBox(this, Properties.Resources.GeneralResetWarning, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                arg.Handled = ret != DialogResult.Yes;
            }
        }
コード例 #8
0
 public void PreAction(GXActionArgs arg)
 {
     if (arg.Action == ActionType.Write && arg.Index == 2)
     {
         //Update current time
         DialogResult ret = GXHelpers.ShowMessageBox(this, Properties.Resources.TimeSetWarning, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
         if (ret == DialogResult.Yes)
         {
             (Target as GXDLMSData).Value = GXDateTime.ToUnixTime(DateTime.Now.ToUniversalTime());
         }
         arg.Handled = ret != DialogResult.Yes;
     }
 }
コード例 #9
0
 void OnShowDialog(GXActionArgs arg)
 {
     if (InvokeRequired)
     {
         BeginInvoke(new ShowUserDialogEventHandler(OnShowDialog), arg).AsyncWaitHandle.WaitOne();
     }
     else
     {
         if (ProfileGenericView.SelectedCells.Count == 1)
         {
             DataGridViewRow row = ProfileGenericView.Rows[ProfileGenericView.SelectedCells[0].RowIndex];
             if (arg.Index == -1)
             {
                 //Add to the white list.
                 string data = "<Array Qty=\"01\" ><Structure Qty=\"04\" ><OctetString Value=\"" + row.Cells[2].Value + "\" /><UInt8 Value=\"63\" /><UInt16 Value=\"0004\" /><UInt8 Value=\"5\" /></Structure></Array>";
                 arg.Action = ActionType.Write;
                 arg.Index  = 2;
                 GXDLMSData d = new GXDLMSData("0.0.94.39.48.255");
                 d.SetDataType(2, DataType.Array);
                 d.Value    = GXDLMSTranslator.XmlToValue(data);
                 arg.Target = d;
             }
             else if (arg.Index == -2)
             {
                 //Add to the black list.
                 string data = "<Array Qty=\"01\" ><OctetString Value=\"" + row.Cells[2].Value + "\" /></Array>";
                 arg.Action = ActionType.Write;
                 arg.Index  = 2;
                 arg.Value  = GXDLMSTranslator.XmlToValue(data);
                 arg.Target = new GXDLMSData("0.0.94.39.47.255");
                 arg.Target.SetDataType(2, DataType.Array);
             }
             else if (arg.Index == -3)
             {
                 //Remove from the white or black list.
                 //Add to the white list.
                 long   unixTime = GXDateTime.ToUnixTime(DateTime.Parse(Convert.ToString(row.Cells[4].Value)));
                 string data     = "<Structure Qty=\"02\" ><OctetString Value=\"" + row.Cells[0].Value + "\" /><UInt32 Value=\"" + unixTime + "\" /></Structure>";
                 arg.Value = GXDLMSTranslator.XmlToValue(data);
                 ProfileGenericView.Rows.Remove(row);
             }
         }
         else
         {
             GXHelpers.ShowMessageBox(this, Properties.Resources.ProfileGenericDeviceAmountWarning, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
             arg.Handled = true;
         }
     }
 }
コード例 #10
0
 public void PostAction(GXActionArgs arg)
 {
     //Read value after reset.
     if (arg.Action == ActionType.Action)
     {
         arg.Index  = 2;
         arg.Action = ActionType.Read;
         return;
     }
     if (arg.Exception == null)
     {
         GXHelpers.ShowMessageBox(this, Properties.Resources.ActionImplemented, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     arg.Action = ActionType.None;
 }
コード例 #11
0
        public void PreAction(GXActionArgs arg)
        {
            arg.Value = (sbyte)0;
            DialogResult ret;

            if (arg.Index == 1)
            {
                //Reset.
                ret         = GXHelpers.ShowMessageBox(this, Properties.Resources.ProfileGenericResetWarning, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                arg.Handled = ret != DialogResult.Yes;
            }
            else if (arg.Index == 2)
            {
                //Capture.
                ret         = GXHelpers.ShowMessageBox(this, Properties.Resources.ProfileGenericCaptureWarning, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                arg.Handled = ret != DialogResult.Yes;
            }
            else if (arg.Index == -1)
            {
                //Add to the white list.
                ret = GXHelpers.ShowMessageBox(this, Properties.Resources.WhiteListWarning, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (ret == DialogResult.Yes)
                {
                    OnShowDialog(arg);
                }
                arg.Handled = ret != DialogResult.Yes;
            }
            else if (arg.Index == -2)
            {
                //Add to the black list.
                ret = GXHelpers.ShowMessageBox(this, Properties.Resources.BlackListWarning, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (ret == DialogResult.Yes)
                {
                    OnShowDialog(arg);
                }
                arg.Handled = ret != DialogResult.Yes;
            }
            else if (arg.Index == -3)
            {
                //Remove from te white or black list.
                ret = GXHelpers.ShowMessageBox(this, Properties.Resources.RemoveDeviceConfirmation, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (ret == DialogResult.Yes)
                {
                    OnShowDialog(arg);
                }
                arg.Handled = ret != DialogResult.Yes;
            }
        }
コード例 #12
0
 void OnExecuteScript(GXActionArgs arg)
 {
     if (InvokeRequired)
     {
         BeginInvoke(new ExecuteScriptEventHandler(OnExecuteScript), arg).AsyncWaitHandle.WaitOne();
     }
     else
     {
         DialogResult ret = GXHelpers.ShowMessageBox(this, Properties.Resources.ScriptTableExecute, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
         if (ret == DialogResult.Yes)
         {
             arg.Value = (Target as GXDLMSScriptTable).Execute(arg.Client, UInt16.Parse(ScriptId.Text));
         }
         arg.Handled = ret != DialogResult.Yes;
     }
 }
コード例 #13
0
        public void PreAction(GXActionArgs arg)
        {
            DialogResult ret;

            if (arg.Action == ActionType.Write)
            {
                if (arg.Index == 2)
                {
                    //Update current time
                    ret = GXHelpers.ShowMessageBox(this, Properties.Resources.TimeSetWarning, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    if (ret == DialogResult.Yes)
                    {
                        (Target as GXDLMSClock).Time = DateTime.Now;
                    }
                    arg.Handled = ret != DialogResult.Yes;
                }
                else if (arg.Index == 3)
                {
                    //Update current time zone.
                    ret = GXHelpers.ShowMessageBox(this, Properties.Resources.TimeZoneSetWarning, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    if (ret == DialogResult.Yes)
                    {
                        if (arg.Client.UseUtc2NormalTime)
                        {
                            (Target as GXDLMSClock).TimeZone = (int)TimeZoneInfo.Local.BaseUtcOffset.TotalMinutes;
                        }
                        else
                        {
                            (Target as GXDLMSClock).TimeZone = -(int)TimeZoneInfo.Local.BaseUtcOffset.TotalMinutes;
                        }
                        Target.UpdateDirty(3, (Target as GXDLMSClock).TimeZone);
                    }
                    arg.Handled = ret != DialogResult.Yes;
                }
            }
            else if (arg.Action == ActionType.Action)
            {
                if (arg.Index == 5 || arg.Index == 6)
                {
                    OnShowDlg(arg);
                }
                else
                {
                    arg.Value = (sbyte)0;
                }
            }
        }
コード例 #14
0
 public void PostAction(GXActionArgs arg)
 {
     if (arg.Exception == null && arg.Action == ActionType.Action)
     {
         if (arg.Index == 1)
         {
             arg.Action = ActionType.Read;
             arg.Index  = 2;
         }
         else
         {
             if (arg.Index == 2)
             {
                 GXHelpers.ShowMessageBox(this, Properties.Resources.ActionImplemented, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else if (arg.Index == 4)
             {
                 GXHelpers.ShowMessageBox(this, Properties.Resources.ActionImplemented, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else if (arg.Index == 5)
             {
                 BeginInvoke(new GetValueEventHandler(SaveCertificateRequest), arg).AsyncWaitHandle.WaitOne();
             }
             else if (arg.Index == 6)
             {
                 GXHelpers.ShowMessageBox(this, Properties.Resources.ActionImplemented, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else if (arg.Index == 7)
             {
                 BeginInvoke(new GetValueEventHandler(SaveCertificate), arg).AsyncWaitHandle.WaitOne();
             }
             else if (arg.Index == 8)
             {
                 GXHelpers.ShowMessageBox(this, Properties.Resources.ActionImplemented, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             arg.Action = ActionType.None;
         }
     }
     else
     {
         arg.Action = ActionType.None;
     }
 }
コード例 #15
0
        public void PreAction(GXActionArgs arg)
        {
            arg.Value = (sbyte)0;
            DialogResult ret;

            if (arg.Index == 1)
            {
                //Request Action.
                ret = GXHelpers.ShowMessageBox(this, Properties.Resources.AccountActivateWarning, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (ret == DialogResult.Yes)
                {
                }
                arg.Handled = ret != DialogResult.Yes;
            }
            else if (arg.Index == 1)
            {
                //Reset.
                ret         = GXHelpers.ShowMessageBox(this, Properties.Resources.RegisterResetWarning, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                arg.Handled = ret != DialogResult.Yes;
            }
        }
コード例 #16
0
        public void PostAction(GXActionArgs arg)
        {
            GXDLMSImageTransfer it = Target as GXDLMSImageTransfer;

            if (arg.Action == ActionType.Read)
            {
                if (arg.Index == 5)
                {
                    if (!it.ImageTransferEnabled)
                    {
                        updatingImage = false;
                        GXHelpers.ShowMessageBox(this, Properties.Resources.ImageTransferDisabled, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        arg.Action = ActionType.None;
                        return;
                    }
                    OnDescription(Properties.Resources.ImageTransferEnabled);
                    //Get ImageBlockSize.
                    arg.Index = 2;
                }
                else if (arg.Index == 2)
                {
                    OnDescription(Properties.Resources.ImageBlockSize + it.ImageBlockSize);
                    //Invoke Initiates image transfer.
                    arg.Index  = 1;
                    arg.Action = ActionType.Action;
                }
                else if (arg.Index == 6)
                {
                    OnImageTransferStatus(it.ImageTransferStatus);
                    GetDelay(arg);
                    if (arg.Exception != null)
                    {
                        return;
                    }
                    int delay = (int)arg.Value;
                    arg.Value = null;
                    switch (it.ImageTransferStatus)
                    {
                    case ImageTransferStatus.NotInitiated:
                        if (++statusReadCount > 10)
                        {
                            OnDescription("Failed to read Image transfer status after image transfer initiate.");
                            GXHelpers.ShowMessageBox(this, "Failed to read Image transfer status after image transfer initiate.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            arg.Action    = ActionType.None;
                            updatingImage = false;
                            return;
                        }
                        Thread.Sleep(delay);
                        arg.Index = 6;
                        break;

                    case ImageTransferStatus.TransferInitiated:
                        if (!transformingImage)
                        {
                            arg.Action        = ActionType.Action;
                            arg.Index         = 2;
                            transformingImage = true;
                        }
                        else
                        {
                            if (!Properties.Settings.Default.ImageManualUpdate)
                            {
                                arg.Index  = 3;
                                arg.Action = ActionType.Action;
                            }
                            else
                            {
                                arg.Action = ActionType.None;
                                ManualBtn_CheckedChanged(null, null);
                            }
                        }
                        break;

                    case ImageTransferStatus.VerificationInitiated:
                        Thread.Sleep(delay);
                        OnDescription(Properties.Resources.VerificationInitiated);
                        arg.Text  = Properties.Resources.VerificationInitiated;
                        arg.Index = 6;
                        break;

                    case ImageTransferStatus.VerificationSuccessful:
                        arg.Index  = 4;
                        arg.Action = ActionType.Action;
                        break;

                    case ImageTransferStatus.VerificationFailed:
                        OnDescription(Properties.Resources.VerificationFailed);
                        arg.Text   = Properties.Resources.VerificationFailed;
                        arg.Action = ActionType.None;
                        break;

                    case ImageTransferStatus.ActivationInitiated:
                        Thread.Sleep(delay);
                        OnDescription(Properties.Resources.ActivationInitiated);
                        arg.Text = Properties.Resources.ActivationInitiated;
                        break;

                    case ImageTransferStatus.ActivationSuccessful:
                        OnDescription(Properties.Resources.ActivationSuccessful);
                        GXHelpers.ShowMessageBox(this, Properties.Resources.ImageActivatedTxt, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        arg.Action = ActionType.None;
                        break;

                    case ImageTransferStatus.ActivationFailed:
                        OnDescription(Properties.Resources.ActivationFailed);
                        arg.Text   = Properties.Resources.ActivationFailed;
                        arg.Action = ActionType.None;
                        break;
                    }
                }
            }
            else if (arg.Action == ActionType.Action)
            {
                if (arg.Index == 1)
                {
                    OnDescription("Image transfer initiated.");
                    arg.Action = ActionType.Read;
                    arg.Index  = 6;
                }
                else if (arg.Index == 2)
                {
                    OnDescription("Image transfered.");
                    arg.Index  = 6;
                    arg.Action = ActionType.Read;
                }
                else if (arg.Index == 3)
                {
                    if (arg.Exception is GXDLMSException)
                    {
                        //If meter is activating image.
                        if ((arg.Exception as GXDLMSException).ErrorCode == (int)ErrorCode.TemporaryFailure)
                        {
                            if (!Properties.Settings.Default.ImageManualUpdate)
                            {
                                arg.Exception = null;
                                GetDelay(arg);
                                if (arg.Exception != null)
                                {
                                    return;
                                }
                                int delay = (int)arg.Value;
                                Thread.Sleep(delay);
                                arg.Value = null;
                            }
                            return;
                        }
                    }
                    if (!Properties.Settings.Default.ImageManualUpdate)
                    {
                        arg.Index  = 6;
                        arg.Action = ActionType.Read;
                    }
                    else
                    {
                        arg.Action = ActionType.None;
                    }
                }
                else if (arg.Index == 4)
                {
                    if (arg.Exception is GXDLMSException)
                    {
                        //If meter is activating image.
                        if ((arg.Exception as GXDLMSException).ErrorCode == (int)ErrorCode.TemporaryFailure)
                        {
                            if (!Properties.Settings.Default.ImageManualUpdate)
                            {
                                arg.Exception = null;
                                GetDelay(arg);
                                if (arg.Exception != null)
                                {
                                    return;
                                }
                                int delay = (int)arg.Value;
                                Thread.Sleep(delay);
                                arg.Value = null;
                            }
                            return;
                        }
                    }
                    OnDescription(Properties.Resources.ImageActivatedTxt);
                    arg.Action    = ActionType.None;
                    arg.Rebooting = true;
                }
            }
        }
コード例 #17
0
        public void PostAction(GXActionArgs arg)
        {
            GXDLMSImageTransfer it     = Target as GXDLMSImageTransfer;
            GXImageUpdateStatus status = (GXImageUpdateStatus)arg.Tag;

            if (arg.Action == ActionType.Read)
            {
                if (arg.Index == 5)
                {
                    if (!it.ImageTransferEnabled)
                    {
                        GXHelpers.ShowMessageBox(this, Properties.Resources.ImageTransferDisabled, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        arg.Action = ActionType.None;
                        return;
                    }
                    OnDescription(Properties.Resources.ImageTransferEnabled);
                    //Get ImageBlockSize.
                    arg.Index = 2;
                }
                else if (arg.Index == 2)
                {
                    OnDescription(Properties.Resources.ImageBlockSize + it.ImageBlockSize);
                    //Read image_transferred_blocks_status.
                    arg.Index = 3;
                }
                else if (arg.Index == 3)
                {
                    int index = 0;
                    foreach (char b in it.ImageTransferredBlocksStatus)
                    {
                        if (b == '0')
                        {
                            DialogResult ret = GXHelpers.ShowMessageBox(this, index + " Image blocks already exists. Do you want to overwrite image? " + Environment.NewLine
                                                                        + "Answering No will update missing blocks.", "GXDLMSDirector",
                                                                        MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                            if (ret == DialogResult.Cancel)
                            {
                                arg.Action = ActionType.None;
                                return;
                            }
                            if (ret == DialogResult.No)
                            {
                                status.ImageStartIndex = index;
                                arg.Index  = 2;
                                arg.Action = ActionType.Action;
                                return;
                            }
                            break;
                        }
                        ++index;
                    }
                    OnDescription(Properties.Resources.ImageBlockSize + it.ImageBlockSize);
                    //Invoke Initiates image transfer.
                    arg.Index  = 1;
                    arg.Action = ActionType.Action;
                }
                else if (arg.Index == 6)
                {
                    OnImageTransferStatus(it.ImageTransferStatus);
                    GetDelay(arg);
                    if (arg.Exception != null)
                    {
                        return;
                    }
                    int delay = (int)arg.Value;
                    arg.Value = null;
                    switch (it.ImageTransferStatus)
                    {
                    case ImageTransferStatus.NotInitiated:
                        if (++status.StatusReadCount > 10)
                        {
                            OnDescription("Failed to read Image transfer status after image transfer initiate.");
                            GXHelpers.ShowMessageBox(this, "Failed to read Image transfer status after image transfer initiate.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            arg.Action = ActionType.None;
                            return;
                        }
                        Thread.Sleep(delay);
                        arg.Index = 6;
                        break;

                    case ImageTransferStatus.TransferInitiated:
                        if (!status.TransformingImage)
                        {
                            arg.Action = ActionType.Action;
                            arg.Index  = 2;
                            status.TransformingImage = true;
                        }
                        else
                        {
                            if (!Properties.Settings.Default.ImageManualUpdate)
                            {
                                arg.Action = ActionType.Action;
                                if (arg.Client.CanInvoke(arg.Target, 3))
                                {
                                    arg.Index = 3;
                                }
                                else if (arg.Client.CanInvoke(arg.Target, 4))
                                {
                                    arg.Index = 4;
                                }
                                else
                                {
                                    GXHelpers.ShowMessageBox(this, Properties.Resources.ImageTransferedNotActivatedTxt, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    arg.Action = ActionType.None;
                                }
                            }
                            else
                            {
                                arg.Action = ActionType.None;
                                ManualBtn_CheckedChanged(null, null);
                            }
                        }
                        break;

                    case ImageTransferStatus.VerificationInitiated:
                        Thread.Sleep(delay);
                        OnDescription(Properties.Resources.VerificationInitiated);
                        arg.Text  = Properties.Resources.VerificationInitiated;
                        arg.Index = 6;
                        break;

                    case ImageTransferStatus.VerificationSuccessful:
                        arg.Index  = 4;
                        arg.Action = ActionType.Action;
                        break;

                    case ImageTransferStatus.VerificationFailed:
                        OnDescription(Properties.Resources.VerificationFailed);
                        arg.Text   = Properties.Resources.VerificationFailed;
                        arg.Action = ActionType.None;
                        break;

                    case ImageTransferStatus.ActivationInitiated:
                        Thread.Sleep(delay);
                        OnDescription(Properties.Resources.ActivationInitiated);
                        arg.Text = Properties.Resources.ActivationInitiated;
                        break;

                    case ImageTransferStatus.ActivationSuccessful:
                        OnDescription(Properties.Resources.ActivationSuccessful);
                        GXHelpers.ShowMessageBox(this, Properties.Resources.ImageActivatedTxt, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        arg.Action = ActionType.None;
                        break;

                    case ImageTransferStatus.ActivationFailed:
                        OnDescription(Properties.Resources.ActivationFailed);
                        arg.Text   = Properties.Resources.ActivationFailed;
                        arg.Action = ActionType.None;
                        break;
                    }
                }
            }
            else if (arg.Action == ActionType.Action)
            {
                if (arg.Index == 1)
                {
                    OnDescription("Image transfer initiated.");
                    arg.Action = ActionType.Read;
                    arg.Index  = 6;
                }
                else if (arg.Index == 2)
                {
                    OnDescription("Image transfered.");
                    arg.Index  = 6;
                    arg.Action = ActionType.Read;
                }
                else if (arg.Index == 3)
                {
                    if (arg.Exception is GXDLMSException)
                    {
                        //If meter is verifying the image.
                        if ((arg.Exception as GXDLMSException).ErrorCode == (int)ErrorCode.TemporaryFailure)
                        {
                            if (!Properties.Settings.Default.ImageManualUpdate)
                            {
                                arg.Exception = null;
                                GetDelay(arg);
                                if (arg.Exception != null)
                                {
                                    return;
                                }
                                int delay = (int)arg.Value;
                                Thread.Sleep(delay);
                                arg.Value = null;
                            }
                        }
                        else
                        {
                            OnDescription("Image verifying failed.");
                        }
                        return;
                    }
                    if (!Properties.Settings.Default.ImageManualUpdate)
                    {
                        arg.Index  = 6;
                        arg.Action = ActionType.Read;
                    }
                    else
                    {
                        arg.Action = ActionType.None;
                    }
                }
                else if (arg.Index == 4)
                {
                    if (arg.Exception is GXDLMSException)
                    {
                        //If meter is activating image.
                        if ((arg.Exception as GXDLMSException).ErrorCode == (int)ErrorCode.TemporaryFailure)
                        {
                            if (!Properties.Settings.Default.ImageManualUpdate)
                            {
                                arg.Exception = null;
                                GetDelay(arg);
                                if (arg.Exception != null)
                                {
                                    return;
                                }
                                int delay = (int)arg.Value;
                                Thread.Sleep(delay);
                                arg.Value = null;
                            }
                        }
                        else
                        {
                            OnDescription("Image activation failed.");
                        }
                        return;
                    }
                    OnDescription(Properties.Resources.ImageActivatedTxt);
                    arg.Action    = ActionType.None;
                    arg.Rebooting = true;
                    GXHelpers.ShowMessageBox(this, Properties.Resources.ActionImplemented, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
コード例 #18
0
 public void PreAction(GXActionArgs arg)
 {
     //Add object to association view.
     if (arg.Index == 3)
     {
         GXDLMSObject it = new GXDLMSData();
         OnShowDialog(it, arg);
     }
     else if (arg.Index == 4)
     {
         // Remove object from association view.
         OnShowDialog(null, arg);
     }
     //Add user to user list.
     else if (arg.Index == 5)
     {
         OnShowDialog(true, arg);
     }
     else if (arg.Index == 6)
     {
         // Remove user from user list.
         OnShowDialog(false, arg);
     }
     if (arg.Action == ActionType.Write && arg.Index == 7)
     {
         DialogResult ret;
         //Update pw.
         ret = GXHelpers.ShowMessageBox(this, Properties.Resources.SetPasswordWarning, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
         if (ret == DialogResult.Yes)
         {
             byte[] value;
             if (SecretAsciiCb.Checked)
             {
                 value = ASCIIEncoding.ASCII.GetBytes(SecretTB.Text);
             }
             else
             {
                 value = GXDLMSTranslator.HexToBytes(SecretTB.Text);
             }
             GXDLMSAssociationLogicalName target = Target as GXDLMSAssociationLogicalName;
             if (target.AuthenticationMechanismName.MechanismId == Authentication.Low)
             {
                 arg.Index  = 7;
                 arg.Action = ActionType.Write;
             }
             else
             {
                 arg.Action = ActionType.Action;
                 arg.Index  = 2;
             }
             if (arg.Action == ActionType.Write)
             {
                 target.Secret = value;
             }
             else
             {
                 GXByteBuffer bb = new GXByteBuffer();
                 bb.SetUInt8((byte)DataType.OctetString);
                 bb.SetUInt8((byte)value.Length);
                 bb.Set(value);
                 arg.Value = bb.Array();
             }
         }
         arg.Handled = ret != DialogResult.Yes;
     }
     else if (arg.Action == ActionType.Write && arg.Index == 2)
     {
         //Skip write invoke.
         arg.Handled = true;
     }
 }