public void theout(object source, ElapsedEventArgs e)
    {
        string cmdId = GetCmdId();

        //如果没有未分配的任务,只计算路权
        if (cmdId == "0")
        {
            SetRoadRight();
            //UpdateCmd();
            return;
        }

        Route r = new Route();
        r.CalcRoute(cmdId);
        SetRoadRight();
        //UpdateCmd();

    }
        /// <summary>
        /// 定时器回调函数
        /// </summary>
        /// <param name="sender"></param>

        void timer_Elapsed(object sender)
        {
            //if (tcp != null && tcp.Connected)
            //{
            //    DataSet ds = GetTaskCmd();//获取发送命令

            //    string cmdId = "";
            //    int cnt = 0;
            //    byte[] buffer = null;
            //    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            //    {
            //        if (CanSendCmd((byte[])ds.Tables[0].Rows[i]["status"]))//判断小车状态是否能接收命令
            //        {
            //            buffer = (byte[])ds.Tables[0].Rows[i]["cmd"];
            //            workStream.Write(buffer, 0, buffer.Length);

            //            cmdId = Fn.ToString(ds.Tables[0].Rows[i]["cmd_id"]);
            //            cnt = Fn.ToInt(ds.Tables[0].Rows[i]["send_cnt"]) + 1;

            //            UpdateCmdSendCnt(cmdId, cnt); //更新命令的发送次数
            //        }
            //    }


            //    //发送路权令牌
            //    DataSet dsToken = GetRoadRightCMD();
            //    byte[] bufferRight = null;
            //    for (int j = 0; j < dsToken.Tables[0].Rows.Count; j++)
            //    {
            //        bufferRight = Asrv.GetSendData(Asrv.GetTokenCmd(Fn.ToInt(dsToken.Tables[0].Rows[j]["step"])), (byte[])(dsToken.Tables[0].Rows[j]["address"]));
            //        cmdId = Fn.ToString(dsToken.Tables[0].Rows[j]["cmd_id"]);

            //        if (CheckTokenSendCnt(cmdId, bufferRight)) //如果相同的令牌发送次数没有超过最大发送次数则发送路权令牌
            //        {

            //            workStream.Write(bufferRight, 0, bufferRight.Length);


            //            InsertCmdBreakdown(cmdId, bufferRight);
            //        }
            //    }

            //}
            //else
            //{
            //    Connect();//连接HOST并等待接收数据
            //}

            
            string cmdId = GetCmdId();

            //如果没有未分配的任务,只计算路权
            if (cmdId == "0")
            {
                SetRoadRight();
                UpdateCmd();
                return;
            }

            Route r = new Route();
            r.CalcRoute(cmdId);
            SetRoadRight();
            UpdateCmd();
        }
    public string SaveAsrvTask(string whId,string asrvId,string floorNum,string fromXNum,string fromYNum,string xNum,string yNum,string taskTypeId)
    {
        string proc = "WCS.SaveAsrvTask";
        Database db = DatabaseFactory.CreateDatabase(ScrConst.ConnectionName);
        DbCommand cmd = db.GetStoredProcCommand(proc);
        db.AddInParameter(cmd, "asrvId", DbType.Int32, asrvId);
        db.AddInParameter(cmd, "whId", DbType.Int32, whId);
        db.AddInParameter(cmd, "fromXNum", DbType.Int32, fromXNum);
        db.AddInParameter(cmd, "fromYNum", DbType.Int32, fromYNum);
        db.AddInParameter(cmd, "xNum", DbType.Int32, xNum);
        db.AddInParameter(cmd, "yNum", DbType.Int32, yNum);
        db.AddInParameter(cmd, "floorNum", DbType.Int32, floorNum);
        db.AddInParameter(cmd, "taskType", DbType.Int32, taskTypeId);
        db.AddOutParameter(cmd, "pOut", DbType.Int32, 10000);
        db.ExecuteNonQuery(cmd);
        string cmdId = Fn.ToString(db.GetParameterValue(cmd, "pOut"));//任务ID,取名字叫pout       

        Route r = new Route();//一个类,见route.cs文件定义
        bool b=r.CalcRoute(cmdId);//计算任务路径

        if (b)//如果计算得到可用的路径,返回包含路径的任务ID,返回结果是多个函数的result传递值
            return cmdId;
        else
        {
            return "error";
        }

    }