Example #1
0
        public void         setupByForm(IDataItem aDataItem, IConnection aConnection, IWin32Window aOwner)
        {
            var lConnection = (Connection)aConnection;
            var lItem       = (DataItem)aDataItem;

            using (var lSetupForm = new ItemSetupForm(lConnection, lItem))
            {
                if (lSetupForm.ShowDialog(aOwner) == DialogResult.OK)
                {
                    lConnection.removeItem(lItem);
                    lConnection.waitCycleEnd();

                    lItem.SlaveID    = lSetupForm.SlaveID;
                    lItem.mSwapWords = lSetupForm.SwapWords;
                    lItem.setRegister(lSetupForm.RegisterType,
                                      lSetupForm.Register, lSetupForm.DataType, lSetupForm.Length);
                    lConnection.addItem(lItem);

                    lConnection.waitCycleEnd();
                    lItem.raisePropertiesChanged();
                    if (lConnection.Connected && lItem.Access.HasFlag(EAccess.READ))
                    {
                        lItem.raiseValueChanged();
                    }
                }
            }
        }
Example #2
0
        public IDataItem    createByForm(IConnection aConnection, IWin32Window aOwner)
        {
            var lConnection = (Connection)aConnection;
            var lItem       = new DataItem();

            using (var lSetupForm = new ItemSetupForm(lConnection, lItem))
            {
                if (lSetupForm.ShowDialog(aOwner) == DialogResult.OK)
                {
                    lItem.SlaveID = lSetupForm.SlaveID;
                    lItem.setRegister(lSetupForm.RegisterType,
                                      lSetupForm.Register, lSetupForm.DataType, lSetupForm.Length);
                    lItem.mSwapWords = lSetupForm.SwapWords;

                    lConnection.addItem(lItem);
                }
                else
                {
                    lItem = null;
                }
            }

            return(lItem);
        }