Example #1
0
        public bool WithinRange(NavMeshAgent agent, ICommandable element, Vector3 offset)
        {
            bool    flag1         = true;
            Vector3 commandCenter = element.CommandCenter;

            commandCenter.y = (__Null)0.0;
            Vector3 basePosition = Vector3.op_Addition(this._baseTransform.get_position(), offset);

            basePosition.y = (__Null)0.0;
            float distance = Vector3.Distance(commandCenter, basePosition);
            float num      = Mathf.Abs((float)(element.CommandCenter.y - this._baseTransform.get_position().y + this._offset.y));
            bool  flag2    = flag1 & (double)num < (double)this._height;

            if (flag2)
            {
                flag2 &= element.Entered(basePosition, distance, this._radius, this._allaroundRadius, this._commandFovAngle, this._baseTransform.get_forward());
            }
            if (flag2)
            {
                flag2 &= this.HasLabels(element);
            }
            if (flag2)
            {
                if (element is Actor)
                {
                    flag2 &= element.IsReachable(agent, this._agentRadius, this._allaroundRadius);
                }
                else
                {
                    flag2 &= element.IsReachable(agent, this._radius, this._allaroundRadius);
                }
            }
            return(flag2);
        }
Example #2
0
        public void Execute(ICommandable com)
        {
            info = com.Execute(this.details);
            int mult_Info = info.Get_Multi_Info();

            if (mult_Info == (int)MultiplayInfo.No_Multiplay)
            {
                string json = info.GetJson();
                FinishedTaskEventArgs finalInfo = new FinishedTaskEventArgs(json, true);
                Finished(this, finalInfo);
            }
            else if (mult_Info < (int)MultiplayInfo.Play_Request)
            {
                multi_manag.MultiplayReady += new MultiplayManager.MultiplayReadyHandler(MultiplayReady);
                multi_manag.PlayerMoved    += new MultiplayManager.PlayerMovedHandler(PlayerMoved);
                multi_manag.EndGame        += new MultiplayManager.EndGameHandler(EndGame);
                if (mult_Info == (int)MultiplayInfo.First_Request)
                {
                    multi_manag.FirstGameRequest(this);
                }
                else if (mult_Info == (int)MultiplayInfo.Second_Request)
                {
                    multi_manag.SecondGameRequest(this);
                }
            }
            else if (mult_Info == (int)MultiplayInfo.Play_Request)
            {
                multi_manag.PlayRequest(this);
            }
            else                 // mult_Info == MultiplayInfo.Close_Request
            {
                multi_manag.CloseRequest(this);
            }
        }
Example #3
0
        public bool CommandCondition(ICommandable element)
        {
            if (Object.op_Equality((Object)this._baseTransform, (Object)null))
            {
                return(false);
            }
            bool    flag1     = true;
            Vector3 vector3_1 = Quaternion.op_Multiply(Quaternion.Euler(0.0f, (float)this._baseTransform.get_eulerAngles().y, 0.0f), this._offset);
            Vector3 position  = element.Position;
            Vector3 vector3_2 = Vector3.op_Addition(this._baseTransform.get_position(), vector3_1);

            position.y = (__Null)(double)(vector3_2.y = (__Null)0.0f);
            float num1  = Vector3.Distance(position, vector3_2);
            float num2  = Mathf.Abs((float)(element.CommandCenter.y - this._baseTransform.get_position().y + this._offset.y));
            bool  flag2 = flag1 & (double)num2 < (double)this._height;
            bool  flag3;

            if (element.CommandType == CommandType.Forward)
            {
                bool  flag4 = flag2 & (double)num1 < (double)this._radius;
                float num3  = this._commandFovAngle / 2f;
                float num4  = Vector3.Angle(Vector3.op_Addition(Vector3.op_Subtraction(element.CommandCenter, this._baseTransform.get_position()), vector3_1), this._baseTransform.get_forward());
                flag3 = flag4 & (double)num4 < (double)num3;
            }
            else
            {
                flag3 = flag2 & (double)num1 < (double)this._allaroundRadius;
            }
            return(flag3);
        }
 public void Execute(ICommandable target)
 {
     var configurable = target as IConfigurable;
     if(configurable != null)
     {
         ConfigureTarget(configurable);
     }
 }
