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); } }
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()); }
public void ActionOccurred( ActionLocation location, ActionType type ) { _actionOccurred = new ActionObj { ActionLocation = location, ActionType = type }; }
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); }
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(); } } } }
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; }
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(); } }
/// <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); }
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()); }
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(); } }
public MovementAction(ActionLocation actionLocation, Time dayNightTime) : base(actionLocation, dayNightTime) { }
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); } }
public MovementAction(Hotel hotel, ActionLocation actionLocation) : base(hotel, actionLocation) { }
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 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); }
protected ActionBase(Hotel hotel, ActionLocation actionLocation) { Hotel = hotel; ActionLocation = actionLocation; ShouldAcBeOn = h => (!IsPowerConsumptionExceeded()) && (MaxToCurrentPoweConsumptionDiff() >= 10); }
/// <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); }
public IdleForTwoMinuteAction(ActionLocation actionLocation) : base(actionLocation) { }
protected ActionBase(ActionLocation actionLocation, Time dayTime) { ActionLocation = actionLocation; ShouldAcBeOn = h => (!IsPowerConsumptionExceeded()) && (MaxToCurrentPoweConsumptionDiff() >= 10); DayNightTime = dayTime; }
public IdleForTwoMinuteAction(Hotel hotel, ActionLocation actionLocation) : base(hotel, actionLocation) { }
public MovementAction(ActionLocation actionLocation) : base(actionLocation) { }
public ActionHandler(ActionLocation actionLocation, ActionType actionType) { _movementType = actionType; _actionLocation = actionLocation; }
public ActionHandler(ActionLocation actionLocation, ActionType actionType, Time dayNightTime) { _movementType = actionType; _actionLocation = actionLocation; _dayNightTime = dayNightTime; }
/// <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)); }