Esempio n. 1
0
    public virtual bool LoadXML(System.Xml.XmlElement ele)
    {
        foreach (System.Xml.XmlElement ch in ele)
        {
            ParamBase.Type ty = ParamBase.FromSerializationType(ch.Name);
            if (ty == ParamBase.Type.Invalid)
            {
                continue;
            }

            System.Xml.XmlAttribute attrName = ch.Attributes["name"];
            if (attrName == null)
            {
                continue;
            }

            string    paramName = attrName.Value;
            ParamBase pb        = this.GetParam(paramName, ty);
            if (pb == null)
            {
                continue;
            }

            pb.SetValueFromString(ch.InnerText);

            System.Xml.XmlAttribute attrViz = ch.Attributes["visible"];
            if (attrViz != null)
            {
                pb.visible = ParamBool.ConvertFromString(attrViz.Value);
            }
        }
        return(true);
    }
Esempio n. 2
0
 protected ParamBase(ParamBase param)
 {
     searchGrid       = param.searchGrid;
     DiagonalMovement = param.DiagonalMovement;
     startNode        = param.startNode;
     endNode          = param.endNode;
 }
Esempio n. 3
0
    public virtual bool LoadXML(System.Xml.XmlElement ele, Dictionary <string, LLDNBase> directory)
    {
        foreach (System.Xml.XmlElement ch in ele)
        {
            ParamBase.Type ty = ParamBase.FromSerializationType(ch.Name);
            if (ty == ParamBase.Type.Invalid)
            {
                continue;
            }

            System.Xml.XmlAttribute attrName = ch.Attributes["name"];
            if (attrName == null)
            {
                continue;
            }

            string    paramName = attrName.Value;
            ParamBase pb        = this.GetParam(paramName, ty);
            if (pb == null)
            {
                continue;
            }

            pb.SetValueFromString(ch.InnerText, directory);
        }

        return(true);
    }
Esempio n. 4
0
 public ParamBase(ParamBase param)
 {
     m_searchGrid     = param.m_searchGrid;
     DiagonalMovement = param.DiagonalMovement;
     m_startNode      = param.m_startNode;
     m_endNode        = param.m_endNode;
 }
Esempio n. 5
0
        /** Override this method to revise the provided parameter database to reflect the "parameters" specified in the
         *  given meta-individual.  'Run' is the current run number for this individual's evaluation.  */
        public void ModifyParameters(IEvolutionState state, IParameterDatabase database, int run,
                                     Individual metaIndividual)
        {
            if (!(metaIndividual is DoubleVectorIndividual))
            {
                state.Output.Fatal("Meta-individual is not a DoubleVectorIndividual.");
            }
            var individual = (DoubleVectorIndividual)metaIndividual;
            var species    = (FloatVectorSpecies)individual.Species;

            double[] genome = individual.genome;

            IParameter pb = ParamBase.Push(P_PARAM);

            for (int i = 0; i < genome.Length; i++)
            {
                IParameter p     = pb.Push("" + i);
                String     param = state.Parameters.GetString(p, null);
                if (param == null)
                {
                    state.Output.Fatal("Meta parameter number " + i + " missing.", p);
                }
                // load it
                database.SetParameter(new Parameter(param), "" + Map(state, genome, species, i));
            }
        }
Esempio n. 6
0
 protected ParamBase(ParamBase param)
 {
     MsearchGrid      = param.MsearchGrid;
     DiagonalMovement = param.DiagonalMovement;
     MstartNode       = param.MstartNode;
     MendNode         = param.MendNode;
 }
Esempio n. 7
0
 public static bool HasUnit(this ParamBase p)
 {
     if (p == null)
     {
         throw new ArgumentNullException("p");
     }
     return(string.IsNullOrWhiteSpace(p.CvUnitAccession) == false);
 }
Esempio n. 8
0
 public static bool HasValue(this ParamBase p)
 {
     if (p == null)
     {
         throw new ArgumentNullException("p");
     }
     return(p.Value != null);
 }
