Пример #1
0
        private SimulateVelocityData SetVChange_Dec(SimulateVelocityData nowData, AxisData axis, SimulateData data, DateTime time)
        {
            double nowDec             = GetNowAccOrDec(data, (time - nowData.Time).TotalSeconds);
            double deltaVelocity      = Math.Pow(nowDec, 2) / (2 * axis.Jerk);
            double nowVelocity        = GetNowVelocity(data, (time - nowData.Time).TotalSeconds);
            double isokineticVelocity = nowVelocity - deltaVelocity;
            double startVelocity      = nowVelocity + deltaVelocity;
            double startTime          = -nowDec / axis.Jerk;;

            SimulateVelocityData returnData = new SimulateVelocityData();
            SimulateData         temp;

            returnData.Command = nowData.Command;
            returnData.Time    = time;

            if (axis.Velocity > isokineticVelocity)
            {   // 升速度.
                CheckAxisDataOKWithVelocityChange(ref axis, startVelocity, isokineticVelocity);
                CheckAxisDataOKWithVelocityChange(ref axis, isokineticVelocity, axis.Velocity);

                temp = new SimulateData();
                temp.SetSimulateData_DecJerkDown(nowVelocity, axis.Deceleration, axis.Jerk, 0);
                returnData.SimulateDataList.Add(temp);

                temp = new SimulateData();
                temp.SetSimulateData_AccJerkUp(returnData.SimulateDataList[returnData.SimulateDataList.Count - 1].EndVelocity,
                                               axis.Acceleration, axis.Jerk,
                                               returnData.SimulateDataList[returnData.SimulateDataList.Count - 1].EndTime);
                returnData.SimulateDataList.Add(temp);

                temp = new SimulateData();
                temp.SetSimulateData_Accing(returnData.SimulateDataList[returnData.SimulateDataList.Count - 1], axis);
                returnData.SimulateDataList.Add(temp);

                temp = new SimulateData();
                temp.SetSimulateData_AccJerkDown(returnData.SimulateDataList[returnData.SimulateDataList.Count - 1].EndVelocity,
                                                 axis.Acceleration, axis.Jerk,
                                                 returnData.SimulateDataList[returnData.SimulateDataList.Count - 1].EndTime);
                returnData.SimulateDataList.Add(temp);
            }
            else if (axis.Velocity < isokineticVelocity)
            {   // 減速度.
                CheckAxisDataOKWithVelocityChange(ref axis, startVelocity, axis.Velocity);

                temp = new SimulateData();
                temp.SetSimulateData_DecJerkUp(startVelocity, axis.Deceleration, axis.Jerk, startTime);
                returnData.SimulateDataList.Add(temp);

                temp = new SimulateData();
                temp.SetSimulateData_Decing(returnData.SimulateDataList[returnData.SimulateDataList.Count - 1], axis);
                returnData.SimulateDataList.Add(temp);

                temp = new SimulateData();
                temp.SetSimulateData_DecJerkDown(returnData.SimulateDataList[returnData.SimulateDataList.Count - 1].EndVelocity,
                                                 axis.Deceleration, axis.Jerk,
                                                 returnData.SimulateDataList[returnData.SimulateDataList.Count - 1].EndTime);
                returnData.SimulateDataList.Add(temp);
            }
            else
            {   // 等速度.
                CheckAxisDataOKWithVelocityChange(ref axis, startVelocity, axis.Velocity);

                temp = new SimulateData();
                temp.SetSimulateData_DecJerkDown(nowVelocity, axis.Deceleration, axis.Jerk, 0);
                returnData.SimulateDataList.Add(temp);
            }

            temp = new SimulateData();
            temp.SetSimulateData_Isokinetic(returnData.SimulateDataList[returnData.SimulateDataList.Count - 1].EndVelocity,
                                            returnData.SimulateDataList[returnData.SimulateDataList.Count - 1].EndTime);
            returnData.SimulateDataList.Add(temp);

            returnData.Axis = axis;
            return(returnData);
        }
Пример #2
0
        private SimulateVelocityData SetVChange_Isokinetic(SimulateVelocityData nowData, AxisData axis, SimulateData data, DateTime time)
        {
            double nowVelocity = GetNowVelocity(data, (time - nowData.Time).TotalSeconds);
            double startTime   = 0;

            SimulateVelocityData returnData = new SimulateVelocityData();
            SimulateData         temp;

            returnData.Command = nowData.Command;
            returnData.Time    = time;

            if (axis.Velocity > nowVelocity)
            {   // 升速度.
                CheckAxisDataOKWithVelocityChange(ref axis, nowVelocity, axis.Velocity);

                temp = new SimulateData();
                temp.SetSimulateData_AccJerkUp(nowVelocity, axis.Acceleration, axis.Jerk, startTime);
                returnData.SimulateDataList.Add(temp);

                temp = new SimulateData();
                temp.SetSimulateData_Accing(returnData.SimulateDataList[returnData.SimulateDataList.Count - 1], axis);
                returnData.SimulateDataList.Add(temp);

                temp = new SimulateData();
                temp.SetSimulateData_AccJerkDown(returnData.SimulateDataList[returnData.SimulateDataList.Count - 1].EndVelocity,
                                                 axis.Acceleration, axis.Jerk,
                                                 returnData.SimulateDataList[returnData.SimulateDataList.Count - 1].EndTime);
                returnData.SimulateDataList.Add(temp);
            }
            else if (axis.Velocity < nowVelocity)
            {   // 減速度.
                CheckAxisDataOKWithVelocityChange(ref axis, nowVelocity, axis.Velocity);

                temp = new SimulateData();
                temp.SetSimulateData_DecJerkUp(nowVelocity, axis.Deceleration, axis.Jerk, startTime);
                returnData.SimulateDataList.Add(temp);

                temp = new SimulateData();
                temp.SetSimulateData_Decing(returnData.SimulateDataList[returnData.SimulateDataList.Count - 1], axis);
                returnData.SimulateDataList.Add(temp);

                temp = new SimulateData();
                temp.SetSimulateData_DecJerkDown(returnData.SimulateDataList[returnData.SimulateDataList.Count - 1].EndVelocity,
                                                 axis.Deceleration, axis.Jerk,
                                                 returnData.SimulateDataList[returnData.SimulateDataList.Count - 1].EndTime);
                returnData.SimulateDataList.Add(temp);
            }
            else
            {   // 等速度.
                temp = new SimulateData();
                temp.SetSimulateData_Isokinetic(axis.Velocity, startTime);
                returnData.SimulateDataList.Add(temp);
            }

            temp = new SimulateData();
            temp.SetSimulateData_Isokinetic(returnData.SimulateDataList[returnData.SimulateDataList.Count - 1].EndVelocity,
                                            returnData.SimulateDataList[returnData.SimulateDataList.Count - 1].EndTime);
            returnData.SimulateDataList.Add(temp);

            returnData.Axis = axis;
            return(returnData);
        }