Exemplo n.º 1
0
        public static ActionLocation GetActionLocation(XElement element, Tree tree, ActionLocation defaultActionLocation = null)
        {
            XAttribute locationAttribute = element.Attribute("Location");

            if (locationAttribute == null)
            {
                return(ActionLocation.OtherPrimaryActionLocation);
            }

            switch (locationAttribute.Value)
            {
            case "Add":
                return(ActionLocation.AddPrimaryActionLocation);

            case "Edit":
                return(ActionLocation.EditPrimaryActionLocation);

            case "Delete":
                return(ActionLocation.DeletePrimaryActionLocation);

            case "Other":
                return(ActionLocation.OtherPrimaryActionLocation);

            default:
                if (defaultActionLocation != null)
                {
                    return(defaultActionLocation);
                }

                tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.WrongLocationValue", locationAttribute.Value);

                return(ActionLocation.OtherPrimaryActionLocation);
            }
        }
Exemplo n.º 2
0
        public void GivenHotelInNightTime_WithManySubCorridorsACandLightsOn_WhenMotionDetectedInOneCorridor_LightShouldbeOnAndPowerConsumptionInRange()
        {
            var hotel = new Hotel()
                        .With(new Floor()
                              .MainCorridorsWithSingleAcAndLight(corridorCount: 2)
                              .SubCorridorWithSingleAcAndLight(corridorCount: 5));

            var     actionLocation      = new ActionLocation(1, 1);
            IAction actiontobePerformed = new MovementAction(hotel, new ActionLocation(1, 1));

            actiontobePerformed.PerformAction();

            Assert.True(hotel
                        .Floors.First()
                        .SubCorridors[actionLocation.SubCorridor]
                        .Lights.First()
                        .Switch == Switch.ON);

            var firstfloor = hotel
                             .Floors.First();

            Console.WriteLine(firstfloor.MaxPowerConsumption());
            Console.WriteLine(firstfloor.CurrentPowerConsumption());
            Assert.True(firstfloor.MaxPowerConsumption() > firstfloor.CurrentPowerConsumption());
        }
Exemplo n.º 3
0
 public void ActionOccurred( ActionLocation location, ActionType type )
 {
     _actionOccurred = new ActionObj
      {
     ActionLocation = location,
     ActionType = type
      };
 }
Exemplo n.º 4
0
        private static ActionLocation GetActionLocation()
        {
            var floor          = _messaageArr.Length == 1 ?  0 : Convert.ToInt32(_messaageArr[1]);
            var subcorridor    = _messaageArr.Length == 1 ? 0 : Convert.ToInt32(_messaageArr[2]);
            var actionLocation = new ActionLocation(floor, subcorridor);

            return(actionLocation);
        }
