public GXDLMSActivityCalendarSeasonProfileDlg(GXDLMSSeasonProfile target, GXDLMSWeekProfile[] weekProfiles) { InitializeComponent(); Target = target; WeekProfile = weekProfiles; AsciiBtn.Checked = GXHelpers.IsAscii(Target.Name); NameTb.Text = GXHelpers.GetString(Target.Name); if (Target.Start != DateTime.MinValue) { StartTb.Text = Target.Start.ToFormatString(); } int pos, selected = -1; if (weekProfiles != null) { foreach (GXDLMSWeekProfile it in weekProfiles) { pos = WeekNameCb.Items.Add(it); if (selected == -1 && StructuralComparisons.StructuralEqualityComparer.Equals(Target.WeekName, it.Name)) { selected = pos; } } if (selected != -1) { WeekNameCb.SelectedIndex = selected; } } OkBtn.Enabled = weekProfiles != null && weekProfiles.Length != 0; }
private void UpdateSeasonProfile(GXDLMSSeasonProfile it, ListViewItem li, ListView target) { string str; if (GXHelpers.IsAscii(it.Name)) { str = ASCIIEncoding.ASCII.GetString(it.Name); } else { str = GXDLMSTranslator.ToHex(it.Name); } if (li == null) { li = target.Items.Add(str); li.SubItems.AddRange(new string[] { "", "" }); li.Tag = it; } else { li.SubItems[0].Text = str; } li.SubItems[1].Text = it.Start.ToFormatString(); if (GXHelpers.IsAscii(it.WeekName)) { li.SubItems[2].Text = ASCIIEncoding.ASCII.GetString(it.WeekName); } else { li.SubItems[2].Text = GXDLMSTranslator.ToHex(it.WeekName); } }
private void UpdateWeekProfile(GXDLMSWeekProfile it, ListViewItem li, ListView list) { string str; if (GXHelpers.IsAscii(it.Name)) { str = ASCIIEncoding.ASCII.GetString(it.Name); } else { str = GXDLMSTranslator.ToHex(it.Name); } if (li == null) { li = list.Items.Add(str); li.SubItems.AddRange(new string[] { it.Monday.ToString(), it.Tuesday.ToString(), it.Wednesday.ToString(), it.Thursday.ToString(), it.Friday.ToString(), it.Saturday.ToString(), it.Sunday.ToString() }); li.Tag = it; } else { li.SubItems[0].Text = str; li.SubItems[1].Text = it.Monday.ToString(); li.SubItems[2].Text = it.Tuesday.ToString(); li.SubItems[3].Text = it.Wednesday.ToString(); li.SubItems[4].Text = it.Thursday.ToString(); li.SubItems[5].Text = it.Friday.ToString(); li.SubItems[6].Text = it.Saturday.ToString(); li.SubItems[7].Text = it.Sunday.ToString(); } }
private void SecretAsciiCb_CheckedChanged(object sender, EventArgs e) { try { if (SecretAsciiCb.Checked) { byte[] data = GXDLMSTranslator.HexToBytes(SecretTB.Text); if (!GXHelpers.IsAscii(data)) { SecretAsciiCb.CheckedChanged -= SecretAsciiCb_CheckedChanged; SecretAsciiCb.Checked = !SecretAsciiCb.Checked; SecretAsciiCb.CheckedChanged += SecretAsciiCb_CheckedChanged; throw new ArgumentOutOfRangeException(Properties.Resources.InvalidASCII); } SecretTB.Text = ASCIIEncoding.ASCII.GetString(data); } else { SecretTB.Text = GXDLMSTranslator.ToHex(ASCIIEncoding.ASCII.GetBytes(SecretTB.Text)); } } catch (Exception ex) { MessageBox.Show(this, ex.Message); } }
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; } } } }
public GXDLMSActivityCalendarWeekProfileDlg(GXDLMSWeekProfile target, GXDLMSDayProfile[] days) { InitializeComponent(); Target = target; AsciiBtn.Checked = GXHelpers.IsAscii(Target.Name); NameTb.Text = GXHelpers.GetString(Target.Name); if (days == null || days.Length == 0) { MondayCb.Enabled = TuesdayCb.Enabled = WednesdayCb.Enabled = ThursdayCb.Enabled = FridayCb.Enabled = SaturdayCb.Enabled = SundayCb.Enabled = OkBtn.Enabled = false; } else { MondayCb.Items.AddRange(days); TuesdayCb.Items.AddRange(days); WednesdayCb.Items.AddRange(days); ThursdayCb.Items.AddRange(days); FridayCb.Items.AddRange(days); SaturdayCb.Items.AddRange(days); SundayCb.Items.AddRange(days); foreach (GXDLMSDayProfile it in days) { if (it.DayId == Target.Monday) { MondayCb.SelectedItem = it; break; } } foreach (GXDLMSDayProfile it in days) { if (it.DayId == Target.Tuesday) { TuesdayCb.SelectedItem = it; break; } } foreach (GXDLMSDayProfile it in days) { if (it.DayId == Target.Wednesday) { WednesdayCb.SelectedItem = it; break; } } foreach (GXDLMSDayProfile it in days) { if (it.DayId == Target.Thursday) { ThursdayCb.SelectedItem = it; break; } } foreach (GXDLMSDayProfile it in days) { if (it.DayId == Target.Friday) { FridayCb.SelectedItem = it; break; } } foreach (GXDLMSDayProfile it in days) { if (it.DayId == Target.Saturday) { SaturdayCb.SelectedItem = it; break; } } foreach (GXDLMSDayProfile it in days) { if (it.DayId == Target.Sunday) { SundayCb.SelectedItem = it; break; } } } }