/// <summary>
        /// Frame update
        /// </summary>
        /// <param name="update"></param>
        public override void Update(FrameUpdate update)
        {
            if (_raycastProperties == null)
            {
                base.Update(update);
                return;
            }

            _appTime = (float)update.ApplicationTime;

            // assume pose of parent
            if (Parent != null)
                State.Pose = Parent.State.Pose;

            _elapsedSinceLastScan += (float)update.ElapsedTime;
            // only retrieve raycast results every SCAN_INTERVAL.
            // For entities that are compute intenisve, you should consider giving them
            // their own task queue so they dont flood a shared queue
            if (_elapsedSinceLastScan > SCAN_INTERVAL)
            {
                _elapsedSinceLastScan = 0;
                // the LRF looks towards the negative Z axis (towards the user), not the positive Z axis
                // which is the default orientation. So we have to rotate its orientation by 180 degrees

                _raycastProperties.OriginPose.Orientation = TypeConversion.FromXNA(
                    TypeConversion.ToXNA(State.Pose.Orientation) * xna.Quaternion.CreateFromAxisAngle(new xna.Vector3(0, 1, 0), (float)Math.PI));

                // to calculate the position of the origin of the raycast, we must first rotate the LocalPose position
                // of the raycast (an offset from the origin of the parent entity) by the orientation of the parent entity.
                // The origin of the raycast is then this rotated offset added to the parent position.
                xna.Matrix parentOrientation = xna.Matrix.CreateFromQuaternion(TypeConversion.ToXNA(State.Pose.Orientation));
                xna.Vector3 localOffset = xna.Vector3.Transform(TypeConversion.ToXNA(_sonarBox.State.LocalPose.Position), parentOrientation);

                _raycastProperties.OriginPose.Position = State.Pose.Position + TypeConversion.FromXNA(localOffset);
                _raycastResultsPort = PhysicsEngine.Raycast2D(_raycastProperties);
                _raycastResultsPort.Test(out _lastResults);
                if (_serviceNotification != null && _lastResults != null)
                {
                    _serviceNotification.Post(_lastResults);
                }
            }

            base.Update(update);
        }
Esempio n. 2
0
 /// <summary>
 /// 从数据库中获取数据并绑定
 /// </summary>
 protected void Refresh()
 {
     DataView dv = new FrameUpdate().SelectUpdate();
     for (int i = 0; i < dv.Count; i++)
     {
         if (dv[i]["ISEXECUTED"].ToString() == "N")
         {
             dv[i]["ISEXECUTED"] = "<span style='color:Red'>否</span>";
         }
         else
             dv[i]["ISEXECUTED"] = "是";
         dv[i]["FILENAMELIST"] = dv[i]["FILENAMELIST"].ToString().Replace(";","<br />");
     }
     grdList.DataSource = dv;
     grdList.DataBind();
     CallJsFun("ChangeColor();");
 }
Esempio n. 3
0
        public override void Update(FrameUpdate update)
        {
            base.Update(update);

            if (_moveToActive)
            {
                bool done = true;

                // Check each joint and update it if necessary.
                for (int i = 0; i < _joints.Count; i++)
                {
                    if (_joints[i].Update(_prevTime, _epsilon))
                        done = false;
                }

                /*// gripper is special case
                if (_joints[5].NeedToMove(_epsilon / 100f))
                {
                    done = false;
                    _joints[5].UpdateCurrent(_prevTime);
                    float jointValue = _joints[5].Current / 2;
                    if (_joints[5].Joint != null)
                        _joints[5].Joint.SetLinearDrivePosition(new Vector3(-jointValue, 0, 0));
                    if (_joints[5].Joint2 != null)
                        _joints[5].Joint2.SetLinearDrivePosition(new Vector3(jointValue, 0, 0));
                }
*/
                if (done)
                {
                    // move completed; send the completion message
                    _moveToActive = false;
                    _moveToResponsePort.Post(new SuccessResult());
                }
            }

            _prevTime = update.ElapsedTime;
        }