Example #5
0
 public void AddCommandableObject(ICommandable commandable)
 {
     if (!this._layerMask.Contains(commandable.Layer) || this._commandableObjects.Contains(commandable))
     {
         return;
     }
     this._commandableObjects.Add(commandable);
 }
 private void CleanPoint(ICommandable commandable, ActionPoint point)
 {
     if (!(commandable is ActionPoint) || Object.op_Equality((Object)(commandable as ActionPoint), (Object)point))
     {
         return;
     }
     this.CommandArea.RemoveConsiderationObject(commandable);
 }
Example #7
0
        /// <summary>
        ///		Creates a new timed event given a command and time to execute
        /// </summary>
        /// <param name="newCommand"></param>
        /// <param name="seconds"></param>
        /// <returns></returns>
        public TimedEvent Create(ICommandable newCommand, float seconds)
        {
            Debug.Assert(this.isPaused == false, "Trying to add a TimedEvent to a paused Timer!");

            TimedEvent newEvent = this.NewBaseCreate(seconds);

            newEvent.SetCommand(newCommand);
            return(newEvent);
        }
Example #8
0
        public void Execute(ICommandable target)
        {
            var configurable = target as IConfigurable;

            if (configurable != null)
            {
                ConfigureTarget(configurable);
            }
        }
Example #9
0
 public void RemoveConsiderationObject(ICommandable commandable)
 {
     if (!this._considerationObjects.Contains(commandable))
     {
         return;
     }
     commandable.SetImpossible(false, (Actor)Singleton <Manager.Map> .Instance.Player);
     this._considerationObjects.Remove(commandable);
 }
Example #10
0
 public Result WaitCommandReply(ICommandable command)
 {
     command.AutoEvent.WaitOne();
     if (command.State == CommandState.Failed)
     {
         return(Result.FAILED);
     }
     return(Result.OK);
 }
Example #11
0
 public void Invoke(ICommandable commandable)
 {
     if (_expression.Parameters.Single().Type.IsAssignableFrom(commandable.GetType()))
     {
         var del = _expression.Compile();
         del.DynamicInvoke(commandable);
     }
     else
         commandable.ProcessMissingCommand(this);
 }
Example #12
0
 public void AddSubordinate(ICommandable subordinate)
 {
     if (subordinate != null)
     {
         DirectSubordinates.Add(subordinate);
     }
     else
     {
         throw new ArgumentNullException(nameof(subordinate), "Subordinate cannot be null");
     }
 }
Example #13
0
        private bool HasLabels(ICommandable elem)
        {
            PlayerActor player     = Singleton <Manager.Map> .Instance.Player;
            AgentActor  agentActor = (AgentActor)null;

            if (Object.op_Inequality((Object)player, (Object)null))
            {
                agentActor = player.AgentPartner;
            }
            return(Object.op_Equality((Object)agentActor, (Object)null) ? !elem.Labels.IsNullOrEmpty <CommandLabel.CommandInfo>() : !(!Object.op_Inequality((Object)player, (Object)null) ? (CommandLabel.CommandInfo[])null : (player.Mode != Desire.ActionType.Date ? elem.Labels : elem.DateLabels)).IsNullOrEmpty <CommandLabel.CommandInfo>());
        }
Example #14
0
 public bool IsStartingPackage(Package Package)
 {
     if (Package is ICommandable)
     {
         ICommandable Command = Package as ICommandable;
         if (Command.Command == ConfigurationManager.AppSettings["StartGameCommand"])
         {
             return(true);
         }
     }
     return(false);
 }
Example #15
0
 private void ProcessPackage(Package pkg, Battleground battlegnd)
 {
     if (pkg is ICommandable)
     {
         ICommandable Command = pkg as ICommandable;
         ProcessCommand(pkg, Command);
     }
     if (pkg is ISimple)
     {
         ISimple Simple = pkg as ISimple;
         ProcessSimple(pkg, Simple);
     }
 }
