Example #1
0
        public override bool ResolveObject(VariableTable varTable)
        {
            if (!base.ResolveObject(varTable))
            {
                return(false);
            }

            if (_isRef)
            {
                ApplianceState stateVar = (ApplianceState)varTable[_stringValue];
                _valid = stateVar != null;

                if (_valid)
                {
                    _value = new ValueConstraint(stateVar);
                }
            }
            else
            {
                try
                {
                    _value = new PUCValue(State.Type.ValueSpace.Validate(_stringValue));
                }
                catch (Exception)
                {
                    _valid = false;
                    throw new PUC.Parsers.SpecParseException(this.LineNumber, "String value does not match the value space of state " + State.Name);
                }
            }

            return(_valid);
        }
Example #2
0
        /*
         * Static Main Testing Method
         */

#if VARTABLE_DEBUG
        public static void Main(string[] args)
        {
            VariableTable table = new VariableTable("TestSpec");

            ApplianceState state1 = new ApplianceState("TestState1", false);

            state1.Type = new PUCType(new IntegerSpace());
            table.RegisterObject("TestSpec.Group1.Group2.TestState1", state1);

            ApplianceState state2 = new ApplianceState("TestState2", false);

            state2.Type = new PUCType(new EnumeratedSpace(4));
            table.RegisterObject("TestSpec.Group1.TestState2", state2);

            ApplianceState state3 = new ApplianceState("Flag", false);

            state3.Type = new PUCType(new BooleanSpace());
            table.RegisterObject("TestSpec.Group1.ListGroup.Flag", state3);

            ApplianceState state4 = new ApplianceState("Date", false);

            state4.Type = new PUCType(new StringSpace());
            table.RegisterObject("TestSpec.Group1.Mailbox.Messages.Date", state4);

            ApplianceState state5 = new ApplianceState("TestState1", false);

            state5.Type = new PUCType(new StringSpace());
            table.RegisterObject("TestSpec.Group1.Group1.TestState1", state5);

            table.StoreValue("TestSpec.Group1.Mailbox[3].Messages[4].Date", "Mon, Jan 4 11:15am");
            table.StoreValue("TestSpec.Group1.ListGroup[2].Flag", true);
            table.StoreValue("TestSpec.Group1.Group2.TestState1", 2);

            bool flag = (bool)table.GetValue("TestSpec.Group1.ListGroup[2].Flag");
        }
Example #3
0
 public void SetParseVariables(GroupNode root,
                               VariableTable varTable, ArrayList dobjs)
 {
     _root            = root;
     _varTable        = varTable;
     _dependedObjects = dobjs;
     _applianceLabel  = _root.Labels;
 }
Example #4
0
        public void CreateExtraStates(Appliance appliance, VariableTable varTable)
        {
            _unionState      = new ApplianceState(appliance, UNION_STATE, _readonly);
            _unionState.Type = new PUCType(new StringSpace());
            GroupNode newG = new ObjectGroupNode(_unionState);

            newG.Parent = this;
            this.Children.Add(newG);
            varTable.RegisterObject(_unionState.FullName, _unionState);
        }
Example #5
0
        public override bool ResolveObject(VariableTable varTable)
        {
            bool r = base.ResolveObject(varTable);

            if (r && !(State.Type.ValueSpace is NumberSpace))
            {
                throw new NotSupportedException("LessThanDependency must be associated with numeric ValueSpaces!");
            }

            return(r);
        }
Example #6
0
        public virtual bool ResolveObject(VariableTable varTable)
        {
            ApplianceState stateVar = (ApplianceState)varTable[_stateName];

            _valid = stateVar != null;

            if (_valid)
            {
                _state = new ValueDataWindow(stateVar);
            }

            return(_valid);
        }
Example #7
0
        public bool ResolveObject(VariableTable varTable)
        {
            _listGroup = varTable.GetListGroup(_listGroupName);

            if (_listGroup == null)
            {
                throw new PUC.Parsers.SpecParseException(_lineNumber, "List group references by " + PUC.Parsers.SpecParser21.APPLY_OVER_TAG + " element could not be found: " + _listGroupName);
            }

            _valid       = true;
            _indexWindow = new IndexedDataWindow(_listGroup.DataWindow);

            return(_valid);
        }
