public void Setup() { var measurementResultValue = new MeasurementResultValue(); measurementResultValue.DataValue = MeasurementValue; var measurementResult = new MeasurementResult(); measurementResult.MeasurementResultValues.Add(measurementResultValue); var result = new Result(); result.ResultDateTime = DateTime.Today; result.MeasurementResult = measurementResult; var samplingFeature = new SamplingFeature(); samplingFeature.SamplingFeatureTypeCV = "Specimen"; var featureAction = new FeatureAction(); featureAction.SamplingFeature = samplingFeature; featureAction.Results.Add(result); var action = new Core.Action(); action.ActionID = ActionId; action.FeatureActions.Add(featureAction); var actions = new List<Core.Action>(); actions.Add(action); supportedData = actions; var mockVersionHelper = new Mock<IDataVersioningHelper>(); mockVersionHelper.Setup(x => x.GetLatestVersionActionData(It.IsAny<Hatfield.EnviroData.Core.Action>())).Returns(action); mockVersionHelper.Setup(x => x.CloneActionData(It.IsAny<Hatfield.EnviroData.Core.Action>())).Returns(cloneAction(action)); var mockRepository = new Mock<IRepository<CV_RelationshipType>>(); testTool = new ChemistryValueCheckingTool(mockVersionHelper.Object, mockRepository.Object); mockChemistryValueCheckingRule = new Mock<ChemistryValueCheckingRule>(); }
private void ExecuteAfterPopulateSection() { try { ActionRunner runner = new ActionRunner(); Core.Action action = null; if (Section is DetailsSection) { if (DetailsSection.AfterPopulateSection != null) { action = ObjectCopier.Clone <Core.Action>(DetailsSection.AfterPopulateSection); } } if (Section is EditSection) { action = ObjectCopier.Clone <Core.Action>(EditSection.AfterPopulateSection); } if (action != null) { runner.Page = (BasePage)this.Page; runner.Action = action; runner.Execute(); } } catch (Exception ex) { throw ex; } }
public static void Link(Core.Action action, ActionBy actionBy) { action.ActionBies.Add(actionBy); actionBy.Action = action; actionBy.ActionID = action.ActionID; }
public static void Link(Core.Action action, RelatedAction relatedAction) { action.RelatedActions.Add(relatedAction); relatedAction.Action = action; relatedAction.ActionID = action.ActionID; }
public static void Link(Core.Action action, Method method) { action.Method = method; action.MethodID = method.MethodID; method.Actions.Add(action); }
public void ElementInteracted(bool finished, Element element, Core.Action action) { if (OnElementInteracted != null) { OnElementInteracted(finished, element, action); } }
public void ScaffoldTest() { var esdatModel = new ESDATModel(); var mockDb = new Mock <IDbContext>(); var mockDbContext = mockDb.Object; var duplicateChecker = new ODM2DuplicateChecker(mockDbContext); var defaultValueProvider = new StaticWQDefaultValueProvider(); var wayToHandleNewData = WayToHandleNewData.ThrowExceptionForNewData; var results = new List <IResult>(); var mapper = new RelatedActionMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results); var action1 = new Core.Action(); action1.ActionID = 101; var action2 = new Core.Action(); action2.ActionID = 102; mapper.SetRelationship(action1, "relationshipTypeCV", action2); var relatedAction = mapper.Draft(esdatModel); Assert.AreEqual(action1.ActionID, relatedAction.ActionID); Assert.AreEqual("relationshipTypeCV", relatedAction.RelationshipTypeCV); Assert.AreEqual(action2.ActionID, relatedAction.RelatedActionID); Assert.AreEqual(action1, relatedAction.Action); Assert.AreEqual(action2, relatedAction.Action1); }
public static void Link(Core.Action action, FeatureAction featureAction) { action.FeatureActions.Add(featureAction); featureAction.Action = action; featureAction.ActionID = action.ActionID; }
void ctrl_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e) { try { if (Me.SelectedIndexChanged != null) { ActionRunner runner = new ActionRunner(); Core.Action action = ObjectCopier.Clone <Core.Action>(Me.SelectedIndexChanged); runner.Page = (BasePage)this.Page; runner.Action = action; runner.Execute(); } } catch (Exception ex) { string ErrorMessageFormat = "ERROR - {0} - Control {1} ({2} - {3})"; string ErrorMessages = String.Format(ErrorMessageFormat, ex.Message, this.ControlID, Me.Type, this.ID); this.ctrl.Items.Insert(0, new RadComboBoxItem(ErrorMessages, String.Empty)); this.ctrl.BackColor = Color.Red; } }
public Core.Action GetNextVersionActionData(Core.Action originVersionActionData) { if (originVersionActionData.RelatedActions == null || !originVersionActionData.RelatedActions.Any()) { return(null); } else { try { var subVersionRelateAction = originVersionActionData.RelatedActions .Where(x => x.CV_RelationshipType.Name == _wqDefaultValueProvider.ActionRelationshipTypeSubVersion) .SingleOrDefault(); if (subVersionRelateAction == null) { return(null); } var childVersion = subVersionRelateAction.Action1; return(childVersion); } catch (Exception) { throw new ArgumentException("Action data is not allowed to have multiple direct children verion"); } } }
public void ScaffoldTest() { var esdatModel = new ESDATModel(); var mockDb = new Mock<IDbContext>(); var mockDbContext = mockDb.Object; var duplicateChecker = new ODM2DuplicateChecker(mockDbContext); var defaultValueProvider = new StaticWQDefaultValueProvider(); var wayToHandleNewData = WayToHandleNewData.ThrowExceptionForNewData; var results = new List<IResult>(); var mapper = new RelatedActionMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results); var action1 = new Core.Action(); action1.ActionID = 101; var action2 = new Core.Action(); action2.ActionID = 102; mapper.SetRelationship(action1, "relationshipTypeCV", action2); var relatedAction = mapper.Draft(esdatModel); Assert.AreEqual(action1.ActionID, relatedAction.ActionID); Assert.AreEqual("relationshipTypeCV", relatedAction.RelationshipTypeCV); Assert.AreEqual(action2.ActionID, relatedAction.RelatedActionID); Assert.AreEqual(action1, relatedAction.Action); Assert.AreEqual(action2, relatedAction.Action1); }
public override Core.Reinforcement PerformAction(Core.Action <int> action) { var transitionNoise = 0.0; var noise = 2.0 * accelerationFactor * transitionNoise * (random.NextDouble() - 0.5); if (action.SingleValue < 0 || action.SingleValue > 2) { throw new InvalidOperationException(); } double acceleration = accelerationFactor; Velocity += (noise + (action.SingleValue - 1) * acceleration) + GetSlope(Position) * gravityFactor; Velocity = Math.Min(Velocity, maxVelocity); Velocity = Math.Max(Velocity, minVelocity); Position += Velocity; Position = Math.Min(Position, MaxPosition); Position = Math.Max(Position, MinPosition); if (Position == MinPosition && Velocity < 0) { Velocity = 0; } UpdateCurrentState(); LastAction = action.SingleValue; return(Position >= GoalPosition ? rewardAtGoal : rewardPerStep); }
public override Core.Reinforcement PerformAction(Core.Action <int> action) { switch (action.SingleValue) { case (int)Action.Left: Left(); break; case (int)Action.Up: Up(); break; case (int)Action.Right: Right(); break; case (int)Action.Down: Down(); break; default: throw new InvalidOperationException(); } bool checkRightBarrier = x < 3 && y >= 1 && y < 8; bool checkLeftBarrier = x > 3 && y >= 1 && y < 8; bool checkUpBarrier = y < 8 && x >= 1 && x < 3; bool checkDownBarrier = y > 8 && x >= 1 && x < 3; x += vx; y += vy; if ((checkRightBarrier && x >= 3) || (checkLeftBarrier && x <= 3) || (checkUpBarrier && y >= 8) || (checkDownBarrier && y <= 8) || x < 0 || x > 10 || y < 0 || y > 10) { StartEpisodeInDefinedState(CurrentState.StateVector[0], CurrentState.StateVector[1], 0, 0); return(-5); } vx /= 3; vy /= 3; RectifyState(); UpdateCurrentState(); if (this.CurrentState.IsTerminal) { return(10); } return(-1); }
public override Core.Reinforcement PerformAction(Core.Action <double> action) { double force = Math.Max(minF, Math.Min(action[0], maxF)); double reward = -forcePenalty *Math.Abs(action[0] - force); Vector <double> ddq = null; for (double t = 0; t < externalDiscretization; t += internalDiscretization) { CalculateBChf(force); for (int i = 4; i < 8; ++i) { dq.At(i - 4, CurrentState[i]); } LU lu = new DenseLU(b); ddq = lu.Solve(f - h - c * dq); double dt = Math.Min(internalDiscretization, externalDiscretization - t); double dt2 = dt * dt; for (int i = 0; i < 4; i++) { CurrentState[i] += dt * CurrentState[4 + i] + 0.5 * dt2 * ddq[i]; CurrentState[4 + i] += dt * ddq[i]; } } for (int i = 1; i < 4; i++) { if (CurrentState[i] > Math.PI) { CurrentState[i] -= Math.PI * 2; } if (CurrentState[i] < -Math.PI) { CurrentState[i] += Math.PI * 2; } } CurrentState.IsTerminal = !IsStateOK(); if (IsStateOK()) { reward -= Math.Abs(CurrentState[0]); reward -= Math.Abs(CurrentState[1]); reward -= Math.Abs(CurrentState[2]); reward -= Math.Abs(CurrentState[3]); } else { reward -= boundryPenalty; } return(reward); }
public void AddBlock(string block, Core.Action action) { Program.AddBlock(block, action); if (action == Core.Action.End) { Model.Blocks = Blocks; } }
/// <summary> /// /// </summary> /// <param name="requestID"></param> public WorkflowRequest(int requestID) : base() { RequestID = requestID; dataworkflowRequest = new Data.WorkflowRequest(); UserAction = new Core.Action(); RequestTracks = new List <RequestComment>(); base.Init(); LoadComments(); }
/// <summary> /// /// </summary> public WorkflowRequest() { Name = ""; RequestNo = ""; RequestedBy = -1; RequestedFor = -1; RecentComment = ""; dataworkflowRequest = new Data.WorkflowRequest(); UserAction = new Core.Action(); RequestTracks = new List <RequestComment>(); }
public Core.Action GetLatestVersionActionData(Core.Action originVersionActionData) { var childVersion = GetNextVersionActionData(originVersionActionData); if (childVersion == null) { return(originVersionActionData); } else { return(GetLatestVersionActionData(childVersion)); } }
public virtual void ExecuteAction(CodeTorch.Core.Action sourceAction) { if (sourceAction != null) { ActionRunner runner = new ActionRunner(); Core.Action action = ObjectCopier.Clone <Core.Action>(sourceAction); runner.Page = (BasePage)this.Page; runner.Action = action; runner.Execute(); } }
public static void ExecuteAction(Page page, Core.Action action) { try { if (action != null) { ActionRunner runner = new ActionRunner(); runner.Page = page; runner.Action = action.Clone(); runner.Execute(); } } catch (Exception ex) { //log.Error(ex); //((BasePage)this.Page).DisplayErrorAlert(ex); } }
public void ScaffoldTest() { var esdatModel = new ESDATModel(); var mockDb = new Mock<IDbContext>(); var mockDbContext = mockDb.Object; var duplicateChecker = new ODM2DuplicateChecker(mockDbContext); var defaultValueProvider = new StaticWQDefaultValueProvider(); var wayToHandleNewData = WayToHandleNewData.ThrowExceptionForNewData; var results = new List<IResult>(); var mapper = new ActionByMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results); var action = new Core.Action(); action.ActionID = 101; var actionBy = mapper.Draft(esdatModel); Assert.AreEqual(true, actionBy.IsActionLead); }
public InteractuableResult Interacted(PointerEventData pointerData = null) { var ed = area.Element as Exit; if (Game.Instance.GameState.IsFirstPerson) { Game.Instance.Execute(new EffectHolder(new Effects { new ExecuteExitEffect(this) })); } else { var sceneMB = FindObjectOfType <SceneMB>(); var scene = sceneMB.SceneData as Scene; Rectangle actionArea = null; if (scene != null && scene.getTrajectory() == null) { // If no trajectory I have to move the area to the trajectory for it to be connected actionArea = ed.MoveAreaToTrajectory(sceneMB.Trajectory); } else { actionArea = new InfluenceArea(ed.getX() - 20, ed.getY() - 20, ed.getWidth() + 40, ed.getHeight() + 40); if (ed.getInfluenceArea() != null && ed.getInfluenceArea().isExists()) { var points = ed.isRectangular() ? ed.ToRect().ToPoints() : ed.getPoints().ToArray(); var topLeft = points.ToRect().position; actionArea = ed.getInfluenceArea().MoveArea(topLeft); } } var exitAction = new Core.Action(Core.Action.CUSTOM) { Effects = new Effects() { new ExecuteExitEffect(this) } }; exitAction.setNeedsGoTo(true); PlayerMB.Instance.Do(exitAction, actionArea); } return(InteractuableResult.DOES_SOMETHING); }
public void ScaffoldTest() { var esdatModel = new ESDATModel(); var mockDb = new Mock <IDbContext>(); var mockDbContext = mockDb.Object; var duplicateChecker = new ODM2DuplicateChecker(mockDbContext); var defaultValueProvider = new StaticWQDefaultValueProvider(); var wayToHandleNewData = WayToHandleNewData.ThrowExceptionForNewData; var results = new List <IResult>(); var mapper = new ActionByMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results); var action = new Core.Action(); action.ActionID = 101; var actionBy = mapper.Draft(esdatModel); Assert.AreEqual(true, actionBy.IsActionLead); }
/// <summary> /// /// </summary> /// <param name="requestedBy"></param> /// <param name="requestFor"></param> /// <param name="requestAction"></param> /// <returns></returns> public bool RaiseRequest(int requestedBy, int requestFor, RequestComment requestAction) { Core.Action _action = new Core.Action(); _action = GetAction(requestAction.StepID, requestAction.ActionID); this.CurrentStep = _action.GetNextStep(); this.RequestedBy = requestedBy; this.RequestedFor = requestFor; this.LastAction = requestAction.ActionID; this.LastActionBy = requestAction.CommentedBy; this.RecentComment = requestAction.Comments; this.ActionSatus = _action.GetStatusAsText(); requestAction.Status = _action.GetStatusAsText(); if (this.RequestID > 0) { SetRequestNo(); if (this.RequestNo == "-1") { return(false); } this.RequestID = dataworkflowRequest.Save(this.RequestNo, Name, RequestedBy, RequestedFor, ID, CurrentStep, (int)Status, ActionSatus, LastActionBy, LastAction); if (this.RequestID > 0) { return(true); } else { return(false); } } else { return(false); } }
void button_Click(object sender, EventArgs e) { log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); try { //find specified button by name string buttonID = ((System.Web.UI.WebControls.Button)sender).ID; CodeTorch.Core.ButtonControl button = Me.Buttons.Where(x => x.Name.ToLower() == buttonID.ToLower()).SingleOrDefault(); if (button != null) { //button was found...so call any commands it may have tied to this action ActionRunner runner = new ActionRunner(); Core.Action action = ObjectCopier.Clone <Core.Action>(button.OnClick); if (action != null) { runner.Page = (BasePage)this.Page; runner.Action = action; runner.Execute(); } } } catch (Exception ex) { log.Error(ex); page.DisplayErrorAlert(ex); } }
void button_Click(object sender, EventArgs e) { log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); try { ActionRunner runner = new ActionRunner(); Core.Action action = ObjectCopier.Clone <Core.Action>(Me.OnClick); if (action != null) { runner.Page = (BasePage)this.Page; runner.Action = action; runner.Execute(); } } catch (Exception ex) { log.Error(ex); ((BasePage)this.Page).DisplayErrorAlert(ex); } }
public void AddBlock(string block, Core.Action action) { Program.AddBlock(block, action); }
private Core.Action cloneAction(Core.Action action) { var measurementResultValueClone = new MeasurementResultValue(); measurementResultValueClone.DataValue = action.FeatureActions.FirstOrDefault().Results.FirstOrDefault() .MeasurementResult.MeasurementResultValues.FirstOrDefault().DataValue; var measurementResultClone = new MeasurementResult(); measurementResultClone.MeasurementResultValues.Add(measurementResultValueClone); var resultClone = new Result(); resultClone.ResultDateTime = action.FeatureActions.FirstOrDefault().Results.FirstOrDefault().ResultDateTime; resultClone.MeasurementResult = measurementResultClone; var samplingFeatureClone = new SamplingFeature(); samplingFeatureClone.SamplingFeatureTypeCV = action.FeatureActions.FirstOrDefault().SamplingFeature.SamplingFeatureTypeCV; var featureActionClone = new FeatureAction(); featureActionClone.SamplingFeature = samplingFeatureClone; featureActionClone.Results.Add(resultClone); var actionClone = new Core.Action(); actionClone.FeatureActions.Add(featureActionClone); return actionClone; }
public abstract void SetRelationship(Core.Action action, string relationshipTypeCV, Core.Action action1);
/// <summary> /// Place a buy or sell order /// </summary> public void ExecuteOrder(Core.Action action, OrderType orderType, int quantity) { //Place Order Broker.ExecuteOrder(_currentTradebar, orderType, action, quantity); }
private void Logic_GCodePush(string gcode, Core.Action action) { GCodePush?.Invoke(gcode, action); // Forward }
public override Core.Reinforcement PerformAction(Core.Action <int> action) { switch (action.SingleValue) { case 0: this.Ball.xdot += 0.2; break; case 1: this.Ball.ydot += 0.2; break; case 2: this.Ball.xdot -= 0.2; break; case 3: this.Ball.ydot -= 0.2; break; } this.Ball.xdot = Math.Min(Math.Max(this.Ball.xdot, -1), 1); this.Ball.ydot = Math.Min(Math.Max(this.Ball.ydot, -1), 1); for (int i = 1; i < 20; ++i) { this.Ball.step(); int collisions = 0; double dx = 0; double dy = 0; foreach (Obstacle o in obstacles) { if (o.collision(Ball)) { double[] d = o.collisionEffect(Ball); dx += d[0]; dy += d[1]; collisions++; intercept = o.getIntercept(); } } if (collisions == 1) { this.Ball.setVelocities(dx, dy); if (i == 19) { this.Ball.step(); } } else if (collisions > 1) { this.Ball.setVelocities(-this.Ball.getXDot(), -this.Ball.getYDot()); } if (episodeEnd()) { UpdateCurrentState(); return(10000); } } this.Ball.addDrag(); checkBounds(); UpdateCurrentState(); if (action.SingleValue == 4) { return(-1); } return(-5); }
public void ElementInteracted(bool finished, Element element, Core.Action action) { if (element == null || !TrackerAsset.Instance.Started) { return; } if (!finished) { if (trace != null) { Debug.LogError("An interaction has been made while another element is being interacted!!"); } if (element is NPC) { trace = TrackerAsset.Instance.GameObject.Interacted(element.getId(), GameObjectTracker.TrackedGameObject.Npc); } else if (element is Item) { trace = TrackerAsset.Instance.GameObject.Interacted(element.getId(), GameObjectTracker.TrackedGameObject.Item); } else if (element is ActiveArea) { trace = TrackerAsset.Instance.GameObject.Interacted(element.getId(), GameObjectTracker.TrackedGameObject.Item); } else { trace = TrackerAsset.Instance.GameObject.Interacted(element.getId(), GameObjectTracker.TrackedGameObject.GameObject); } trace.SetPartial(); Game.Instance.GameState.BeginChangeAmbit(trace); //Game.Instance.OnActionCanceled += ActionCanceled; UpdateElementsInteracted(element, action.getType().ToString(), element.getId()); } else { string actionType = string.Empty; switch (action.getType()) { case Core.Action.CUSTOM: actionType = (action as CustomAction).getName(); break; case Core.Action.CUSTOM_INTERACT: actionType = (action as CustomAction).getName(); break; case Core.Action.DRAG_TO: actionType = "drag_to"; break; case Core.Action.EXAMINE: actionType = "examine"; break; case Core.Action.GIVE_TO: actionType = "give_to"; break; case Core.Action.GRAB: actionType = "grab"; break; case Core.Action.TALK_TO: actionType = "talk_to"; break; case Core.Action.USE: actionType = "use"; break; case Core.Action.USE_WITH: actionType = "use_with"; break; } if (!string.IsNullOrEmpty(action.getTargetId())) { TrackerAsset.Instance.setVar("action_target", action.getTargetId()); } if (!string.IsNullOrEmpty(actionType)) { TrackerAsset.Instance.setVar("action_type", actionType); } Game.Instance.GameState.EndChangeAmbitAsExtensions(trace); trace.Completed(); trace = null; } }
public override void SetRelationship(Core.Action action, string relationshipTypeCV, Core.Action action1) { _action = action; _action1 = action1; _relationshipTypeCV = relationshipTypeCV; }