Example #16
0
        public void Update()
        {
            if (this.currentCommand == null)
            {
                this.commandQueue.TryDequeue(out this.currentCommand);
            }

            if (this.currentCommand != null)
            {
                if (this.StopFlag)
                {
                    this.Stop();
                }

                this.currentCommand.Update();

                switch (this.currentCommand.State)
                {
                case CommandState.Idel:
                    if (this.currentCommand.Guard())
                    {
                        this.currentCommand.Call();
                    }
                    break;

                case CommandState.Running:
                    break;

                case CommandState.Pause:
                    break;

                case CommandState.Succeed:
                    this.currentCommand.AutoEvent.Set();
                    this.currentCommand.OnFinished?.Invoke();
                    this.currentCommand = null;
                    this.State          = ActiveItemState.Idel;
                    break;

                case CommandState.Failed:
                    this.currentCommand.AutoEvent.Set();
                    this.currentCommand.OnFinished?.Invoke();
                    this.currentCommand = null;
                    this.State          = ActiveItemState.Idel;
                    break;

                default:
                    break;
                }
            }
        }
Example #17
0
        public static void ProcessCommand(ChatContext context, string commandContext)
        {
            string cmdHandle = "";

            string[] args     = new string[] { "NONE" };
            bool     haveArgs = false;
            string   user     = context.name;

            if (commandContext.Contains(" "))
            {
                List <string> split = commandContext.Split(' ').ToList();
                cmdHandle = split[0];

                split.RemoveAt(0);
                args     = split.ToArray();
                haveArgs = true;
            }
            else
            {
                cmdHandle = commandContext;
                haveArgs  = false;
            }

            if (commands.ContainsKey(cmdHandle))
            {
                ICommandable cmd       = commands[cmdHandle];
                AuthLevel    authLevel = GetUserAuthLevel(user);
                if (authLevel >= cmd.authLevel)
                {
                    if (haveArgs)
                    {
                        cmd.InvokeCommand(context, user, args);
                    }
                    else
                    {
                        cmd.InvokeCommand(context, user);
                    }

                    OnCommandActivated?.Invoke(cmdHandle, args);
                }
                else
                {
                    Debug.LogError(user + " tried to use " + cmd.handle + " as a(n) " + authLevel);
                }
            }
            else
            {
                Debug.LogError("Couldnt find command.");
            }
        }
Example #18
0
        void Handle_ItemSelected(object sender, Xamarin.Forms.SelectedItemChangedEventArgs e)
        {
            // Only run on Android. iOS uses TextCell with Command property.
            if (Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.Android)
            {
                ICommandable item = e.SelectedItem as ICommandable;
                if (item != null && item.Command != null && item.Command.CanExecute(null))
                {
                    item.Command.Execute(null);
                }
            }

            ((ListView)sender).SelectedItem = null;
        }
Example #19
0
        void HandleShortRightClick()
        {
            if (_selectedObjects.Count == 0)
            {
                return;
            }

            ITargetable t = null;
            //Test to see if the mouse is over a targetable object
            Fixture f = _physicsManager.World.TestPoint(_uiConversionService.MousePosToSimUnits());

            if (f != null)
            {
                //Need to store references to the actual objects in userdata to make this much prettier and simpler
                ShipBodyDataObject s = f.Body.UserData as ShipBodyDataObject;
                if (s != null && s.Ship is ITargetable)
                {
                    t = (ITargetable)s.Ship;
                }

                StructureBodyDataObject b = f.Body.UserData as StructureBodyDataObject;
                if (b != null && b.Structure is ITargetable)
                {
                    t = (ITargetable)b.Structure;
                }
            }

            if (t != null)
            {
                foreach (var s in _selectedObjects)
                {
                    ICommandable i = s.Value as ICommandable;
                    if (i != null)
                    {
                        i.AttackTarget(t);
                    }
                }
                return;
            }

            foreach (var s in _selectedObjects)
            {
                if (s.Value is Ship)
                {
                    Ship ship = (Ship)s.Value;
                    ship.Pilot.GoToPosition(_uiConversionService.MousePosToSimUnits());
                }
            }
        }
