示例#1
0
 /// <summary>
 /// Set Method attribute access.
 /// </summary>
 /// <param name="index"></param>
 /// <param name="access"></param>
 public void SetMethodAccess(int index, MethodAccessMode access)
 {
     GXDLMSAttributeSettings att = MethodAttributes.Find(index);
     if (att == null)
     {
         att = new GXDLMSAttributeSettings(index);
         MethodAttributes.Add(att);
     }
     att.MethodAccess = access;
 }
 public void OnAccessRightsChange(int index, MethodAccessMode mode, bool connected)
 {
 }
示例#3
0
        public void OnAccessRightsChange(int index, MethodAccessMode mode, bool connected)
        {
            bool enabled = connected && (mode & MethodAccessMode.Access) != 0;

            ScriptId.ReadOnly = !enabled;
        }
        public void OnValueChanged(int index, object value, bool user, bool connected)
        {
            GXDLMSAssociationLogicalName target = Target as GXDLMSAssociationLogicalName;

            //object list.
            if (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 += ", ";
                                }
                                AccessMode mode = it.GetAccess(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 += ", ";
                                }
                                MethodAccessMode mode = it.GetMethodAccess(pos);
                                str += pos.ToString() + " = " + mode;
                            }
                            li.SubItems.Add(str);
                        }
                    }
                }
            }
            //Associated partners ID.
            else if (index == 3)
            {
                ClientSAPTb.Text = Convert.ToString(target.ClientSAP);
                ServerSAPTb.Text = Convert.ToString(target.ServerSAP);
            }
            else if (index == 4)
            {
                // 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);
                ApplicationContextIDTb.Text = Convert.ToString(target.ApplicationContextName.ContextId);
            }
            else if (index == 5)
            {
                // xDLMS_context_info
                ConformanceTB.Text       = target.XDLMSContextInfo.Conformance.ToString();
                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 (index == 6)
            {
                // 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);
                AuthenticationMechanismIdTb.Text   = Convert.ToString(target.AuthenticationMechanismName.MechanismId);
            }
            else if (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 (index == 9)
            {
                SecuritySetupCb.Items.Clear();
                //security_setup_reference
                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);
                    }
                }
            }
            //user list.
            else if (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 (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;
                    }
                }
            }
        }
 public void OnAccessRightsChange(int index, MethodAccessMode mode, bool connected)
 {
     throw new IndexOutOfRangeException("index");
 }
示例#6
0
        public void OnValueChanged(int index, object value, bool user, bool connected)
        {
            GXDLMSAssociationShortName target = Target as GXDLMSAssociationShortName;
            GXDLMSObjectCollection     items  = target.ObjectList;

            if (index == 2)
            {
                ObjectsView.Items.Clear();
                if (items != null)
                {
                    SNItems.Clear();
                    foreach (GXDLMSObject it in items)
                    {
                        ListViewItem li = ObjectsView.Items.Add(Convert.ToString(it.ShortName, 16));
                        li.SubItems.AddRange(new string[] { it.ObjectType.ToString(), it.Version.ToString(),
                                                            it.LogicalName });
                        //access_rights: access_right
                        StringBuilder str = new StringBuilder();
                        //Show attribute access.
                        int cnt = (it as IGXDLMSBase).GetAttributeCount();
                        for (int pos = 1; pos != cnt + 1; ++pos)
                        {
                            if (str != null)
                            {
                                str.Append(", ");
                            }
                            AccessMode mode = it.GetAccess(pos);
                            str.Append(pos.ToString() + " = " + mode);
                        }
                        li.SubItems.Add(str.ToString());
                        //Show method access.
                        str.Length = 0;
                        cnt        = (it as IGXDLMSBase).GetMethodCount();
                        for (int pos = 1; pos != cnt + 1; ++pos)
                        {
                            if (str != null)
                            {
                                str.Append(", ");
                            }
                            MethodAccessMode mode = it.GetMethodAccess(pos);
                            str.Append(pos.ToString() + " = " + mode);
                        }
                        li.SubItems.Add(str.ToString());
                        if (it.ShortName != 0)
                        {
                            SNItems.Add(it.ShortName, li);
                        }
                        li.Tag = it;
                    }
                }
            }
            //Update Access rights.
            if (index == 3)
            {
                //access_rights: access_right
                foreach (GXDLMSObject it in items)
                {
                    ListViewItem  li  = SNItems[it.ShortName];
                    StringBuilder str = new StringBuilder();
                    //Show attribute access.
                    int cnt = (it as IGXDLMSBase).GetAttributeCount();
                    for (int pos = 1; pos != cnt + 1; ++pos)
                    {
                        if (str != null)
                        {
                            str.Append(", ");
                        }
                        AccessMode mode = it.GetAccess(pos);
                        str.Append(pos.ToString() + " = " + mode);
                    }
                    li.SubItems[4].Text = str.ToString();
                    //Show method access.
                    str.Length = 0;
                    cnt        = (it as IGXDLMSBase).GetMethodCount();
                    for (int pos = 1; pos != cnt + 1; ++pos)
                    {
                        if (str != null)
                        {
                            str.Append(", ");
                        }
                        MethodAccessMode mode = it.GetMethodAccess(pos);
                        str.Append(pos.ToString() + " = " + mode);
                    }
                    li.SubItems[5].Text = str.ToString();
                }
            }
            //security_setup_reference
            else if (index == 4)
            {
                //security_setup_reference
                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);
                    }
                }
            }
        }