Esempio n. 9
0
 // 创建GM账号,返回true创建成功
 public bool createGMUser(ParamBase param)
 {
     m_gmUser = new GMUser(param);
     if (!m_gmUser.isLogin)
     {
         m_retData.Add("result", RetCode.RET_GM_LOGIN_FAILED);
     }
     return(m_gmUser.isLogin);
 }
Esempio n. 10
0
    /*
     * 作为状态机基类,要求子类传入玩家属性
     */

    public virtual void Init(StateBase defaultState, ParamBase parameter)
    {
        this.defaultState = defaultState;

        /*
         * 状态机进入默认状态
         */

        TransactionState(defaultState);
    }
Esempio n. 11
0
    public ParamConnection GetParamConnection(string name)
    {
        ParamBase pb = GetParam(name, ParamBase.Type.PCMInput);

        if (pb == null)
        {
            return(null);
        }

        return((ParamConnection)pb);
    }
Esempio n. 12
0
    /// <summary>
    /// Get the node's enum parameter matching a specified name.
    /// </summary>
    /// <param name="name">The name of the parameter to retrive</param>
    /// <returns>The found parameter, or null if none was found.</returns>
    public ParamEnum GetParamEnum(string name)
    {
        ParamBase pb = GetParam(name, ParamBase.Type.Enum);

        if (pb == null)
        {
            return(null);
        }

        return((ParamEnum)pb);
    }
Esempio n. 13
0
    public ParamText GetParamText(string name)
    {
        ParamBase pb = GetParam(name, ParamBase.Type.Text);

        if (pb == null)
        {
            return(null);
        }

        return((ParamText)pb);
    }
Esempio n. 14
0
    /// <summary>
    /// Get the node's bool parameter matching a specified name.
    /// </summary>
    /// <param name="name">The name of the parameter to retrive.</param>
    /// <returns>The found parameter, or null if none was found.</returns>
    public ParamBool GetBoolParam(string name)
    {
        ParamBase pb = GetParam(name, ParamBase.Type.Bool);

        if (pb == null)
        {
            return(null);
        }

        return((ParamBool)pb);
    }
Esempio n. 15
0
    /// <summary>
    /// Get the node's float parameter matching a specified name.
    /// </summary>
    /// <param name="name">The name of the paramter to retrieve.</param>
    /// <returns>The found parameter, or null if none was found.</returns>
    public ParamFloat GetFloatParam(string name)
    {
        ParamBase pb = GetParam(name, ParamBase.Type.Float);

        if (pb == null)
        {
            return(null);
        }

        return((ParamFloat)pb);
    }
Esempio n. 16
0
    /// <summary>
    /// 注册
    /// </summary>
    public void SignUp()
    {
        SocketIO.Ins.OpenSocket();
        string    uname = username.text;
        string    upwd  = password.text;
        ParamBase param = new ParamBase();

        param.name = uname;
        string paramstr = JsonConvert.SerializeObject(param);

        SocketIO.Ins.sdgSocket.Emit("ReqSignUp", paramstr);
    }
Esempio n. 17
0
    public override string doDyop(object param)
    {
        ParamBase p = (ParamBase)param;

        p.fieldIndex = 2;
        bool cres = createGMUser(p);

        if (!cres)
        {
            return(Helper.genJsonStr(m_retData));
        }

        if (!p.checkSign(m_gmUser))
        {
            m_retData.Add("result", RetCode.RET_SIGN_ERROR);
            return(Helper.genJsonStr(m_retData));
        }

        Player player = new Player(p.m_playerAcc, m_gmUser);

        if (!player.m_isExists)
        {
            m_retData.Add("result", RetCode.RET_NO_PLAYER);
            return(Helper.genJsonStr(m_retData));
        }
        if (!player.isOwner(m_gmUser.m_acc))
        {
            m_retData.Add("result", RetCode.RET_NO_RIGHT);
            return(Helper.genJsonStr(m_retData));
        }

        string url = string.Format(CONST.URL_CLEAR_FAILED_LOGIN, p.m_playerAcc);
        var    ret = HttpPost.Get(new Uri(url));

        if (ret != null)
        {
            string retStr = Encoding.UTF8.GetString(ret);
            if (retStr == "0")
            {
                m_retData.Add("result", RetCode.RET_SUCCESS);
            }
            else
            {
                m_retData.Add("result", RetCode.RET_OP_FAILED);
            }
        }
        else
        {
            m_retData.Add("result", RetCode.RET_OP_FAILED);
        }
        return(Helper.genJsonStr(m_retData));
    }
