Esempio n. 1
0
                } // end CheckAttributeData

                public override void UnderAttack(IDamageData damage) {
                    if (null == damage) return;
                    // end if
                    IRealData realData = new RealData(damage, m_charcterData);
                    m_charcterData.Minus(realData);
                    Vector2 screenPoint = SceneManager.mainCamera.camera.WorldToScreenPoint(character.helpTransform.position);
                    Vector2 hud_pos;
                    if (RectTransformUtility.ScreenPointToLocalPointInRectangle(SceneManager.mainCanvas.HUD_rectTRansform, screenPoint,
                        SceneManager.mainCanvas.camera, out hud_pos)) {
                        HUD_Damage hud = InstanceMgr.GetObjectManager().GetGameObject<HUD_Damage>(HUD_Damage.poolName);
                        hud.SetNumber(realData.HP);
                        hud.transform.SetParent(SceneManager.mainCanvas.HUD_rectTRansform, false);
                        hud.transform.localPosition = hud_pos;
                        hud.gameObject.SetActive(true);
                    } // end if
                    if (null != lockCharacter) return;
                    // end if
                    if (damage.hashID == SceneManager.mainCharacter.hashID) {
                        LockCharacter(SceneManager.mainCharacter);
                        return;
                    } // end if
                    ICharacter npc = SceneManager.characterManager.factory.GetNPCharacter(damage.hashID);
                    if (null != npc) {
                        LockCharacter(npc);
                    } // end if
                } // end UnderAttack
Esempio n. 2
0
        /// <summary>
        /// 增加数据委托
        /// </summary>
        /// <param name="realData"></param>
        private void AddDataDelegate(RealData realData)
        {
            if (dataLst.Count >= TargetLimit)
            {
                dataLst.Clear();
            }

            int oldDataIndex = dataLst.FindIndex(i => i.TargetNum == realData.TargetNum);

            if (oldDataIndex < 0)
            {
                dataLst.Add(realData);

                if (ToolStripMenuItemRefresh.Checked)
                {
                    gvRealData.FocusedRowHandle = dataLst.Count - 1;
                }
            }
            else
            {
                dataLst[oldDataIndex] = realData;
            }
            gcRealData.DataSource = dataLst;
            gcRealData.RefreshDataSource();
        }