Example #20
0
        public static bool AddCommand(ICommandable cmd)
        {
            bool rtn = false;

            if (commands.ContainsKey(cmd.handle))
            {
                Debug.LogWarning("There is already a defination for: " + cmd.handle);
                rtn = false;
            }
            else
            {
                commands.Add(cmd.handle, cmd);
                rtn = true;
            }

            return(rtn);
        }
Example #21
0
 public void RemoveCommandableObject(ICommandable commandable)
 {
     if (this._commandableObjects.Contains(commandable))
     {
         this._commandableObjects.Remove(commandable);
     }
     if (this._considerationObjects.Contains(commandable))
     {
         commandable.SetImpossible(false, (Actor)Singleton <Manager.Map> .Instance.Player);
         this._considerationObjects.Remove(commandable);
     }
     if (this._collisionStateTable.ContainsKey(commandable.InstanceID))
     {
         this._collisionStateTable.Remove(commandable.InstanceID);
     }
     this.RefreshCommands();
 }
Example #22
0
 private static bool executeCommand(ICommandable command)
 {
     command.Call();
     while (true)
     {
         Thread.Sleep(5);
         command.Update();
         if (command.State == CommandState.Running)
         {
             continue;
         }
         else if (command.State == CommandState.Succeed || command.State == CommandState.Failed)
         {
             break;
         }
     }
     return(command.State == CommandState.Succeed);
 }
Example #23
0
        private void SetCollisionState(
            ICommandable element,
            CollisionState state,
            ref int changedCount)
        {
            int            instanceId = element.InstanceID;
            CollisionState collisionState;

            this._collisionStateTable.TryGetValue(instanceId, out collisionState);
            if (collisionState == state)
            {
                return;
            }
            this._collisionStateTable[instanceId] = state;
            if (state != CollisionState.Enter && state != CollisionState.Exit)
            {
                return;
            }
            ++changedCount;
        }
Example #24
0
        public static void LoadCommands(Assembly assembly, string fileName)
        {
            var         commandType = typeof(ICommandable);
            List <Type> commands    = assembly.GetTypes().Where(x => commandType.IsAssignableFrom(x)).ToList();

            foreach (Type cType in commands)
            {
                ICommandable cmd    = (ICommandable)Activator.CreateInstance(cType);
                bool         canAdd = CommandHandler.AddCommand(cmd);

                if (canAdd)
                {
                    Debug.Log(string.Format("Command {0} from {1} added successfully", cmd.handle, fileName));
                }
                else
                {
                    Debug.LogError(string.Format("Command {0} from {1} failed", cmd.handle, fileName));
                }
            }
        }
Example #25
0
        private void Select(GameObject go)
        {
            _actor = go.GetComponent <Actor>();
            if (_actor == null)
            {
                _commandable     = null;
                _abilitiableHACK = null;
                if (_panel != null)
                {
                    _panel.SetTarget(null);
                }
                return;
            }

            _commandable     = _actor.GetModule <ICommandable>();
            _abilitiableHACK = _actor.GetModule <IAbilitiable>();
            if (_panel != null)
            {
                _panel.SetTarget(_actor);
            }
        }
Example #26
0
 /// <summary>
 /// Initializes a new instance of <see cref="Kubernetes"/>.
 /// </summary>
 /// <param name="shell">Decorate instance with a class with shell access.</param>
 public Kubernetes(ICommandable shell)
 {
     _shell = shell;
 }
Example #27
0
 public IdleStage(ICommandable commandable)
     : this()
 {
     _Commandable = commandable;
 }
Example #28
0
 public QueueableCommand(ICommandable commandable, T command)
 {
     this.commandable = commandable;
     this.command     = command;
 }
Example #29
0
 public ChoiceStage(ChoicePrototype protorype, ICommandable commandable)
 {
     _ChoicePrototype = protorype;
     _Commandable = commandable;
     _Agent = new Standalong.Agent();
 }