Esempio n. 18
0
        public static bool HasUnit(this ParamBase p, string unitAccession)
        {
            if (p == null)
            {
                throw new ArgumentNullException("p");
            }
            if (unitAccession == null)
            {
                throw new ArgumentNullException("unitAccession");
            }

            return(p.CvUnitAccession != null &&
                   p.CvUnitAccession.Equals(unitAccession, StringComparison.InvariantCultureIgnoreCase));
        }
Esempio n. 19
0
    public virtual bool SaveXML(System.Xml.XmlElement ele)
    {
        foreach (ParamBase pb in this.genParams)
        {
            string paramType = ParamBase.ToSerializationType(pb.type);
            System.Xml.XmlElement paramEle = ele.OwnerDocument.CreateElement(paramType);
            paramEle.SetAttribute("name", pb.name);
            paramEle.InnerText = pb.GetStringValue();
            paramEle.SetAttribute("visible", ParamBool.ConvertToString(pb.visible));

            ele.AppendChild(paramEle);
        }

        return(true);
    }
Esempio n. 20
0
    /// <summary>
    ///  登录
    /// </summary>
    public void Login()
    {
        SocketIO.Ins.OpenSocket();
        string uname = username.text;
        string upwd  = password.text;

        CurrentPlayer.Ins.user.username = uname;
        CurrentPlayer.Ins.user.password = upwd;
        ParamBase param = new ParamBase();

        param.name = uname;
        string paramstr = JsonConvert.SerializeObject(param);

        SocketIO.Ins.sdgSocket.Emit("ReqSignIn", paramstr);
    }
Esempio n. 21
0
        public static long GetInt64OrDefault(this ParamBase p)
        {
            if (p == null)
            {
                throw new ArgumentNullException("p");
            }

            if (p.HasValue())
            {
                return(p.Value.ToInt64(ParamEditExtension.FormatProvider));
            }
            else
            {
                return(default(long));
            }
        }