Esempio n. 3
0
        private void 闪烁ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            RealData data = gvRealData.GetFocusedRow() as RealData;

            if (data == null)
            {
                return;
            }

            try
            {
                var element = globeBusiness.mapLogic.GetElement(data.TargetNum.ToString());
                if (element == null)
                {
                    return;
                }
                I3DModel model = element as I3DModel;
                if (model == null)
                {
                    return;
                }

                bool flash = !model.IsFlash;
                model.Flash(flash, 500);
            }
            catch (Exception ex)
            {
                Log4Allen.WriteLog(typeof(RealDataListControl), ex.Message);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 判断点是否在多边形内(预警)
        /// </summary>
        /// <param name="point"></param>
        /// <param name="warnNames"></param>
        /// <returns></returns>
        public bool Warn(RealData dataIn, out RealData dataOut, out bool isWarn, out List <string> warnNames)
        {
            warnNames = new List <string>();
            isWarn    = false;
            dataOut   = dataIn;

            if (dataIn.Altitude > Atilute)
            {
                return(false);                              // 如果高度超过预警高度,则直接返回false
            }
            foreach (var item in warnAresDic.Values)
            {
                if (item.IsWarn == false)
                {
                    continue;
                }

                if (MapFrame.Core.Common.Utils.IsInsidePolygon(new MapLngLat(dataIn.Longitude, dataIn.Latitude, dataIn.Altitude), item.Points))
                {
                    isWarn = true;
                    warnNames.Add(item.Name);
                }
            }

            return(isWarn);
        }
Esempio n. 5
0
        // 处理预警结果
        public void DealWarnData(RealData data, bool isWarn, List <string> warnNames)
        {
            IMFLayer layer = mapLogic.GetLayer(GetModelLayerName(data.TargetType));

            if (layer == null)
            {
                return;
            }

            IMFElement element = layer.GetElement(data.TargetNum.ToString());

            if (element == null)
            {
                return;
            }

            if (isWarn == false)
            {
                element.Flash(false);
            }
            else
            {
                if (element.IsFlash == false)
                {
                    element.Flash(true, 500);
                }
            }
        }
Esempio n. 6
0
        protected override bool InitCommunicateKernel(IO_SERVER server, IO_COMMUNICATION communication, List <IO_DEVICE> ioDevices, SCADA_DRIVER driver)
        {
            if (IsCreateControl)
            {
                CommunicationControl = new Modbus_Serial_Ctrl();
                if (communication != null)
                {
                    CommunicationControl.SetUIParameter(communication.IO_COMM_PARASTRING);
                }
            }
            Serial_PARA = new Modbus_Serial_PARA();
            if (communication != null)
            {
                comParaPack          = new ParaPack(communication.IO_COMM_PARASTRING);
                Serial_PARA.BaudRate = Convert.ToInt32(comParaPack.GetValue("波特率"));
                Serial_PARA.CollectFaultsInternal = Convert.ToInt32(comParaPack.GetValue("重试间隔"));
                Serial_PARA.CollectFaultsNumber   = Convert.ToInt32(comParaPack.GetValue("重试次数"));
                Serial_PARA.ContinueCollect       = comParaPack.GetValue("连续采集") == "1" ? true : false;
                Serial_PARA.DataBits             = Convert.ToInt32(comParaPack.GetValue("数据位"));
                Serial_PARA.ModbusType           = (ModbusType)Enum.Parse(typeof(ModbusType), comParaPack.GetValue("MODBUS类型"));
                Serial_PARA.OffsetInterval       = Convert.ToInt32(comParaPack.GetValue("偏移间隔"));
                Serial_PARA.PackMaxSize          = Convert.ToInt32(comParaPack.GetValue("包最大长度"));
                Serial_PARA.ReadTimeout          = Convert.ToInt32(comParaPack.GetValue("读超时时间"));
                Serial_PARA.RSTSendPreKeeyTime   = Convert.ToInt32(comParaPack.GetValue("发送前RTS保持时间"));
                Serial_PARA.RTSSendAfterKeeyTime = Convert.ToInt32(comParaPack.GetValue("发送后RTS保持时间"));
                Serial_PARA.RTSEnable            = comParaPack.GetValue("RTS") == "1" ? true : false;
                Serial_PARA.SerialCheck          = (SerialCheck)Enum.Parse(typeof(SerialCheck), comParaPack.GetValue("校验"));
                Serial_PARA.SerialPort           = comParaPack.GetValue("串口");
                Serial_PARA.SimulatorSerialPort  = comParaPack.GetValue("模拟器串口");
                Serial_PARA.SixCommmand          = comParaPack.GetValue("支持6号命令") == "1" ? true : false;
                Serial_PARA.SixteenCommmand      = comParaPack.GetValue("支持16号命令") == "1" ? true : false;;
                Serial_PARA.StopBits             = (StopBits)Enum.Parse(typeof(StopBits), comParaPack.GetValue("停止位"));
                Serial_PARA.WriteTimeout         = Convert.ToInt32(comParaPack.GetValue("写超时时间"));

                //构造获取数据命令的字节数组,Modbus
                for (int i = 0; i < this.IODevices.Count; i++)
                {
                    object   fragment  = new ModbusFragmentStore();
                    RealData mRealData = new RealData();
                    mRealData.Device = this.IODevices[i];
                    ScadaDeviceKernel driverDll = DeviceDrives.Find(x => x.DeviceDriverID == this.IODevices[i].DEVICE_DRIVER_ID);
                    if (driverDll != null)
                    {
                        driverDll.InitKernel(IOServer, IOCommunication, this.IODevices[i], null, this.IODevices[i].DriverInfo);
                        //IO_DEVICE_ADDRESS中存储的是DTU编号
                        mRealData.SlaveId = this.IODevices[i].IO_DEVICE_ADDRESS;
                        //数据库中系统编号
                        mRealData.DEVICEID = this.IODevices[i].IO_DEVICE_ID;
                        //获取下发命令的参数,注意此次要进心分段存储,因为modbus一次不能超过123个寄存器地址
                        mRealData.Fragment = (ModbusFragmentStore)fragment;
                        RealDevices.Add(mRealData);
                    }
                }
            }

            return(true);
        }
Esempio n. 7
0
 public void CreateItem(RealData data)
 {
     Context.SaveAsync(data, (result) => {
         if (result.Exception != null)
         {
             resultText.text += result.Exception.Message;
             return;
         }
     });
 }
Esempio n. 8
0
        public MainWindow()
        {
            InitializeComponent();
            this.Visibility = Visibility.Hidden;
            new LoginForm().ShowDialog();
            this.Visibility = Visibility.Visible;


            usersList.Users.ItemsSource = RealData.getUsers();
        }
Esempio n. 9
0
 /// <summary>
 /// 增加数据
 /// </summary>
 /// <param name="realData"></param>
 public void AddData(RealData realData)
 {
     if (gcRealData.InvokeRequired)
     {
         gcRealData.Invoke((Action) delegate() { AddDataDelegate(realData); });
     }
     else
     {
         AddDataDelegate(realData);
     }
 }
 private void LevelsQuotesClick(double price, string buySell)
 {
     if (_MainWindow.dcFutHangqing.IsSelected)
     {
         foreach (var item in _MainWindow.RealDataCollection)
         {
             if (item.Code == this.lblCode.Content.ToString())
             {
                 if (LevelRealDataMouseLeftButtonDown != null)
                 {
                     RealData realRecord = new RealData();
                     if (realRecord.UpdateRealProperties(item as DisplayRealData))
                     {
                         LevelRealDataMouseLeftButtonDown(buySell, realRecord, price, false);
                         break;
                     }
                 }
             }
         }
     }
     else if (_MainWindow.dcOptHangqing.IsSelected)
     {
         foreach (OptionRealData item in _MainWindow.OptionRealDataCollection)
         {
             if (item.Code_C == this.lblCode.Content.ToString())
             {
                 if (LevelRealDataMouseLeftButtonDown != null)
                 {
                     RealData realRecord = item.GetOptRealData_C();
                     if (realRecord != null)
                     {
                         LevelRealDataMouseLeftButtonDown(buySell, realRecord, price, false);
                         break;
                     }
                 }
             }
             else if (item.Code_P == this.lblCode.Content.ToString())
             {
                 if (LevelRealDataMouseLeftButtonDown != null)
                 {
                     RealData realRecord = item.GetOptRealData_P();
                     if (realRecord != null)
                     {
                         LevelRealDataMouseLeftButtonDown(buySell, realRecord, price, false);
                         break;
                     }
                 }
             }
         }
     }
 }
Esempio n. 11
0
        // 创建目标对象
        private Plane CreateStateModel(RealData data, MapLngLat postion)
        {
            Plane p = new Plane();

            p.Name           = data.TargetNum.ToString();
            p.Azimuth        = data.ActionRange;
            p.Coordinate     = postion;
            p.TrackLayerName = GetModelLayerName(data.TargetType);
            p.TargetType     = data.TargetType;
            p.PlaneColor     = data.TargetProperty == 0 ? Color.Red : Color.Blue;

            string text = string.Format("目标:{0}\n经度:{1}\n纬度:{2}\n高度:{3}\n信息来源:{4}\n国家:{5}\n目标性质:{6}\n目标类别:{7}\n装备型号:{8}\n位置时间:{9}",
                                        data.TargetNum, data.Longitude, data.Latitude, data.Altitude, data.InformationSource, data.Country, data.TargetProperty, data.TargetType, data.EquipModelNumber, data.PositionDate);

            p.LabelText = text;

            string path      = "";
            string layerName = "";

            switch (data.TargetType)
            {
            case 0:        // 空中目标
                path      = string.Format("{0}|{1}|{2}", Application.StartupPath + "\\Image\\TTMITC.TTF", 88, 18);
                layerName = "天空态势图层";
                break;

            case 1:        // 陆地目标
                path      = string.Format("{0}|{1}|{2}", Application.StartupPath + "\\Image\\TTMITC.TTF", 92, 18);
                layerName = "陆地态势图层";
                break;

            case 2:        // 海洋目标
                path      = string.Format("{0}|{1}|{2}", Application.StartupPath + "\\Image\\TTMITC.TTF", 97, 18);
                layerName = "海洋态势图层";
                break;

            case 3:        // 未知目标
                path      = string.Format("{0}|{1}|{2}", Application.StartupPath + "\\Image\\TTMITC.TTF", 86, 18);
                layerName = "未知目标图层";
                break;

            default:
                path      = string.Format("{0}|{1}|{2}", Application.StartupPath + "\\Image\\TTMITC.TTF", 86, 18);
                layerName = "未知目标图层";
                break;
            }

            p.LayerName = layerName;
            p.ImageUrl  = path;
            return(p);
        }
Esempio n. 12
0
        protected override bool InitCommunicateKernel(IO_SERVER server, IO_COMMUNICATION communication, List <IO_DEVICE> ioDevices, SCADA_DRIVER driver)
        {
            if (IsCreateControl)
            {
                CommunicationControl = new Modbus_UDP_Ctrl();
                if (communication != null)
                {
                    CommunicationControl.SetUIParameter(communication.IO_COMM_PARASTRING);
                }
            }
            Udp_PARA = new Modbus_TCP_PARA();
            if (communication != null)
            {
                TcpParaPack = new ParaPack(communication.IO_COMM_PARASTRING);
                Udp_PARA.CollectFaultsInternal = Convert.ToInt32(TcpParaPack.GetValue("重试间隔"));
                Udp_PARA.CollectFaultsNumber   = Convert.ToInt32(TcpParaPack.GetValue("重试次数"));
                Udp_PARA.ContinueCollect       = TcpParaPack.GetValue("重试") == "1" ? true : false;
                Udp_PARA.LocalTCP_Port         = TcpParaPack.GetValue("本地端口");
                Udp_PARA.LocalTCP_IP           = TcpParaPack.GetValue("本地IP");
                Udp_PARA.SimulatorTCP_Port     = TcpParaPack.GetValue("模拟设备端口");
                Udp_PARA.SimulatorTCP_IP       = TcpParaPack.GetValue("模拟设备IP");
                Udp_PARA.WriteTimeout          = int.Parse(TcpParaPack.GetValue("写超时时间"));
                Udp_PARA.ReadTimeout           = int.Parse(TcpParaPack.GetValue("读超时时间"));
                Udp_PARA.WriteBufferSize       = int.Parse(TcpParaPack.GetValue("写缓存"));
                Udp_PARA.ReadBufferSize        = int.Parse(TcpParaPack.GetValue("读缓存"));

                //构造获取数据命令的字节数组,Modbus
                for (int i = 0; i < this.IODevices.Count; i++)
                {
                    object   fragment  = new ModbusFragmentStore();
                    RealData mRealData = new RealData();
                    mRealData.Device = this.IODevices[i];
                    ScadaDeviceKernel driverDll = DeviceDrives.Find(x => x.DeviceDriverID == this.IODevices[i].DEVICE_DRIVER_ID);
                    if (driverDll != null)
                    {
                        driverDll.InitKernel(IOServer, IOCommunication, this.IODevices[i], null, this.IODevices[i].DriverInfo);
                        //IO_DEVICE_ADDRESS中存储的是DTU编号
                        mRealData.SlaveId = this.IODevices[i].IO_DEVICE_ADDRESS;
                        //数据库中系统编号
                        mRealData.DEVICEID = this.IODevices[i].IO_DEVICE_ID;
                        //获取下发命令的参数,注意此次要进心分段存储,因为modbus一次不能超过123个寄存器地址
                        //mRealData.ReadSendByte = driverDll.GetDataCommandBytes(this.IOServer, this.IOCommunication, this.IODevices[i], this.IODevices[i].IOParas, null, ref fragment);
                    }
                    mRealData.Fragment = (ModbusFragmentStore)fragment;
                    RealDevices.Add(mRealData);
                }
            }

            return(true);
        }
Esempio n. 13
0
        /// <summary>
        /// 删除所选目标
        /// </summary>
        private void DeleteFocusedItem()
        {
            if (DevExpress.XtraEditors.XtraMessageBox.Show("是否从列表删除所选实时数据?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (gvRealData.FocusedRowHandle < 0)
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show("您还未选中任何数据!", "删除提示", MessageBoxButtons.OK);
                }
                else
                {
                    try
                    {
                        dataLst.RemoveAt(gvRealData.FocusedRowHandle);

                        //TODO:删除地图数据
                        RealData data = gvRealData.GetFocusedRow() as RealData;
                        if (data == null)
                        {
                            return;
                        }

                        string elementName = data.TargetNum.ToString();
                        string lineName    = elementName + "line";

                        var layer = globeBusiness.mapLogic.GetLayer(layerName);
                        if (layer == null)
                        {
                            return;
                        }

                        layer.RemoveElement(elementName);
                        layer.RemoveElement(lineName);

                        var layerMap = mapBusiness.mapLogic.GetLayer(layerName);
                        if (layerMap != null)
                        {
                            layerMap.RemoveElement(elementName);
                            layerMap.RemoveElement(lineName);
                        }

                        gcRealData.RefreshDataSource();
                    }
                    catch (Exception ex)
                    {
                        Log4Allen.WriteLog(typeof(RealDataListControl), ex.Message);
                    }
                }
            }
        }
 private double GetPriceFluctuation(RealData realData)
 {
     if (realData.NewPrice == 0.0)
     {
         return(0);
     }
     else if (realData.PrevSettlementPrice == 0)
     {
         return(realData.NewPrice - realData.PrevClose);
     }
     else
     {
         return(realData.NewPrice - realData.PrevSettlementPrice);
     }
 }
Esempio n. 15
0
        private void AddClicked(object sender, RoutedEventArgs e)
        {
            //TODO: VALIDATION
            if (dataType == DataType.user)
            {
                if (UserForm.validate())
                {
                    if (RealData.addUser(new User(UserForm.username.Text, UserForm.handle.Text, UserForm.image.Text), UserForm.password.Password))
                    {
                        MessageBox.Show("added");
                        this.Close();
                    }
                }

                //validate
            }
            if (dataType == DataType.post)
            {
                if (PostForm.validate())
                {
                    if (PostForm.Author.SelectedItem is User u)
                    {
                        if (RealData.addPost(new Post(PostForm.Text.Text, u), MainWindow.password))
                        {
                            MessageBox.Show("added");
                            this.Close();
                        }
                    }
                }
            }
            if (dataType == DataType.reply)
            {
                if (RepllyForm.validate())
                {
                    if (RepllyForm.Author.SelectedItem is User u)
                    {
                        if (RepllyForm.PostID.SelectedItem is Post p)
                        {
                            if (RealData.addReply(new Reply(RepllyForm.Text.Text, u, p), MainWindow.password))
                            {
                                MessageBox.Show("added");
                                this.Close();
                            }
                        }
                    }
                }
            }
        }
Esempio n. 16
0
    void EndGame()
    {
        GameActive = false;
        AutoScalingDifficulty();
        RealData sessionData = new RealData
        {
            ID       = System.Guid.NewGuid().ToString(),
            User     = PlayerPrefs.GetString("User"),
            Time     = System.DateTime.UtcNow.ToString(),
            GameType = "Desk",
            //ObjectScoreArray = ObjectScoreArray,
            ObjectDifficultyArray = objectDifficultyArray
        };

        aws.CreateItem(sessionData);
    }
Esempio n. 17
0
 private void LogInClicked(object sender, RoutedEventArgs e)
 {
     //database
     if (RealData.isAdmin(username.Text, password.Password))
     {
         success             = true;
         MainWindow.username = username.Text;
         MainWindow.password = password.Password;
         this.Close();
     }
     else
     {
         MessageBox.Show("Incorrect username or password! Try again!", "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error);
         password.Clear();
     }
 }
Esempio n. 18
0
        private void 跳转ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RealData focusedData = gvRealData.GetFocusedRow() as RealData;

            if (focusedData != null)
            {
                try
                {
                    globeBusiness.mapLogic.GetToolBox().ZoomToPosition(new MapFrame.Core.Model.MapLngLat(focusedData.Longitude, focusedData.Latitude, focusedData.Altitude));
                }
                catch (Exception ex)
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show("跳转失败:" + ex.Message);
                }
            }
        }