Example #30
0
 public void EnqueueCommand <T>(ICommandable actor, T command) where T : struct, IRoutineHandleable => ui.EnqueueCommand(actor, command);
Example #31
0
 private void ProcessCommand(Package pkg, ICommandable Command)
 {
     if (Command.Command == ConfigurationManager.AppSettings["StartGameCommand"])
     {
         NetCommandPackage SyncPackage = new NetCommandPackage();
         SyncPackage.Command         = ConfigurationManager.AppSettings["SyncGameCommand"];
         SyncPackage.InDeckCardCount = battlegnd.InStackCards.Count;
         SyncPackage.InHandCardCount = battlegnd.InHandCards.Count;
         SyncPackage.Scope           = battlegnd.UserCardsPower;
         SendMessage(SyncPackage);
     }
     else if (Command.Command == ConfigurationManager.AppSettings["SyncGameCommand"])
     {
         battlegnd.Control.Dispatcher.Invoke(() =>
         {
             battlegnd.Sync(Convert.ToString(pkg.Scope),
                            Convert.ToString(pkg.InDeckCardCount), Convert.ToString(pkg.InHandCardCount));
         });
         SendGoodCommand();
     }
     else if (Command.Command == ConfigurationManager.AppSettings["TurnWaitGameCommand"])
     {
         battlegnd.Control.Dispatcher.Invoke(() =>
         {
             battlegnd.ShowNotMessage("Ходит ваш опонент, подождите");
             battlegnd.IsUserTurn = false;
         });
         SendGoodCommand();
     }
     else if (Command.Command == ConfigurationManager.AppSettings["StartTurnGameCommand"])
     {
         battlegnd.Control.Dispatcher.Invoke(() =>
         {
             battlegnd.ShowNotMessage("Ваш ход");
             battlegnd.IsUserTurn = true;
         });
         SendGoodCommand();
     }
     else if (Command.Command == ConfigurationManager.AppSettings["ConnectionLost"])
     {
         battlegnd.Control.Dispatcher.Invoke(() =>
         {
             MessageBox.Show("Потеряно соединение с другим пользователем, перенаправление в меню...", "Сообщение", MessageBoxButton.OK, MessageBoxImage.Exclamation);
             battlegnd.EndBattle();
         });
     }
     else if (Command.Command == ConfigurationManager.AppSettings["LeaveGameCommand"])
     {
         battlegnd.Control.Dispatcher.Invoke(() =>
         {
             MessageBox.Show("Ваш противник вышел из игры, перенаправление в меню...", "Сообщение", MessageBoxButton.OK, MessageBoxImage.Exclamation);
             battlegnd.EndBattle();
         });
     }
     else if (Command.Command == ConfigurationManager.AppSettings["PassedGameCommand"])
     {
         battlegnd.Control.Dispatcher.Invoke(() =>
         {
             battlegnd.Passed();
         });
         SendGoodCommand();
     }
     else if (Command.Command == ConfigurationManager.AppSettings["LostRoundCommand"])
     {
         battlegnd.Control.Dispatcher.Invoke(() =>
         {
             battlegnd.ShowNotMessage("Вы проиграли раунд");
             battlegnd.EndRound();
         });
         SendGoodCommand();
     }
     else if (Command.Command == ConfigurationManager.AppSettings["WinRoundCommand"])
     {
         battlegnd.Control.Dispatcher.Invoke(() =>
         {
             battlegnd.ShowNotMessage("Вы выиграли раунд");
             battlegnd.EndRound();
         });
         SendGoodCommand();
     }
     else if (Command.Command == ConfigurationManager.AppSettings["LostGameCommand"])
     {
         battlegnd.Control.Dispatcher.Invoke(() =>
         {
             MessageBox.Show("Вы проиграли игру, перенаправление в меню...", "Сообщение", MessageBoxButton.OK, MessageBoxImage.Exclamation);
             battlegnd.EndBattle();
         });
     }
     else if (Command.Command == ConfigurationManager.AppSettings["WinGameCommand"])
     {
         battlegnd.Control.Dispatcher.Invoke(() =>
         {
             MessageBox.Show("Вы выиграли игру, перенаправление в меню...", "Сообщение", MessageBoxButton.OK, MessageBoxImage.Exclamation);
             battlegnd.EndBattle();
         });
     }
 }
