Beispiel #1
0
        /// <summary>
        /// 数据来源于最大值表!
        /// 取最大值号〔已经自加1,无须再加1〕
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="codex">编码规则</param>
        /// <param name="digit">位数</param>
        /// <returns>生成后的编码</returns>
        public string GetMaxNo(string tableName, string codex, int digit)
        {
            DataAccess db    = new DataAccess(DataAccess.DBConn);
            string     maxNo = "";
            ComCommand acmd  = new ComCommand("PGetMax", db.DbConnection);

            acmd.CommandType = System.Data.CommandType.StoredProcedure;
            acmd.Parameters.AddWithValue("vi_TabName", tableName);
            acmd.Parameters.AddWithValue("vi_Codex", codex);
            acmd.Parameters.AddWithValue("vi_Digit", digit);
            acmd.Parameters.AddWithValue("vo_ReturnValue", maxNo);
            acmd.Parameters["vi_TabName"].Direction     = System.Data.ParameterDirection.Input;
            acmd.Parameters["vi_Codex"].Direction       = System.Data.ParameterDirection.Input;
            acmd.Parameters["vi_Digit"].Direction       = System.Data.ParameterDirection.Input;
            acmd.Parameters["vo_ReturnValue"].Direction = System.Data.ParameterDirection.InputOutput;
            acmd.Parameters["vo_ReturnValue"].Size      = 50;
            try
            {
                db.Open();
                acmd.ExecuteNonQuery();
                maxNo = acmd.Parameters["vo_ReturnValue"].Value.ToString();
                acmd.Dispose();
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                db.Close();
            }
            return(maxNo.Trim());
        }
Beispiel #2
0
    void NoteUserCommunication(string key, DataStore.IValue value)
    {
        var comVal = value as CommunicationValue;

        if (comVal == null)
        {
            return;
        }

        // if we're standing by, then ignore anything that's not a direct address.
        if (DataStore.GetBoolValue("me:standingBy"))
        {
            if (!comVal.val.directAddress)
            {
                return;
            }
            DataStore.SetValue("me:standingBy", new DataStore.BoolValue(false), this, "noted direct address");
        }

        ComCommand cmd = comVal.val as ComCommand;

        if (cmd != null)
        {
            HandleCommand(cmd);
        }
    }