Esempio n. 19
0
 private void ToolStripMenuItemJump_Click(object sender, EventArgs e)
 {
     try
     {
         RealData focusedData = gvRealData.GetFocusedRow() as RealData;
         if (focusedData != null)
         {
             MapLngLat lnglat = new MapLngLat(focusedData.Longitude, focusedData.Latitude, focusedData.Altitude);
             globeBusiness.mapLogic.GetToolBox().ZoomToPosition(lnglat);
             gmapBusiness.mapLogic.GetToolBox().ZoomToPosition(lnglat);
         }
     }
     catch (Exception ex)
     {
         DevExpress.XtraEditors.XtraMessageBox.Show("跳转失败:" + ex.Message);
     }
 }
Esempio n. 20
0
        private void gvRealData_MouseMove(object sender, MouseEventArgs e)
        {
            var hitInfo = gvRealData.CalcHitInfo(e.X, e.Y);    //计算鼠标位置是否在行上

            if (hitInfo.InRow && hitInfo.RowHandle >= 0)
            {
                RealData realData = gvRealData.GetRow(hitInfo.RowHandle) as RealData;  //获取鼠标所在行
                if (realData != null)
                {
                    toolTipDetail.ShowHint(realData.ToString(), Control.MousePosition);
                }
            }
            else
            {
                toolTipDetail.HideHint();
            }
        }
