Ejemplo n.º 1
0
        private void SaveCrudDevice()
        {
            CrudDeviceViewModel viewModel = null;
            CrudDeviceModel     model     = null;

            viewModel = this;

            if (viewModel != null && viewModel.CrudDeviceModel != null)
            {
                model = viewModel.CrudDeviceModel;
            }


            List <_RegisterValue> registerValueList = new List <_RegisterValue>();

            for (int i = 0; i < model.RegisterCount; i++)
            {
                //string name = (model.AutoGenerateName == true) ? model.DeviceName + "_reg_" + i : "";
                //TODO default considered to be checked
                string         name          = model.DeviceName + "_reg_" + i;
                int            address       = model.StartingAddress + i;
                _RegisterValue registerValue = _RegisterValue.getRegisterValueFactory((EnumRegisterType)model.RegisterType, address, name);
                registerValueList.Add(registerValue);
            }

            RegisterGroup registerGroup = RegisterGroup.getRegisterGroupFactory(model, registerValueList);

            DeviceTreeModel configuration = new DeviceTreeModel()
            {
                DeviceName        = model.DeviceName,
                ConfigurationType = EnumConfigurationType.RegisterGroup,
                RegisterGroup     = registerGroup
            };


            MainWindow.Instance.DeviceTree.SelectedTreeNode.ListDeviceTreeModel.Add(configuration);
            //ConfigurationStore.getInstance().addConfiguration(configuration);

            MainWindow.Instance.DeviceTree.updateTree();
            MainWindow.Instance.ShowCrudDevice = false;



            string message = "Device Created successfully";

            viewModel.FeedbackMessage = message;
        }
Ejemplo n.º 2
0
        public CrudDeviceView()
        {
            InitializeComponent();

            DataContext = new CrudDeviceViewModel();
        }