Example #8
0
        public void ListChanged(VariableTable varTable, ListEventArgs e)
        {
            int listLength = (int)_listLengthState.Value;

            _defined = listLength > 0;

            if (_dataWindow.Index <= listLength)
            {
                _dataWindow.Update();
            }

            if (ListDataChanged != null)
            {
                ListDataChanged(this, e);
            }
        }
Example #9
0
        public void CreateExtraStates(VariableTable varTable, IBranchDataWindow window)
        {
            // Add Length State
            _listLengthState = new ApplianceState(_appliance, LIST_LENGTH_STATE, true);

            PUC.Types.IntegerSpace intSpace;
            if (_itemCount != null)
            {
                intSpace = new PUC.Types.IntegerSpace(_itemCount, _itemCount);
                if (_itemCount is IConstraint)
                {
                    new TypeConstraintListener(_listLengthState, (IConstraint)_itemCount);
                }
            }
            else if (_minimum == null && _maximum == null)
            {
                intSpace = new PUC.Types.IntegerSpace(new IntNumber(0), new IntNumber(Int32.MaxValue));
            }
            else if (_minimum != null && _maximum != null)
            {
                intSpace = new PUC.Types.IntegerSpace(_minimum, _maximum);

                if (_minimum is IConstraint)
                {
                    new TypeConstraintListener(_listLengthState, (IConstraint)_minimum);
                }
                if (_maximum is IConstraint)
                {
                    new TypeConstraintListener(_listLengthState, (IConstraint)_maximum);
                }
            }
            else if (_minimum != null)
            {
                intSpace = new IntegerSpace(_minimum, new IntNumber(Int32.MaxValue));

                if (_minimum is IConstraint)
                {
                    new TypeConstraintListener(_listLengthState, (IConstraint)_minimum);
                }
            }
            else
            {
                intSpace = new IntegerSpace(new IntNumber(0), _maximum);

                if (_maximum is IConstraint)
                {
                    new TypeConstraintListener(_listLengthState, (IConstraint)_maximum);
                }
            }

            _listLengthState.Type = new PUCType(intSpace);

            GroupNode newG = new ObjectGroupNode(_listLengthState);

            newG.Parent = this;
            this.Children.Add(newG);
            varTable.RegisterObject(_listLengthState.MakeFullName(this.FullPath), _listLengthState);
            window.AddChildWindow(_listLengthState);
            newG.Parent = null;             // remove from group so it doesn't get in the way later
            this.Children.Remove(newG);

            // Add Selection States
            _listSelectionState      = new ApplianceState(_appliance, LIST_SELECTION_STATE, _selectionReadOnly);
            _listSelectionState.Type = new PUCType(new IntegerSpace(new IntNumber(0), new NumberConstraint(_listSelectionState, _listLengthState)));

            if (_selectionType == SelectionType.One)
            {
                // one selection
                newG        = new ObjectGroupNode(_listSelectionState);
                newG.Parent = this;
                this.Children.Add(newG);
                _listSelectionState.FullName = _listSelectionState.MakeFullName(this.FullPath);
                _listSelectionState.SetNetworkHandler();
                window.AddChildWindow(_listSelectionState);
                newG.Parent = null;                 // remove from group so it doesn't get in the way later
                this.Children.Remove(newG);
            }
            else
            {
                // multiple selections
                BranchGroupNode selGroup = new BranchGroupNode();

                _listSelectionLengthState      = new ApplianceState(_appliance, LIST_LENGTH_STATE, false);
                _listSelectionLengthState.Type = new PUCType(new IntegerSpace(new IntNumber(0), new NumberConstraint(_listSelectionState, _listLengthState)));

                this.Children.Add(selGroup);
                selGroup.Name = LIST_SELECTION_STATE;
                newG          = new ObjectGroupNode(_listSelectionLengthState);
                newG.Parent   = selGroup;
                selGroup.Children.Add(newG);
                newG        = new ObjectGroupNode(_listSelectionState);
                newG.Parent = selGroup;
                selGroup.Children.Add(newG);

                varTable.RegisterObject(_listSelectionLengthState.MakeFullName(selGroup.FullPath), _listSelectionLengthState);
                _listSelectionState.FullName = _listSelectionState.MakeFullName(selGroup.FullPath);
                window.AddChildWindow(_listSelectionLengthState);
                window.AddChildWindow(_listSelectionState);

                this.Children.Remove(selGroup);
            }

            varTable.RegisterObject(_listSelectionState.FullName, _listSelectionState);
        }