public void OnValueChanged(int index, object value, bool user, bool connected) { if (index == 6) { GXDLMSSecuritySetup target = (GXDLMSSecuritySetup)Target; CertificatesLv.Items.Clear(); if (target.Certificates != null) { foreach (GXDLMSCertificateInfo it in target.Certificates) { ListViewItem li = CertificatesLv.Items.Add(it.Entity.ToString()); li.SubItems.Add(it.Type.ToString()); li.SubItems.Add(it.SerialNumber); li.SubItems.Add(it.Issuer); li.SubItems.Add(it.Subject); li.SubItems.Add(it.SubjectAltName); li.Tag = it; } } } else if (index != 2) { throw new IndexOutOfRangeException("index"); } }
public void OnValueChanged(GXDLMSViewArguments arg) { GXDLMSSecuritySetup target = (GXDLMSSecuritySetup)Target; if (arg.Index == 6) { CertificatesLv.Items.Clear(); if (target.Certificates != null) { foreach (GXDLMSCertificateInfo it in target.Certificates) { ListViewItem li = CertificatesLv.Items.Add(it.Entity.ToString()); li.SubItems.Add(it.Type.ToString()); li.SubItems.Add(it.SerialNumber.ToString()); li.SubItems.Add(it.Issuer); li.SubItems.Add(it.Subject); li.SubItems.Add(it.SubjectAltName); li.Tag = it; } } } else if (arg.Index == 2) { SecurityCb.Visible = Target.Version == 0; SecurityPolicyTB.Visible = Target.Version == 1; if (Target.Version == 0) { SecurityCb.SelectedItem = target.SecurityPolicy; } else { SecurityPolicyTB.SetItemChecked(0, (target.SecurityPolicy & SecurityPolicy.AuthenticatedRequest) != 0); SecurityPolicyTB.SetItemChecked(1, (target.SecurityPolicy & SecurityPolicy.EncryptedRequest) != 0); SecurityPolicyTB.SetItemChecked(2, (target.SecurityPolicy & SecurityPolicy.DigitallySignedRequest) != 0); SecurityPolicyTB.SetItemChecked(3, (target.SecurityPolicy & SecurityPolicy.AuthenticatedResponse) != 0); SecurityPolicyTB.SetItemChecked(4, (target.SecurityPolicy & SecurityPolicy.EncryptedResponse) != 0); SecurityPolicyTB.SetItemChecked(5, (target.SecurityPolicy & SecurityPolicy.DigitallySignedResponse) != 0); } } else if (arg.Index == 5) { SystemTitleDescriptionTb.Text = GXDLMSConverter.SystemTitleToString(Standard.DLMS, target.ServerSystemTitle, true); } else { throw new IndexOutOfRangeException("index"); } }
public void OnValueChanged(GXDLMSViewArguments arg) { GXDLMSAssociationLogicalName target = Target as GXDLMSAssociationLogicalName; //object list. if (arg.Index == 2) { GXDLMSObjectCollection items = target.ObjectList; ObjectsView.Items.Clear(); if (items != null) { foreach (GXDLMSObject it in items) { ListViewItem li = ObjectsView.Items.Add(it.ObjectType.ToString()); li.SubItems.Add(it.Version.ToString()); //Version li.SubItems.Add(it.LogicalName); li.Tag = it; //access_rights: access_right if (it is IGXDLMSBase) { string str = null; //Show attribute access. int cnt = (it as IGXDLMSBase).GetAttributeCount(); for (int pos = 1; pos != cnt + 1; ++pos) { if (str != null) { str += ", "; } if (target.Version < 3) { AccessMode mode = it.GetAccess(pos); str += pos.ToString() + " = " + mode; } else { AccessMode3 mode = it.GetAccess3(pos); str += pos.ToString() + " = " + mode; } } li.SubItems.Add(str); //Show method access. str = null; cnt = (it as IGXDLMSBase).GetMethodCount(); for (int pos = 1; pos != cnt + 1; ++pos) { if (str != null) { str += ", "; } if (target.Version < 3) { MethodAccessMode mode = it.GetMethodAccess(pos); str += pos.ToString() + " = " + mode; } else { MethodAccessMode3 mode = it.GetMethodAccess3(pos); str += pos.ToString() + " = " + mode; } } li.SubItems.Add(str); } } } } //Associated partners ID. else if (arg.Index == 3) { ClientSAPTb.Text = Convert.ToString(target.ClientSAP); ServerSAPTb.Text = Convert.ToString(target.ServerSAP); } else if (arg.Index == 4) { try { this.ApplicationContextIDCb.SelectedIndexChanged -= new System.EventHandler(this.ApplicationContextIDCb_SelectedIndexChanged); ApplicationContextIDCb.Items.Clear(); if (target.ApplicationContextName.ContextId == ApplicationContextName.LogicalName || target.ApplicationContextName.ContextId == ApplicationContextName.LogicalNameWithCiphering) { ApplicationContextIDCb.Items.AddRange(new object[] { ApplicationContextName.LogicalName, ApplicationContextName.LogicalNameWithCiphering }); } else { ApplicationContextIDCb.Items.AddRange(new object[] { ApplicationContextName.ShortName, ApplicationContextName.ShortNameWithCiphering }); } // Application context name. ApplicationJointISOCTTTb.Text = Convert.ToString(target.ApplicationContextName.JointIsoCtt); ApplicationCountryTb.Text = Convert.ToString(target.ApplicationContextName.Country); ApplicationCountryNameTb.Text = Convert.ToString(target.ApplicationContextName.CountryName); ApplicationIdentifiedOrganizationTb.Text = Convert.ToString(target.ApplicationContextName.IdentifiedOrganization); ApplicationDLMSUATb.Text = Convert.ToString(target.ApplicationContextName.DlmsUA); ApplicationContextTb.Text = Convert.ToString(target.ApplicationContextName.ApplicationContext); ApplicationContextIDCb.SelectedItem = target.ApplicationContextName.ContextId; ApplicationRegistrationAuthorityCb.SelectedItem = FindCountry(target.ApplicationContextName.JointIsoCtt, target.ApplicationContextName.Country, target.ApplicationContextName.CountryName); } finally { ApplicationContextIDCb.SelectedIndexChanged += new System.EventHandler(this.ApplicationContextIDCb_SelectedIndexChanged); } } else if (arg.Index == 5) { // xDLMS_context_info ShowConformance(target.XDLMSContextInfo.Conformance); MaxReceivePDUSizeTb.Text = target.XDLMSContextInfo.MaxReceivePduSize.ToString(); MaxSendPDUSizeTb.Text = target.XDLMSContextInfo.MaxSendPduSize.ToString(); DLMSVersionNumberTB.Text = target.XDLMSContextInfo.DlmsVersionNumber.ToString(); CypheringInfoTb.Text = GXDLMSTranslator.ToHex(target.XDLMSContextInfo.CypheringInfo); } else if (arg.Index == 6) { Freeze = true; // authentication_mechanism_name AuthenticationJointISOCTTTb.Text = Convert.ToString(target.AuthenticationMechanismName.JointIsoCtt); AuthenticationCountryTb.Text = Convert.ToString(target.AuthenticationMechanismName.Country); AuthenticationCountryNameTb.Text = Convert.ToString(target.AuthenticationMechanismName.CountryName); AuthenticationIdentifiedorganizationTb.Text = Convert.ToString(target.AuthenticationMechanismName.IdentifiedOrganization); AuthenticationDLMSUATb.Text = Convert.ToString(target.AuthenticationMechanismName.DlmsUA); AuthenticationMechanismNameTb.Text = Convert.ToString(target.AuthenticationMechanismName.AuthenticationMechanismName); AuthenticationMechanismIdCb.Text = Convert.ToString(target.AuthenticationMechanismName.MechanismId); AuthenticationRegistrationAuthorityCb.SelectedItem = FindCountry(target.AuthenticationMechanismName.JointIsoCtt, target.AuthenticationMechanismName.Country, target.AuthenticationMechanismName.CountryName); Freeze = false; } else if (arg.Index == 7) { //Secret. if (GXHelpers.IsAscii(target.Secret)) { SecretAsciiCb.Checked = true; SecretTB.Text = ASCIIEncoding.ASCII.GetString(target.Secret); } else { SecretTB.Text = GXDLMSTranslator.ToHex(target.Secret); } } else if (arg.Index == 9) { SecuritySetupCb.Items.Clear(); //security_setup_reference if (target.Parent != null) { SecuritySetupCb.Items.Add(""); foreach (GXDLMSSecuritySetup it in target.Parent.GetObjects(ObjectType.SecuritySetup)) { SecuritySetupCb.Items.Add(it); if (target.SecuritySetupReference == it.LogicalName) { SecuritySetupCb.SelectedIndexChanged -= new System.EventHandler(this.SecuritySetupCb_SelectedIndexChanged); SecuritySetupCb.SelectedItem = it; SecuritySetupCb.SelectedIndexChanged += new System.EventHandler(this.SecuritySetupCb_SelectedIndexChanged); } } } else { GXDLMSSecuritySetup it = new GXDLMSSecuritySetup(target.SecuritySetupReference); SecuritySetupCb.Items.Add(it); SecuritySetupCb.SelectedIndexChanged -= new System.EventHandler(this.SecuritySetupCb_SelectedIndexChanged); SecuritySetupCb.SelectedItem = it; SecuritySetupCb.SelectedIndexChanged += new System.EventHandler(this.SecuritySetupCb_SelectedIndexChanged); } } //User list. else if (arg.Index == 10) { List <KeyValuePair <byte, string> > items = target.UserList; UsersList.Items.Clear(); if (items != null) { foreach (KeyValuePair <byte, string> it in items) { ListViewItem li = UsersList.Items.Add(it.Key.ToString()); li.SubItems.Add(it.Value); li.Tag = it.Key; } } } else if (arg.Index == 11) //Current user { foreach (ListViewItem it in UsersList.Items) { if ((byte)it.Tag == target.CurrentUser.Key) { it.Selected = true; } else if (it.Selected) { it.Selected = false; } } } }