Beispiel #1
0
        public void Initialize(NetParams netParams)
        {
            m_net.Initialize(netParams);
            m_modelTime = netParams.modelTime;
            m_threats.Clear();
            TimerCallback tm = new TimerCallback(OnTimer);

            m_timer = new System.Threading.Timer(tm, 0, Timeout.Infinite, 1000);
        }
Beispiel #2
0
 /// <summary>
 /// 构造
 /// </summary>
 /// <param name="username"></param>
 /// <param name="passworld"></param>
 public User(string username,string passworld)
 {
     ready = false;
     isLogined=false;
     proxy = null;
     proxyPort = 0;
     isProxy = true;
     netParams = null;
     if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(passworld))
         return;
     myname = username;
     mypass = passworld;
     flowerDateTime = DateTime.Now;
     //nick = Common.Gb2312();
     //if(user.pass=ilin)
 }
Beispiel #3
0
        private void OnInitialize()
        {
            // get parameters
            NetParams netParams = new NetParams();

            netParams.netSize   = int.Parse(netSize_tbx.Text);
            netParams.cellSize  = int.Parse(cellSize_tbx.Text);
            netParams.wCoast    = int.Parse(wCoast_tbx.Text);
            netParams.aCoast    = int.Parse(aCoast_tbx.Text);
            netParams.modelTime = int.Parse(modelTime_tbx.Text);
            netParams.scenario  = (Scenario)scenario_cbx.SelectedIndex;

            //clear
            dataGW.Columns.Clear();
            infor_lbl.Text            = "";
            step_lbl.Text             = "Инициализация";
            currentModelTime_lbl.Text = "0";

            // initialize
            for (int i = 0; i < netParams.netSize; ++i)
            {
                var column1 = new DataGridViewColumn();
                column1.HeaderText   = i.ToString();                  //текст в шапке
                column1.Width        = 22;                            //ширина колонки
                column1.ReadOnly     = true;                          //значение в этой колонке нельзя править
                column1.Name         = i.ToString();                  //текстовое имя колонки, его можно использовать вместо обращений по индексу
                column1.CellTemplate = new DataGridViewTextBoxCell(); //тип нашей колонки
                dataGW.Columns.Add(column1);
            }
            dataGW.RowCount = 5;
            // set
            dataGW.Rows[0].HeaderCell.Value = "Генерируемые данные";
            dataGW.Rows[1].HeaderCell.Value = "Входные данные";
            dataGW.Rows[2].HeaderCell.Value = "Анализ угроз";
            dataGW.Rows[3].HeaderCell.Value = "Тревога";
            dataGW.Rows[4].HeaderCell.Value = "Сброс";
            dataGW.RowHeadersWidth          = 160;
            // initialixe petri net
            m_netCtrl.Initialize(netParams);
        }
Beispiel #4
0
 public static extern UInt32 LPR_SetNetParams(IntPtr pHandle, ref NetParams pOldParams, ref NetParams pNewParams);
Beispiel #5
0
 public static extern UInt32 LPR_SetNetParams(IntPtr pHandle, ref NetParams pOldParams, ref NetParams pNewParams);
Beispiel #6
0
 /// <summary>
 /// 获取参数
 /// </summary>
 bool GetParams()
 {
     //if (isProxy)
     //{
     //    byte[] data = new byte[1024];
     //    //IPAddress ip = IPAddress.Parse(proxy);
     //    //IPEndPoint ipEnd = new IPEndPoint(ip, proxyPort);
     //    ///重连X次
     //    for (int i = 0; i < 1; i++)
     //    {
     //        try
     //        {
     //            //socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     //            socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 5000);
     //            //Common.NowMsg = "代理" + proxy + ":" + proxyPort + "【获取参数】连接中,";
     //            //socket.Connect(ipEnd);
     //            StringBuilder buf = new StringBuilder();
     //            buf.Append("GET ").Append("http://yy.com//get-data/9999?subSid=125233252&type=main&_=137493045" + new Random().Next(1, 9) + "9" + new Random().Next(1, 9)).Append(" HTTP/1.1\r\n");
     //            buf.Append("User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)\r\n");
     //            buf.Append("Host: yy.com\r\n");
     //            buf.Append("Proxy-Connection: Keep-Alive\r\n");
     //            buf.Append("\r\n");
     //            byte[] ms = System.Text.UTF8Encoding.UTF8.GetBytes(buf.ToString());
     //            //发送
     //            socket.Send(ms);
     //            string jsonStr = string.Empty;
     //            int recv = 0;
     //            do
     //            {
     //                recv = socket.Receive(data);
     //                if (recv > 0)
     //                    jsonStr += (Encoding.Default.GetString(data, 0, recv));
     //                //判断参数结尾
     //                if (jsonStr.IndexOf("core.bmp\"}") != -1)
     //                    break;
     //            } while (recv != 0);
     //            socket.Close();
     //            if (jsonStr.IndexOf("200 OK") == -1)//未取到参数
     //            {
     //                Common.ProxyManager.Score(proxy, ScoreType.Discard);
     //                if (Common.LogSwitch)
     //                    lastMsg = "代理服务器未返回有效参数";
     //                continue;
     //            }
     //            jsonStr = jsonStr.Substring(jsonStr.IndexOf("{\""));
     //            StringReader sread = new StringReader(jsonStr);
     //            JsonReader jr = new JsonReader(sread);
     //            JsonSerializer js = new JsonSerializer();
     //            NetParams np = (NetParams)js.Deserialize(jr, typeof(NetParams));
     //            netParams = np;
     //            server = netParams.pps[0].ip;
     //            port = netParams.pps[0].ports[0];
     //            lastMsg = "获取参数完成";
     //            break;
     //        }
     //        catch (SocketException se)
     //        {
     //            if (se.ErrorCode == 10060)
     //                if (Common.LogSwitch)
     //                    lastMsg = "代理服务器无回应";
     //                else if (se.ErrorCode == 10061)
     //                    if (Common.LogSwitch)
     //                        lastMsg = "代理服务器拒绝连接";
     //                    else
     //                        lastMsg = "";
     //        }
     //        catch (Exception e)
     //        {
     //            //异常
     //            Common.ProxyManager.Score(proxy, ScoreType.Exception);
     //            if (Common.LogSwitch)
     //                lastMsg = "参数数据异常。";
     //            return false;
     //        }
     //    }
     //}
     //else
     {
         try
         {
             lastMsg = "获取参数...";
             HttpWebResponse response = HttpWebResponseUtility.CreateGetHttpResponse(tagUrl, null, null, null);
             StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
             string jsonStr = sr.ReadToEnd();
             StringReader sread = new StringReader(jsonStr);
             JsonReader jr = new JsonReader(sread);
             JsonSerializer js = new JsonSerializer();
             NetParams np = (NetParams)js.Deserialize(jr, typeof(NetParams));
             netParams = np;
             //设置缺省服务器及端口
             server = netParams.pps[0].ip;
             port = netParams.pps[0].ports[0];
             lastMsg = "获取参数完成";
         }
         catch (Exception e)
         {
             if (Common.LogSwitch)
                 lastMsg = "获取参数失败,可能是网速太差。";
             return false;
         }
     }
     return true;
 }
Beispiel #7
0
 private void SetLogLevel()
 {
     Log.addLevel("5");
     NetParams.addLevel("5");
 }