Esempio n. 21
0
        private List <RealData> FromDataTable(DataTable dt)
        {
            List <RealData> dataLst = new List <RealData>();

            foreach (DataRow item in dt.Rows)
            {
                try
                {
                    RealData realData = new RealData();

                    realData.ActionRange       = double.Parse(item["ActionRange"].ToString());
                    realData.Country           = short.Parse(item["Country"].ToString());
                    realData.EquipModelNumber  = item["EquipModelNumber"].ToString();
                    realData.Altitude          = double.Parse(item["Altitude"].ToString());
                    realData.InformationSource = byte.Parse(item["InformationSource"].ToString());
                    realData.Latitude          = double.Parse(item["Latitude"].ToString());
                    realData.Longitude         = double.Parse(item["Longitude"].ToString());

                    string dateStr = item["PositionDate"].ToString().ToUpper();
                    int    eIndex  = dateStr.IndexOf("E");
                    if (eIndex > 0)
                    {
                        dateStr = dateStr.Replace("E", "");
                        string[] dateNumArray = dateStr.Split('+');
                        realData.PositionDate = (long)(double.Parse(dateNumArray[0]) * Math.Pow(10, int.Parse(dateNumArray[1])));
                    }
                    else
                    {
                        realData.PositionDate = long.Parse(item["PositionDate"].ToString());
                    }

                    realData.ScanRange      = double.Parse(item["ScanRange"].ToString());
                    realData.TargetNum      = long.Parse(item["TargetNum"].ToString());
                    realData.TargetProperty = byte.Parse(item["TargetProperty"].ToString());
                    realData.TargetType     = byte.Parse(item["TargetType"].ToString());

                    dataLst.Add(realData);
                }
                catch (Exception ex)
                {
                    continue;
                }
            }

            return(dataLst);
        }