Exemplo n.º 5
0
        public virtual ActionLocation locateSourceLineEnd(ActionLocation l, int stopAt)
        {
            ActionLocation end = m_container.endOfSourceLine(l);

            if (stopAt > -1 && end.at > stopAt)
            {
                end.at = stopAt;
            }
            return(end);
        }
        /// <summary> This routine is called from the DSwfInfo object
        /// and is used to obtain LineRecord information
        /// from the ActionLists
        ///
        /// The ActionLocation record is used as a holding
        /// container for state as we traverse the lists
        /// </summary>
        internal virtual void  probeForLineRecords(ActionList list, ActionLocation where, DSwfInfo info)
        {
            int size = list.size();

            for (int i = 0; i < size; i++)
            {
                try
                {
                    // set our context
                    where.at      = i;
                    where.actions = list;

                    // pull the action
                    Action a = list.getAction(i);

                    // then see if we need to traverse
                    if ((a.code == ActionConstants.sactionDefineFunction) || (a.code == ActionConstants.sactionDefineFunction2))
                    {
                        where.function = (DefineFunction)a;
                        probeForLineRecords(((DefineFunction)a).actionList, where, info);
                        where.function = null;
                    }
                    else if (a.code == ActionList.sactionLineRecord)
                    {
                        // hit a line record, so let's do our callback
                        info.processLineRecord(where, (LineRecord)a);
                    }
                    else if (a is DummyAction)
                    {
                        // our dummy container, then we drop in
                        where.className = ((DummyAction)a).ClassName;
                        probeForLineRecords(((DummyAction)a).ActionList, where, info);
                        where.className = null;
                    }
                }
                catch (Exception e)
                {
                    // this is fairly bad and probably means that we have corrupt line
                    // records in the swd, the exception being an ArrayIndexOutOfBoundsException.
                    // I've seen this in cases where a bad swc is built by authoring wherein a
                    // script id collision occurs and thus the offset table will contain references
                    // to line numbers that are non existent in one of the scripts.
                    // If its another type of exception...well, hopefully the trace message will
                    // help you track it down :)
                    if (Trace.error)
                    {
                        Trace.trace("Error processing ActionList at " + where.at + " at offset " + where.actions.getOffset(where.at) + " in swf " + info.Url);                         //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                        Console.Error.Write(e.StackTrace);
                        Console.Error.Flush();
                    }
                }
            }
        }
		/// <summary> This routine is called from the DSwfInfo object
		/// and is used to obtain LineRecord information 
		/// from the ActionLists
		/// 
		/// The ActionLocation record is used as a holding
		/// container for state as we traverse the lists
		/// </summary>
		internal virtual void  probeForLineRecords(ActionList list, ActionLocation where, DSwfInfo info)
		{
			int size = list.size();
			for (int i = 0; i < size; i++)
			{
				try
				{
					// set our context
					where.at = i;
					where.actions = list;
					
					// pull the action
					Action a = list.getAction(i);
					
					// then see if we need to traverse
					if ((a.code == ActionConstants.sactionDefineFunction) || (a.code == ActionConstants.sactionDefineFunction2))
					{
						where.function = (DefineFunction) a;
						probeForLineRecords(((DefineFunction) a).actionList, where, info);
						where.function = null;
					}
					else if (a.code == ActionList.sactionLineRecord)
					{
						// hit a line record, so let's do our callback
						info.processLineRecord(where, (LineRecord) a);
					}
					else if (a is DummyAction)
					{
						// our dummy container, then we drop in
						where.className = ((DummyAction) a).ClassName;
						probeForLineRecords(((DummyAction) a).ActionList, where, info);
						where.className = null;
					}
				}
				catch (Exception e)
				{
					// this is fairly bad and probably means that we have corrupt line
					// records in the swd, the exception being an ArrayIndexOutOfBoundsException. 
					// I've seen this in cases where a bad swc is built by authoring wherein a
					// script id collision occurs and thus the offset table will contain references
					// to line numbers that are non existent in one of the scripts.
					// If its another type of exception...well, hopefully the trace message will
					// help you track it down :)
					if (Trace.error)
					{
						Trace.trace("Error processing ActionList at " + where.at + " at offset " + where.actions.getOffset(where.at) + " in swf " + info.Url); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
						Console.Error.Write(e.StackTrace);
                        Console.Error.Flush();
                    }
				}
			}
		}
Exemplo n.º 8
0
    private List <Action> GetAvailableActionsForLocation(ActionLocation location)
    {
        List <Action> actionsAtLocation = null;

        if (!_actionsByLocation.TryGetValue(location, out actionsAtLocation))
        {
            Debug.LogError("No " + location + " Actions have been configured!");
            return(new List <Action>());
        }

        var available = actionsAtLocation.Where(a => IsActionAvailable(a)).ToList();

        if (!available.Any())
        {
            Debug.Log("No " + location + " Actions are currently available. Hopefully this is intentional.");
        }

        return(available);
    }
		/// <summary> Use the action list located in the given location
		/// and return a new action location that corresponds
		/// to the next line record that is encountered
		/// after this location.  This routine does not 
		/// span into another action list.
		/// </summary>
		public virtual ActionLocation endOfSourceLine(ActionLocation l)
		{
			ActionLocation current = new ActionLocation(l);
			int size = l.actions.size();
			for (int i = l.at + 1; i < size; i++)
			{
				// hit a line record => we done
				Action a = l.actions.getAction(i);
				if (a.code == ActionList.sactionLineRecord)
					break;
				
				// hit a function => we are done
				if ((a.code == ActionConstants.sactionDefineFunction) || (a.code == ActionConstants.sactionDefineFunction2))
					break;
				
				current.at = i;
			}
			return current;
		}