Example #32
0
 public bool ContainsConsiderationObject(ICommandable source)
 {
     return(this._considerationObjects.Contains(source));
 }
Example #33
0
	void selectAndDrag (bool userFingerUp, bool userFingerDown, bool userFingerPressed)
	{
		RaycastHit hit;
		Ray ray = Camera.main.ScreenPointToRay (pointerPosition);
		int layerMask =~(1 << 10);
		if (Physics.Raycast (ray, out hit, Mathf.Infinity, layerMask))
		{
			if (userFingerDown)
			{
				latestFingerDownPosition = pointerPosition;
				withinDeadZone = true;
								
				draggableComponent = DragGameObject.GetDraggable (hit.transform.gameObject);
				if (draggableComponent != null && SelectGameObject.GetObjectByIndex (0) == draggableComponent && draggableComponent.IsPlaceholder)
				{
					lockCameraMovement = true;
				}
				else
				{
					lockCameraMovement = false;
				}
			}

			// Once we leave the deadzone, we don't check this anymore until the next touch/mouse down.
			if(userFingerPressed && withinDeadZone)
			{
				float draggedDistance = Vector3.Distance(latestFingerDownPosition, pointerPosition);
				if(draggedDistance > deadZoneThreshold)
				{
					withinDeadZone = false;
				}
			}

			if (userFingerUp)
			{
				GameObject hitObject = hit.collider.transform.gameObject;
				// If we have not move a screen
				if (withinDeadZone)
				{
					if (hitObject.name == "Terrain")
					{
						if(commandableComponent != null)
						{
							// A commandable unit is selected, and we hit the terrain. Move that unit to this position.
							CommandGameObject.DispatchMoveCommand(commandableComponent, hit.point);
						}
						
						//Deselect all objects, whether we are commanding or not.
						SelectGameObject.DeselectAll ();
					}
					else if (hitObject.name == "OkButton" || hitObject.name == "CancelButton")
					{
						// hitObject is the button--> its parent is the button container --> and its parent is the building.
						GameObject parentGameObject = hitObject.transform.parent.transform.parent.gameObject;
						if(hitObject.name == "OkButton")
						{
							if(draggableComponent.CurrentPositionValid)
							{
								JSTrigger.StartBuildingConstruction (parentGameObject);
							}
							else
							{
								print ("Invalid construction site!! derp");
							}
						}
						else
						{
							Destroy(parentGameObject);
						}
					}
					else
					{
						SelectGameObject.Dispatch (hitObject);
						commandableComponent = CommandGameObject.GetCommandable(hitObject);
					}
				}

				if (draggableComponent != null && draggingOccured)
				{
					DragGameObject.DispatchDragStop (draggableComponent);
					draggingOccured = false;
				}
				draggableComponent = null;
				withinDeadZone = true;
			}
		}

		if (draggableComponent != null)
		{
			if (!withinDeadZone && draggableComponent.IsPlaceholder)
			{
				lockCameraMovement = DragGameObject.DispatchDrag (draggableComponent, pointerPosition);
				draggingOccured = lockCameraMovement;
			}
		}
		else
		{
			lockCameraMovement = false;
		}
	}
Example #34
0
	public static void DispatchMoveCommand(ICommandable commandableComponent, Vector3 destination)
	{
		commandableComponent.OnMoveCommand(destination);
	}
Example #35
0
 public void Fire(ICommandable command)
 {
     this.State = ActiveItemState.Busy;
     this.commandQueue.Enqueue(command);
 }
