예제 #1
0
        /// <summary>
        /// Read all data from the meter.
        /// </summary>
        public void ReadAll(bool useCache)
        {
            try
            {
                InitializeConnection();
                GetAssociationView(useCache);
                //Mikko
                GXDLMSAssociationLogicalName ln = Client.Objects.GetObjects(ObjectType.AssociationLogicalName)[0] as GXDLMSAssociationLogicalName;
                Read(ln, 10);
                Read(ln, 11);
                if (ln.UserList.Count != 0)
                {
                    throw new Exception("Mikko");
                }
                GXReplyData reply = new GXReplyData();
                if (!ReadDataBlock(ln.AddUser(Client, 1, "Mikko"), reply))
                {
                    if (reply.Error != (short)ErrorCode.Rejected)
                    {
                        throw new GXDLMSException(reply.Error);
                    }
                }
                //Update data type.
                Read(ln, 10);
                if (ln.UserList.Count != 1)
                {
                    throw new Exception("Mikko");
                }
                if (ln.UserList[0].Key != 1 || ln.UserList[0].Value != "Mikko")
                {
                    throw new Exception("Mikko");
                }
                reply.Clear();
                if (!ReadDataBlock(ln.RemoveUser(Client, 1, "Mikko"), reply))
                {
                    if (reply.Error != (short)ErrorCode.Rejected)
                    {
                        throw new GXDLMSException(reply.Error);
                    }
                }
                Read(ln, 10);
                if (ln.UserList.Count != 0)
                {
                    throw new Exception("Mikko");
                }

                /*
                 * GetScalersAndUnits();
                 * GetProfileGenericColumns();
                 * GetReadOut();
                 * GetProfileGenerics();
                 */
            }
            finally
            {
                Close();
            }
        }
예제 #2
0
 void OnShowDialog(bool addUser, GXActionArgs arg)
 {
     if (InvokeRequired)
     {
         BeginInvoke(new ShowUserDialogEventHandler(OnShowDialog), addUser, arg).AsyncWaitHandle.WaitOne();
     }
     else
     {
         GXDLMSAssociationLogicalName target = Target as GXDLMSAssociationLogicalName;
         if (addUser)
         {
             GXUserDlg dlg = new GXUserDlg((byte)target.UserList.Count, "", false);
             if (dlg.ShowDialog(this) == DialogResult.OK)
             {
                 ListViewItem li = UsersList.Items.Add(dlg.UserId.ToString());
                 li.SubItems.Add(dlg.UserName);
                 arg.Value = target.AddUser(arg.Client, dlg.UserId, dlg.UserName);
             }
             else
             {
                 arg.Handled = true;
             }
         }
         else
         {
             if (UsersList.SelectedItems.Count == 1)
             {
                 ListViewItem li  = UsersList.SelectedItems[0];
                 GXUserDlg    dlg = new GXUserDlg(byte.Parse(li.SubItems[0].Text), li.SubItems[1].Text, true);
                 if (dlg.ShowDialog(this) == DialogResult.OK)
                 {
                     arg.Value = target.RemoveUser(arg.Client, dlg.UserId, dlg.UserName);
                     li.Remove();
                 }
                 else
                 {
                     arg.Handled = true;
                 }
             }
             else
             {
                 arg.Handled = true;
             }
         }
     }
 }