Esempio n. 4
0
        /// <summary>
        /// 更新命令
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void grdList_Execute(object source, DataGridCommandEventArgs e)
        {
            try
            {
                string UpdateGuid = grdList.DataKeys[e.Item.ItemIndex].ToString();
                DataView dv = new FrameUpdate().SelectUpdate(UpdateGuid);
                if (dv.Count > 0)
                {
                    string PathSet = Server.MapPath(dv[0]["FILEPATH"].ToString()) + "PathSet.txt";
                    //读取配置文件 PathSet.txt
                    string PathConfig = "";
                    if (File.Exists(PathSet))
                    {
                        StreamReader reader = new StreamReader(PathSet, System.Text.Encoding.Default);
                        PathConfig = reader.ReadToEnd().ToLower();
                        reader.Dispose();
                    }
                    else
                    {
                        ShowJsMessage("该更新缺乏路径配置文件,请手工更新!");
                        return;
                    }
                    //具体的信息格式为:aa.dll=/bin/; bb.aspx=/ccc/;

                    string[] FileList = dv[0]["FILENAMELIST"].ToString().Split(';');
                    for (int i = 0; i < FileList.Length; i++)
                    {
                        string FileName = FileList[i].Trim().ToLower();
                        if (FileName != "" && PathConfig.IndexOf(FileName) != -1)
                        {
                            string FromPath = Server.MapPath(dv[0]["FILEPATH"].ToString()) + FileList[i].Trim();
                            int begin = PathConfig.IndexOf("/", PathConfig.IndexOf(FileName) + 1);
                            int end = PathConfig.IndexOf("/", begin + 1);
                            string ToPath = PathConfig.Substring(begin, end - begin + 1);
                            ToPath = Server.MapPath(ToPath);
                            if(!Directory.Exists(ToPath)) //如果目录不存在,则创建目录
                            {
                              Directory.CreateDirectory(ToPath);
                            }
                            ToPath = ToPath + FileList[i].Trim(); //具体文件名
                            File.Copy(FromPath, ToPath, true);
                        }
                    }
                    new FrameUpdate().UpdateStatus(UpdateGuid);
                    ShowJsMessage("更新完成,请重新刷新!");
                }
            }
            catch (Exception a)
            {
                ShowJsMessage(a.Message);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Updates pose for our entity. We override default implementation
        /// since we control our own rendering when no file mesh is supplied, which means
        /// we dont need world transform updates
        /// </summary>
        /// <param name="update"></param>
        public override void Update(FrameUpdate update)
        {
            float left = _leftWheel.Wheel.AxleSpeed + _leftTargetVelocity;
            float right = _rightWheel.Wheel.AxleSpeed + _rightTargetVelocity;

            if (Math.Abs(left) > 0.1)
            {
                if (left > 0)
                {
                    _leftWheel.Wheel.AxleSpeed -= SPEED_DELTA;
                }
                else
                {
                    _leftWheel.Wheel.AxleSpeed += SPEED_DELTA;
                }
            }

            if (Math.Abs(right) > 0.1)
            {
                if (right > 0)
                {
                    _rightWheel.Wheel.AxleSpeed -= SPEED_DELTA;
                }
                else
                {
                    _rightWheel.Wheel.AxleSpeed += SPEED_DELTA;
                }
            }

            // update state for us and all the shapes that make up the rigid body
            PhysicsEntity.UpdateState(true);

            /////////////////////////////////////////////////////////////
            // TT May-2007
            // Handle RotateDegrees
            if (IsRotating)
            {
                double current;
                double diff;
                // Get the current heading
                current = this.Rotation.Y;
                // This is tricky because the angle wraps around
                // so it is always in the range 0-360.
                // This is probably unnecessary because the Simulator
                // does it for us, but just to be sure ...
                while (current > 360)
                    current -= 360;
                while (current < 0)
                    current += 360;

                // Figure out how far we have turned
                // NOTE: You cannot simply compare the current heading
                // with a target angle because the simulation moves in
                // steps and might skip over the target angle.
                diff = current - TurnStartDegrees;
                if (TurnAngle > 0)
                {
                    if (diff < 0)
                        diff += 360;
                    if (diff >= TurnAngle)
                        IsRotating = false;
                }
                else
                {
                    if (diff > 0)
                        diff -= 360;
                    if (diff <= TurnAngle)
                        IsRotating = false;
                }
                if (!IsRotating)
                {
                    SetMotorTorque(0, 0);
                    SetVelocity(0);     // This is overkill, but AllStop does it!
                    // This is cheating! Eliminates inertia
                    _rightWheel.Wheel.AxleSpeed = 0;
                    _leftWheel.Wheel.AxleSpeed = 0;
                    IsRotating = false;
                }
            }

            // TT May-2007
            // Handle DriveDistance
            if (IsTranslating)
            {
                double dist;
                // Calculate the SQUARED distance so far
                // This avoids taking a square root every time
                dist = (this.Position.X - TranslateStartX) * (this.Position.X - TranslateStartX) +
                       (this.Position.Z - TranslateStartZ) * (this.Position.Z - TranslateStartZ);
                // Check if we have reached the end of the travel
                if (dist >= TranslateDistanceSquared)
                {
                    SetMotorTorque(0, 0);
                    SetVelocity(0);     // This is overkill, but AllStop does it!
                    // This is cheating! Eliminates inertia
                    _rightWheel.Wheel.AxleSpeed = 0;
                    _leftWheel.Wheel.AxleSpeed = 0;
                    IsTranslating = false;
                }
            }

            /////////////////////////////////////////////////////////////

            // update entities in fields
            _leftWheel.Update(update);
            _rightWheel.Update(update);
            
            // sim engine will update children

            if (State.Assets.Mesh != null)
            {
                base.Update(update);
            }
        }