Esempio n. 22
0
        public void editReply(Reply r)
        {
            EditView e = new EditView(r);

            e.ShowDialog();
            if (e.save)
            {
                if (e.replyEditor.validate())
                {
                    r.Text = e.replyEditor.Text.Text;
                    if (RealData.editReply(r))
                    {
                        MessageBox.Show("saved");
                    }
                }
            }
            FakeData.editReply(r);
        }
Esempio n. 23
0
        public void editUser(User u)
        {
            EditView e = new EditView(u, RealData.getPostsFromUser(u).ToList());

            e.ShowDialog();
            if (e.save)
            {
                if (e.userEditor.validate())
                {
                    u.Username = e.userEditor.username.Text;
                    u.Image    = e.userEditor.image.Text;
                    u.Handle   = e.userEditor.handle.Text;
                    if (RealData.editUser(u))
                    {
                        MessageBox.Show("saved");
                    }
                }
            }
        }
Esempio n. 24
0
        public void editPost(Post p)
        {
            //TODO: UI
            EditView e = new EditView(p, RealData.getRepliesFromPost(p).ToList());

            e.ShowDialog();
            if (e.save)
            {
                if (e.postEditor.validate())
                {
                    p.Text = e.postEditor.Text.Text;
                    if (RealData.editPost(p))
                    {
                        MessageBox.Show("saved");
                    }
                }
            }
            FakeData.editPost(p);
        }