Esempio n. 22
0
        public static IConvertible GetValueOrDefault(this ParamBase p)
        {
            if (p == null)
            {
                throw new ArgumentNullException("p");
            }

            if (p.HasValue())
            {
                return(p.Value);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 23
0
        public static float GetSingleOrDefault(this ParamBase p)
        {
            if (p == null)
            {
                throw new ArgumentNullException("p");
            }

            if (p.HasValue())
            {
                return(p.Value.ToSingle(ParamEditExtension.FormatProvider));
            }
            else
            {
                return(default(float));
            }
        }
Esempio n. 24
0
        public static char GetCharOrDefault(this ParamBase p)
        {
            if (p == null)
            {
                throw new ArgumentNullException("p");
            }

            if (p.HasValue())
            {
                return(p.Value.ToChar(ParamEditExtension.FormatProvider));
            }
            else
            {
                return(default(char));
            }
        }
Esempio n. 25
0
        public static bool GetBooleanOrDefault(this ParamBase p)
        {
            if (p == null)
            {
                throw new ArgumentNullException("p");
            }

            if (p.HasValue())
            {
                return(p.Value.ToBoolean(ParamEditExtension.FormatProvider));
            }
            else
            {
                return(default(Boolean));
            }
        }
Esempio n. 26
0
        public static IConvertible GetValue(this ParamBase p)
        {
            if (p == null)
            {
                throw new ArgumentNullException("p");
            }

            if (p.HasValue())
            {
                return(p.Value);
            }
            else
            {
                throw new InvalidOperationException("Param value not set.");
            }
        }
Esempio n. 27
0
        public static float GetSingle(this ParamBase p)
        {
            if (p == null)
            {
                throw new ArgumentNullException("p");
            }

            if (p.HasValue())
            {
                return(p.Value.ToSingle(ParamEditExtension.FormatProvider));
            }
            else
            {
                throw new InvalidOperationException("Param value not set.");
            }
        }
Esempio n. 28
0
        static void Main(string[] args)
        {
            Console.WriteLine("WebRTC Test Pattern Server Demo");
            CancellationTokenSource cts = new CancellationTokenSource();

            // Start web socket.
            Console.WriteLine("Starting web socket server...");
            var webSocketServer = new WebSocketServer(IPAddress.Any, WEBSOCKET_PORT);

            webSocketServer.AddWebSocketService <WebRTCWebSocketPeer>("/", (peer) => peer.CreatePeerConnection = CreatePeerConnection);
            webSocketServer.Start();

            Console.WriteLine($"Waiting for web socket connections on {webSocketServer.Address}:{webSocketServer.Port}...");
            Console.WriteLine("Press ctrl-c to exit.");

            ManualResetEvent exitMre = new ManualResetEvent(false);

            Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e)
            {
                e.Cancel = true;
                cts.Cancel();
                exitMre.Set();
            };

            ParamBase encoderParams = new ParamBase();

            encoderParams.MaxFrameRate  = 60.0F;
            encoderParams.PicWidth      = 640;
            encoderParams.PicHeight     = 480;
            encoderParams.RateControl   = RateControlModes.RC_BITRATE_MODE;
            encoderParams.TargetBitrate = 5000000;
            encoderParams.UsageType     = UsageType.CAMERA_VIDEO_REAL_TIME;

            SourcePicture sourcePicture = new SourcePicture();

            sourcePicture.PicWidth    = 640;
            sourcePicture.PicHeight   = 480;
            sourcePicture.ColorFormat = (int)VideoFormats.VideoFormatI420;
            encoder = new Encoder();

            encoder.KeyframeInterval = 5;
            encoder.Initialize(encoderParams);
            encoder.SetSourcePictureParameters(sourcePicture);

            exitMre.WaitOne();
            encoder.Dispose();
        }
Esempio n. 29
0
    public GMUser(ParamBase param)
    {
        string sqlServer = WebConfigurationManager.AppSettings["mysql"];

        m_sqlDb = new MySqlDbServer(sqlServer);

        string sqlCmd = string.Format(CONST.SQL_QUERY_GM_USER,
                                      TableName.GM_ACCOUNT,
                                      param.m_gmAccount,
                                      param.m_gmPwd,
                                      CONST.FIELD_SET[param.fieldIndex]);

        Dictionary <string, object> r = m_sqlDb.queryOne(sqlCmd, MySqlDbName.DB_XIANXIA);

        if (r != null)
        {
            do
            {
                m_acc = Convert.ToString(r["acc"]);
                string dbPwd = Convert.ToString(r["pwd"]);
                if (m_acc != param.m_gmAccount)
                {
                    m_isLogin = false;
                    break;
                }
                if (dbPwd != param.m_gmPwd)
                {
                    m_isLogin = false;
                    break;
                }
                m_accType = Convert.ToInt32(r["accType"]);
                if (m_accType != AccType.ACC_API)
                {
                    m_isLogin = false;
                    break;
                }
                m_devSecretKey = Convert.ToString(r["devSecretKey"]);
                readFieldValue(r, param.fieldIndex);
                m_isLogin = true;
            } while (false);
        }
    }
Esempio n. 30
0
        public IHasValue SetCvParam(string accession)
        {
            if (string.IsNullOrWhiteSpace(accession))
            {
                throw new ArgumentNullException("accession");
            }

            if (HasCvParam(accession))
            {
                Param = ParamContainer.CvParams[accession];
            }
            else
            {
                CvParam param = new CvParam(accession);
                ParamContainer.CvParams.Add(param);
                Param = param;
            }

            return(new HasValue(this));
        }