Beispiel #3
0
        public bool CheckCaseState(string caseId, string nameId, string typeId)
        {
            DataAccess db   = new DataAccess(DataAccess.DBConn);
            ComCommand acmd = new ComCommand("CheckCaseState", db.DbConnection);

            acmd.CommandType = System.Data.CommandType.StoredProcedure;
            acmd.Parameters.Add("caseId", caseId);
            acmd.Parameters.Add("nameId", nameId);
            acmd.Parameters.Add("typeId", typeId);
            try
            {
                db.Open();
                int count = acmd.ExecuteNonQuery();
                acmd.Dispose();
                if (count > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                db.Close();
            }
            return(false);
        }
 public LoginViewModel()
 {
     LoginIn = new ComCommand(async p => {
         string resultStr      = this._client.GetStringAsync("http://47.94.162.230:80/api/Data/1?tbname=UserInfo").Result;
         UserInfoResult result = Newtonsoft.Json.JsonConvert.DeserializeObject <UserInfoResult>(resultStr);
         if (this.UserId.Equals(result.UserName) && this.Password.Equals(result.UserPassword))
         {
             ;
         }
     });
 }
        /// <summary>
        /// 접속 되면 최초 통신 하겠다는 메세지 전송 함수
        /// </summary>
        private void SendStartCommand()
        {
            string targetServerIP = iep.Address.ToString();

            string[] ipAddress = targetServerIP.Split('.');

            string serverIP = int.Parse(ipAddress[0]).ToString("D3")
                              + "." + int.Parse(ipAddress[1]).ToString("D3")
                              + "." + int.Parse(ipAddress[2]).ToString("D3")
                              + "." + int.Parse(ipAddress[3]).ToString("D3");

            ComCommand StartCommand = new ComCommand();

            StartCommand.IpAddress  = Encoding.ASCII.GetBytes(serverIP);
            StartCommand.PortNumber = Encoding.ASCII.GetBytes(serverPort.ToString());
            StartCommand.Status     = (byte)'1';

            Send(StartCommand.GetByte());

            StartCommand.Status = (byte)'2';
            Send(StartCommand.GetByte());
        }
Beispiel #6
0
 public SendCommand(ComCommand comCommand) => ComCommand = comCommand;
Beispiel #7
0
    void HandleCommand(ComCommand cmd)
    {
        ActionSpec act = cmd.action;

        if (act == null)
        {
            return;
        }
        Transform obj;
        string    comment = "handling " + act;

        switch (act.action)
        {
        case Action.Close:
            if (IsAgentsEyes(act.directObject))
            {
                SetValue("me:intent:eyesClosed", true, comment);
            }
            else
            {
                SayICant(comment);
            }
            break;

        case Action.Open:
            if (IsAgentsEyes(act.directObject))
            {
                SetValue("me:intent:eyesClosed", false, comment);
            }
            else
            {
                SayICant(comment);
            }
            break;

        case Action.Point:
            if (act.location != null && act.location.obj != null)
            {
                // Point at the indicated object.
                obj = FindObjectFromSpec(act.location.obj);
                if (obj == null)
                {
                    SetValue("me:speech:intent", "I can't find that.", comment);
                }
                else
                {
                    SetValue("me:speech:intent", "OK.", comment);
                    SetValue("me:intent:action", "point", comment);
                    SetValue("me:intent:pointAt", obj.name, comment);
                    SetValue("me:intent:target", obj.position, comment);
                }
            }
            else
            {
                // If no object, we assume the direction to point is always where the user is pointing.
                SetValue("me:speech:intent", "OK.", comment);
                SetValue("me:intent:pointAt", "userPoint", comment);
            }
            break;

        case Action.Look:
            Debug.Log("<color=green>Look object: " + act.directObject + "</color>");
            if (act.directObject == null)
            {
                // For now, if not otherwise specified, we assume the direction
                // to point is whereever the user is pointing.
                SetValue("me:speech:intent", "OK.", comment);
                SetValue("me:intent:lookAt", "userPoint", comment);
            }
            else if (act.directObject.referredToAs == "me")
            {
                SetValue("me:intent:lookAt", "user", comment);
            }
            else
            {
                obj = FindObjectFromSpec(act.directObject);
                if (obj == null)
                {
                    SetValue("me:speech:intent", "I don't understand what block you mean.", comment);
                }
                else
                {
                    SetValue("me:intent:lookAt", obj.name, comment);
                    SetValue("me:speech:intent", "OK.", comment);
                }
            }
            break;

        case Action.Stop:
            SetValue("me:speech:intent", "OK.", comment);
            SetValue("me:intent:lookAt", "", comment);
            SetValue("me:intent:pointAt", "", comment);
            SetValue("me:intent:action", "", comment);
            break;

        case Action.PickUp:
        case Action.Raise:
            // See if we can determine what object to pick up, based on spec.
            if (act.directObject == null)
            {
                return;                                         // (user is probably not done speaking)
            }
            obj = FindObjectFromSpec(act.directObject);
            if (obj == null)
            {
                SetValue("me:speech:intent", "I don't know what block you mean.", comment);
            }
            else
            {
                SetValue("me:speech:intent", "OK.", comment);
                SetValue("me:intent:action", "pickUp", comment);
                SetValue("me:intent:targetName", obj.name, comment);
                SetValue("me:intent:target", obj.position, comment);
            }
            break;

        case Action.SetDown:
        case Action.Put:
            // For now we'll assume we're being told to set down whatever we're holding.
            // But let's verify anyway.
            obj = FindObjectFromSpec(act.directObject);
            if (obj != null && obj.name != DataStore.GetStringValue("me:holding"))
            {
                SetValue("me:speech:intent", "I'm not holding that.", comment);
            }
            else
            {
                bool allGood = true;
                if (act.location == null)
                {
                    // No location specified.
                    SetValue("me:intent:targetName", "", comment);
                    SetValue("me:intent:target", "", comment);
                }
                else
                {
                    // Location specified.
                    if (act.location.relation == LocationSpec.Relation.Indicated)
                    {
                        // User is saying "here" or "there" and should be pointing.
                        if (!DataStore.GetBoolValue("user:isPointing"))
                        {
                            SetValue("me:speech:intent", "I don't know where you mean.", comment);
                            allGood = false;
                        }
                        else
                        {
                            SetValue("me:intent:targetName", "", comment);
                            SetValue("me:intent:target", DataStore.GetVector3Value("user:pointPos"), comment);
                        }
                    }
                    else
                    {
                        // User specified an object to set it on.
                        Transform relObj = FindObjectFromSpec(act.location.obj);
                        if (relObj == null && act.location.obj != null)
                        {
                            SetValue("me:speech:intent", "I don't know where you mean.", comment);
                            allGood = false;
                        }
                        if (relObj != null)
                        {
                            SetValue("me:intent:target", relObj.position, comment);
                            SetValue("me:intent:targetName", relObj.name, comment);
                        }
                    }
                }
                if (allGood)
                {
                    SetValue("me:speech:intent", "OK.", comment);
                    SetValue("me:intent:action", "setDown", comment);
                }
            }
            break;

        case Action.StandBy:
            SetValue("me:standingBy", true, comment);
            break;

        default:
            // Let's not say "I can't" to every unknown command.
            // At least not yet ... it gets pretty annoying.
            //SayICant(comment);
            break;
        }
    }
Beispiel #8
0
        public static Communication GrokInput(string text, ParseState st)
        {
            Communication comm = null;
            ActionSpec    act  = null;

            foreach (int child in st.ChildrenOf(-1))
            {
                if (st.partOfSpeech[child] == PartOfSpeech.VB && act == null)
                {
                    act = Grok.GrokAction(st, child);
                }
                if (st.partOfSpeech[child] == PartOfSpeech.IN)
                {
                    // Here's where we get fancy: based on the verb, and
                    // possibly the current state of the world, figure out
                    // this prepositional phrase modifies the last object
                    // already parsed, or instead modifies the verb.
                    // For now, we'll just assume it modifies the verb.
                    if (act != null)
                    {
                        act.location = GrokLocation(st, child);
                    }
                }
                if (st.partOfSpeech[child] == PartOfSpeech.UH)
                {
                    switch (st.words[child].ToLower())
                    {
                    case "hello":
                    case "hi":
                        comm = new ComPhatic(text, st, ComPhatic.Type.Greeting);
                        break;

                    case "bye":
                    case "goodbye":
                    case "good-bye":
                        comm = new ComPhatic(text, st, ComPhatic.Type.Goodbye);
                        break;

                    default:
                        comm = new ComEmote(text, st);
                        break;
                    }
                }
                else if (st.partOfSpeech[child] == PartOfSpeech.VB)
                {
                    switch (st.words[child].ToLower())
                    {
                    case "thank":
                    case "thank_you":
                        comm = new ComPhatic(text, st, ComPhatic.Type.ThankYou);
                        break;
                    }
                }
            }

            if (act != null && act.action != null)
            {
                // For now, we'll assume commands...
                comm = new ComCommand(text, st, act);
            }
            else if (comm == null)
            {
                // Not sure what to do with this.  Wrap it in the base class.
                comm = new Communication(text, st);
            }

            // Check for a direct address.
            // ToDo: find and use user self-knowledge, rather than hard-coded names.
            var firstWord = st.words[0].ToLower();

            if (firstWord == "diana" || firstWord == "sam")
            {
                comm.directAddress = true;
            }

            return(comm);
        }