Exemplo n.º 10
0
        public static void PlayVow( ActionLocation loc )
        {
            if ( loc == ActionLocation.Left )
             {
            _vowInst1.Play();
            _vowInst1.Play();
             }

             if ( loc == ActionLocation.Middle )
             {
            _vowInst2.Play();
            _vowInst2.Play();
             }

             if ( loc == ActionLocation.Right )
             {
            _vowInst3.Play();
            _vowInst3.Play();
             }
        }
Exemplo n.º 11
0
        /// <summary> This is a callback function from LineFunctionContainer.combForLineRecords()
        /// We extract what we want and then update the associated module
        /// </summary>
        public virtual void  processLineRecord(ActionLocation where, LineRecord r)
        {
            int         line = r.lineno;
            String      func = (where.function == null)?null:where.function.name;
            DebugModule dm   = r.module;

            // locate the source file
            int     id = -1;
            DModule module;

            if (dm == null || where.at == -1)
            {
            }
            else if ((id = local2Global(dm.id)) < 0)
            {
            }
            else if ((module = m_manager.getSource(id)) == null)
            {
            }
            else
            {
                module.addLineFunctionInfo(where.actions.getOffset(where.at), line, func);
            }
        }
        /// <summary> Use the action list located in the given location
        /// and return a new action location that corresponds
        /// to the next line record that is encountered
        /// after this location.  This routine does not
        /// span into another action list.
        /// </summary>
        public virtual ActionLocation endOfSourceLine(ActionLocation l)
        {
            ActionLocation current = new ActionLocation(l);
            int            size    = l.actions.size();

            for (int i = l.at + 1; i < size; i++)
            {
                // hit a line record => we done
                Action a = l.actions.getAction(i);
                if (a.code == ActionList.sactionLineRecord)
                {
                    break;
                }

                // hit a function => we are done
                if ((a.code == ActionConstants.sactionDefineFunction) || (a.code == ActionConstants.sactionDefineFunction2))
                {
                    break;
                }

                current.at = i;
            }
            return(current);
        }
Exemplo n.º 13
0
 private static string CalculateActionCategoryGroupId(ActionLocation actionLocation)
 {
     // trying to aqvoid overflow - might be lamo way
     return("Key" + Math.Abs(Math.Abs(actionLocation.ActionGroup.Priority.GetHashCode()) - Math.Abs(actionLocation.ActionGroup.Name.GetHashCode())).ToString());
 }
Exemplo n.º 14
0
 private void ShakeHead( ActionLocation loc )
 {
     if ( loc == ActionLocation.Left )
      {
     _laynaHead.Shake();
      }
      else if ( loc == ActionLocation.Middle )
      {
     _dunkHead.Shake();
      }
      else if ( loc == ActionLocation.Right )
      {
     _brettHead.Shake();
      }
 }
Exemplo n.º 15
0
 public MovementAction(ActionLocation actionLocation, Time dayNightTime) : base(actionLocation, dayNightTime)
 {
 }
Exemplo n.º 16
0
        private static void InitializeWithCommonValue(XElement element, Tree tree, ActionNode actionNode, string defaultIconName, string defaultLabelName = null, ActionLocation defaultActionLocation = null, List <PermissionType> defaultPermissionTypes = null)
        {
            XAttribute labelAttribute   = element.Attribute("Label");
            XAttribute toolTipAttribute = element.Attribute("ToolTip");
            XAttribute iconAttribute    = element.Attribute("Icon");

            if ((defaultLabelName == null) && (labelAttribute == null))
            {
                tree.AddValidationError(element.GetXPath(), "TreeValidationError.Common.MissingAttribute", "Label");
            }

            actionNode.XPath    = element.GetXPath();
            actionNode.Id       = tree.BuildProcessContext.ActionIdCounter++;
            actionNode.Label    = labelAttribute.GetValueOrDefault(defaultLabelName);
            actionNode.ToolTip  = toolTipAttribute.GetValueOrDefault(actionNode.Label);
            actionNode.Icon     = FactoryHelper.GetIcon(iconAttribute.GetValueOrDefault(defaultIconName));
            actionNode.Location = GetActionLocation(element, tree, defaultActionLocation);
            if (defaultPermissionTypes != null)
            {
                actionNode.PermissionTypes = defaultPermissionTypes;
            }
            else
            {
                actionNode.PermissionTypes = GetPermissionTypes(element, tree);
            }
        }