Esempio n. 25
0
        public static void SetRealDataToContainer(RealData realData)
        {
            Contract codeKey = CodeSetManager.GetContractInfo(realData.CodeInfo.Code, realData.CodeInfo.ExchCode);

            if (codeKey != null)
            {
                if (RealDataContainer.ContainsKey(codeKey))
                {
                    RealDataContainer[codeKey] = realData;
                }
                else
                {
                    RealDataContainer.Add(codeKey, realData);
                }
            }
            else
            {
                Util.Log("Warning!: codeKey is NULL! ");
            }
        }
Esempio n. 26
0
 public NewData(DataType dataType)
 {
     InitializeComponent();
     this.dataType = dataType;
     if (dataType == DataType.user)
     {
         UserForm.Visibility = Visibility.Visible;
     }
     if (dataType == DataType.post)
     {
         PostForm.Author.ItemsSource = RealData.getUsers();
         PostForm.Visibility         = Visibility.Visible;
     }
     if (dataType == DataType.reply)
     {
         RepllyForm.Author.ItemsSource = RealData.getUsers();
         RepllyForm.PostID.ItemsSource = RealData.getPosts();
         RepllyForm.Visibility         = Visibility.Visible;
     }
 }
Esempio n. 27
0
        // 处理实时态势数据
        private void DealRealData(RealData data)
        {
            var    point      = new MapLngLat(data.Longitude, data.Latitude, data.Altitude);
            string name       = data.TargetNum.ToString();
            bool   isHaveDraw = elementMgr.IsHaveElement(name);

            trackMgr.AddTrackPoint(name, data.TargetType, point);           // 不管目标是否存在,都要添加航迹

            if (isHaveDraw == false)
            {
                if (AddElement(data))
                {
                    trackMgr.AddShowTrackModel(name, data.TargetType);   // ceshi................
                }
            }
            else
            {
                elementMgr.UpdateElementPosition(name, point);
                UpdateElement(data);
            }
        }