Example #36
0
        public override Result FluidLine(PointD accStartPos, PointD lineStartPos, PointD lineEndPos, PointD decEndPos, double vel, PointD[] points, double intervalSec, double acc)
        {
            if (Machine.Instance.Robot.IsSimulation)
            {
                return(Result.OK);
            }

            if (points == null)
            {
                return(Result.FAILED);
            }

            if (Machine.Instance.Valve1.RunMode == ValveRunMode.Wet || Machine.Instance.Valve1.RunMode == ValveRunMode.Dry)
            {
                accStartPos  = accStartPos.ToNeedle(this.valve1.Key);
                lineStartPos = lineStartPos.ToNeedle(this.valve1.Key);
                lineEndPos   = lineEndPos.ToNeedle(this.valve1.Key);
                decEndPos    = decEndPos.ToNeedle(this.valve1.Key);
                for (int i = 0; i < points.Length; i++)
                {
                    points[i] = points[i].ToNeedle(this.valve1.Key);
                }
            }

            double interval = 0;

            if (points.Length >= 2)
            {
                interval = points[0].DistanceTo(points[1]);
            }

            //计算加速段时间,用于启动时间控制打胶
            double accTime = this.CalcAccTime(accStartPos, lineStartPos, vel, acc * 1000);

            //连续插补
            List <ICrdable> crdList = new List <ICrdable>();
            //加速段
            CrdLnXY crdAcc = new CrdLnXY()
            {
                EndPosX = lineStartPos.X,
                EndPosY = lineStartPos.Y,
                Vel     = vel,
                Acc     = acc,
                VelEnd  = vel
            };

            crdList.Add(crdAcc);
            //匀速段
            for (int i = 1; i < points.Length; i++)
            {
                CrdLnXY crdLn = new CrdLnXY()
                {
                    EndPosX = points[i].X,
                    EndPosY = points[i].Y,
                    Vel     = vel,
                    Acc     = acc,
                    VelEnd  = vel
                };
                crdList.Add(crdLn);
            }
            //减速段
            CrdLnXY crdDec = new CrdLnXY()
            {
                EndPosX = decEndPos.X,
                EndPosY = decEndPos.Y,
                Vel     = vel,
                Acc     = acc,
                VelEnd  = 0
            };

            crdList.Add(crdDec);

            DateTime t1           = DateTime.Now;
            DateTime t2           = DateTime.Now;
            Result   rtn          = Result.OK;
            int      intervalTime = (int)(intervalSec * 1000000);

            //时间控制函数
            Action timeCtrlAction = () =>
            {
                ICommandable command = null;
                if (this.jtValve1.Prm.MoveMode == ValveMoveMode.单次插补)
                {//单次插补
                    CrdLnXY crd = new CrdLnXY()
                    {
                        EndPosX = decEndPos.X,
                        EndPosY = decEndPos.Y,
                        Vel     = vel,
                        Acc     = acc,
                        VelEnd  = vel
                    };
                    command = new CommandMoveTrc(
                        Machine.Instance.Robot.AxisX,
                        Machine.Instance.Robot.AxisY,
                        Machine.Instance.Robot.TrcPrm,
                        crd,
                        () =>
                    {
                        t1 = DateTime.Now;
                        ValveSprayServer.Instance.StartSprayEvent.Set();
                    })
                    {
                        EnableINP = Machine.Instance.Robot.DefaultPrm.EnableINP
                    };
                }
                else
                {//多次插补
                    command = new CommandMoveTrc(
                        Machine.Instance.Robot.AxisX,
                        Machine.Instance.Robot.AxisY,
                        Machine.Instance.Robot.TrcPrm,
                        crdList,
                        () =>
                    {
                        t1 = DateTime.Now;
                        ValveSprayServer.Instance.StartSprayEvent.Set();
                    })
                    {
                        EnableINP = Machine.Instance.Robot.DefaultPrm.EnableINP
                    };
                }

                //设置打胶线程启动时间
                ValveSprayServer.Instance.SleepSpan = TimeSpan.FromSeconds(accTime);
                if (Machine.Instance.Valve1.RunMode == ValveRunMode.Wet)
                {
                    ValveSprayServer.Instance.SprayAction = () =>
                    {
                        t2 = DateTime.Now;
                        this.SprayCycle((short)points.Count(), (short)(intervalTime - this.jtValve1.Prm.OnTime));
                    };
                }
                else
                {
                    ValveSprayServer.Instance.SprayAction = null;
                }

                Log.Dprint(string.Format("Fluid Line[time ctrl]-> accTime:{0}, intervalTime:{1}, onTime:{2}, offTime{3}.",
                                         accTime, intervalTime, this.jtValve1.Prm.OnTime, this.jtValve1.Prm.OffTime));
                Machine.Instance.Robot.Fire(command);
                rtn = Machine.Instance.Robot.WaitCommandReply(command);

                Debug.WriteLine(t1.ToString("HH::mm::ss::fff"));
                Debug.WriteLine(t2.ToString("HH::mm::ss::fff"));
            };

            //2d比较控制函数
            Action cmp2dAction = () =>
            {
                if (Machine.Instance.Valve1.RunMode == ValveRunMode.Wet)
                {
                    CmpStop();
                    SimulCmp2dStart((short)Cmp2dSrcType.编码器, (short)this.jtValve1.Prm.Cmp2dMaxErr, points);
                }

                if (this.jtValve1.Prm.MoveMode == ValveMoveMode.单次插补)
                {
                    rtn = Machine.Instance.Robot.MovePosXYAndReply(decEndPos, vel, acc);
                }
                else
                {
                    CommandMoveTrc command = new CommandMoveTrc(
                        Machine.Instance.Robot.AxisX,
                        Machine.Instance.Robot.AxisY,
                        Machine.Instance.Robot.TrcPrm,
                        crdList)
                    {
                        EnableINP = Machine.Instance.Robot.DefaultPrm.EnableINP
                    };
                    Log.Dprint(string.Format("Fluid Line[2d ctrl]-> maxErr:{0}, interval:{1}", this.jtValve1.Prm.Cmp2dMaxErr, interval));
                    Machine.Instance.Robot.Fire(command);
                    rtn = Machine.Instance.Robot.WaitCommandReply(command);
                }

                if (Machine.Instance.Valve1.RunMode == ValveRunMode.Wet)
                {
                    //Cmp2dStop();
                }
            };

            //一维比较控制函数
            Action cmp1dAction = () =>
            {
                if (Machine.Instance.Valve1.RunMode == ValveRunMode.Wet)
                {
                    SimulCmp2dStop();
                    CmpStart((short)Cmp2dSrcType.编码器, points);
                }

                if (this.jtValve1.Prm.MoveMode == ValveMoveMode.单次插补)
                {
                    rtn = Machine.Instance.Robot.MovePosXYAndReply(decEndPos, vel, acc);
                }
                else
                {
                    CommandMoveTrc command = new CommandMoveTrc(
                        Machine.Instance.Robot.AxisX,
                        Machine.Instance.Robot.AxisY,
                        Machine.Instance.Robot.TrcPrm,
                        crdList)
                    {
                        EnableINP = Machine.Instance.Robot.DefaultPrm.EnableINP
                    };
                    Log.Dprint(string.Format("Fluid Line[2d ctrl]-> maxErr:{0}, interval:{1}", this.jtValve1.Prm.Cmp2dMaxErr, interval));
                    Machine.Instance.Robot.Fire(command);
                    rtn = Machine.Instance.Robot.WaitCommandReply(command);
                }

                if (Machine.Instance.Valve1.RunMode == ValveRunMode.Wet)
                {
                    //CmpStop();
                }
            };

            switch (this.jtValve1.Prm.FluidMode)
            {
            case ValveFluidMode.一维比较优先:
                cmp1dAction();
                break;

            case ValveFluidMode.二维比较优先:
                if (interval * 1000 > this.jtValve1.Prm.Cmp2dMaxErr || points.Length < 2)
                {
                    cmp2dAction();
                }
                else
                {
                    //timeCtrlAction();
                    cmp1dAction();
                }
                break;

            case ValveFluidMode.时间控制优先:
                if (intervalTime - this.jtValve1.Prm.OnTime < short.MaxValue)
                {    //判断脉宽是否short类型溢出,
                    timeCtrlAction();
                }
                else
                {    //溢出:位置比较模式
                    //cmp2dAction();
                    cmp1dAction();
                }
                break;
            }


            return(rtn);
        }