Exemplo n.º 17
0
 public MovementAction(Hotel hotel, ActionLocation actionLocation) : base(hotel, actionLocation)
 {
 }
Exemplo n.º 18
0
		public virtual ActionLocation locateSourceLineEnd(ActionLocation l, int stopAt)
		{
			ActionLocation end = m_container.endOfSourceLine(l);
			if (stopAt > - 1 && end.at > stopAt)
				end.at = stopAt;
			return end;
		}
Exemplo n.º 19
0
		/// <summary> This is a callback function from LineFunctionContainer.combForLineRecords()
		/// We extract what we want and then update the associated module
		/// </summary>
		public virtual void  processLineRecord(ActionLocation where, LineRecord r)
		{
			int line = r.lineno;
			String func = (where.function == null)?null:where.function.name;
			DebugModule dm = r.module;
			
			// locate the source file
			int id = - 1;
			DModule module;
			
			if (dm == null || where.at == - 1)
			{
			}
			else if ((id = local2Global(dm.id)) < 0)
			{
			}
			else if ((module = m_manager.getSource(id)) == null)
			{
			}
			else
				module.addLineFunctionInfo(where.actions.getOffset(where.at), line, func);
		}
Exemplo n.º 20
0
 protected ActionBase(Hotel hotel, ActionLocation actionLocation)
 {
     Hotel          = hotel;
     ActionLocation = actionLocation;
     ShouldAcBeOn   = h => (!IsPowerConsumptionExceeded()) && (MaxToCurrentPoweConsumptionDiff() >= 10);
 }
Exemplo n.º 21
0
		/// <summary> Ask the container to locate the next line
		/// record following the location specified in the 
		/// location, without spilling over into the next
		/// action list
		/// </summary>
		public virtual ActionLocation locateSourceLineEnd(ActionLocation l)
		{
			return locateSourceLineEnd(l, - 1);
		}
Exemplo n.º 22
0
 public IdleForTwoMinuteAction(ActionLocation actionLocation) : base(actionLocation)
 {
 }
Exemplo n.º 23
0
 protected ActionBase(ActionLocation actionLocation, Time dayTime)
 {
     ActionLocation = actionLocation;
     ShouldAcBeOn   = h => (!IsPowerConsumptionExceeded()) && (MaxToCurrentPoweConsumptionDiff() >= 10);
     DayNightTime   = dayTime;
 }
Exemplo n.º 24
0
 public IdleForTwoMinuteAction(Hotel hotel, ActionLocation actionLocation) : base(hotel, actionLocation)
 {
 }
Exemplo n.º 25
0
 public MovementAction(ActionLocation actionLocation) : base(actionLocation)
 {
 }
Exemplo n.º 26
0
 public ActionHandler(ActionLocation actionLocation, ActionType actionType)
 {
     _movementType   = actionType;
     _actionLocation = actionLocation;
 }
Exemplo n.º 27
0
 public ActionHandler(ActionLocation actionLocation, ActionType actionType, Time dayNightTime)
 {
     _movementType   = actionType;
     _actionLocation = actionLocation;
     _dayNightTime   = dayNightTime;
 }
Exemplo n.º 28
0
 /// <summary> Ask the container to locate the next line
 /// record following the location specified in the
 /// location, without spilling over into the next
 /// action list
 /// </summary>
 public virtual ActionLocation locateSourceLineEnd(ActionLocation l)
 {
     return(locateSourceLineEnd(l, -1));
 }