Esempio n. 28
0
        // 更新目标
        private bool UpdateElement(RealData data)
        {
            var layer = mapLogic.GetLayer(objLayer);

            if (layer == null)
            {
                return(false);
            }

            string name = data.TargetNum.ToString();

            if (!elementMgr.IsHaveElement(name))
            {
                return(false);
            }

            var element = mapLogic.GetLayer(objLayer).GetElement(name);

            if (element == null)
            {
                return(false);
            }
            IMFPicture picElement = element as IMFPicture;

            if (picElement == null)
            {
                return(false);
            }
            // 更新目标位置
            picElement.UpdatePosition(data.Longitude, data.Latitude);

            // 更新目标航迹
            if (trackMgr.IsShowTrack(name))
            {
                UpdateElementTrackLine(name);
            }

            return(true);
        }
Esempio n. 29
0
        protected override ScadaResult IOSendCommand(IO_SERVER server, IO_COMMUNICATION comm, IO_DEVICE device, IO_PARA para, string value)
        {
            ScadaResult res = new ScadaResult();

            if (device == null)
            {
                res = new ScadaResult(false, "设备对象不存在");
            }

            //用户发送一条命令后要及时获取最新的数据,主要是因为有些命令需要及时判断命令是否成功,
            if (ResponseData(server, comm, device, para, value))
            {
                RealData realData = this.RealDevices.Find(x => x.Device == device);
                string   error    = "";
                if (RequestData(realData.Device, realData, out error, realData.Fragment))
                {
                    res = new ScadaResult(true, "请求数据成功");
                }
            }
            DataSended(server, comm, device, para, value, res.Result);
            return(res);
        }
Esempio n. 30
0
        /// <summary>
        /// 实时数据入库
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static int Data2Db(RealData data)
        {
            if (data == null)
            {
                return(-1);
            }

            try
            {
                SQLiteCommand cmd = new SQLiteCommand(conn);
                cmd.CommandText = string.Format(@"insert into RealData (TargetNum,InformationSource,Country,TargetProperty,TargetType,EquipModelNumber,PositionDate,Longitude,Latitude,Altitude,ScanRange,ActionRange) 
                    values({0},{1},{2},{3},{4},'{5}',{6},{7},{8},{9},{10},{11})", data.TargetNum, data.InformationSource, data.Country, data.TargetProperty, data.TargetType, data.EquipModelNumber.Trim('\0'), data.PositionDate, data.Longitude, data.Latitude, data.Altitude,
                                                data.ScanRange, data.ActionRange);
                var ret = cmd.ExecuteNonQuery();
                return(ret);
            }
            catch (Exception ex)
            {
                Log4Allen.WriteLog(typeof(SQLiteHelper), ex.Message);
                return(-1);
            }
        }
Esempio n. 31
0
        /// <summary>
        /// Decode a file of all the samples.  A sample is made up of a
        /// group of Real and Imaginary data samples.  This will create a list
        /// of all samples found in the file.
        /// </summary>
        /// <param name="file">File to decode.</param>
        /// <returns>List of all the samples found in the list.</returns>
        public List<Sample> Decode(string file)
        {
            List<Sample> samples = new List<Sample>();
            List<byte> buffer = new List<byte>();

            // Placeholder for real data while waiting for imaginary data
            RealData realData = null;

            // Open file to read
            using (FileStream strm = File.OpenRead(file))
            {
                for (int x = 0; x < strm.Length; x++)
                {
                    // Read in a byte
                    int strmReadByte = strm.ReadByte();

                    // Verify the byte is good
                    if (strmReadByte >= 0)
                    {
                        // Add it to the list
                        buffer.Add((byte)strmReadByte);

                        // If the list has 4 bytes
                        // verify we have a good sample
                        // if we do not have a good sample,
                        // drop the first byte.  If we good have a
                        // good sample, remove the sample from the list
                        // and decode the sample
                        if (buffer.Count == 4)
                        {
                            // Create an array for the data
                            byte[] data = buffer.ToArray();

                            if (ValidRealData(buffer))
                            {
                                realData = new RealData(data);
                                buffer.Clear();
                            }
                            else if (ValidImaginaryData(buffer))
                            {
                                ImaginaryData imgData = new ImaginaryData(data);

                                // If a Real data has already been set
                                // Create a sample and add it to the list
                                //if (realData != null && imgData.BoardId <= 1)
                                if (realData != null)
                                {
                                    samples.Add(new Sample() { RealDataSample = realData, ImaginaryDataSample = imgData });
                                }

                                // Reset values
                                buffer.Clear();
                                realData = null;
                            }
                            else
                            {
                                buffer.RemoveAt(0);
                                realData = null;
                            }
                        }
                    }
                }
            }

            return samples;
        }
Esempio n. 32
0
 public override double PredictValue(RealData.StockHistory stockHistory, int today, int daysInFuture)
 {
     throw new NotImplementedException();
 }
Esempio n. 33
0
 public override double PredictValue(RealData.StockHistory stockHistory, int today, int daysInFuture)
 {
     double change = -Math.Log(random.NextDouble());
     return stockHistory.Closes[today] * change;
 }