Exemple #1
0
 public DeviceUI6517AB(Device6517AB d, Frame fm)
     : base(d, fm)
 {
     device = d;
     DeviceInUI.PropertyChanged += new PropertyChangedEventHandler(box_PropertyChanged);
     box      = (DeviceDataBox_6517AB)DeviceInUI.Value;
     valueDic = new Dictionary <int, string>();
     valueDic.Add(0, "keep_time");
     dataSeries = new  DataSeries[valueDic.Count];
     values     = new List <string>();
     for (int i = 0; i < valueDic.Count; i++)
     {
         dataSeries[i]          = new DataSeries(); //数据系列
         dataSeries[i].Legend   = valueDic[i];
         dataSeries[i].RenderAs = RenderAs.Line;    //Spline : 平滑曲线 Line : 折线
         device_chart.Series.Add(dataSeries[i]);
     }
 }
        public Device fromBoxToDevice()
        {
            Device deviceToChange = null;

            switch (this.className())
            {
            case "DeviceDataBox_Quality":
                deviceToChange = new DeviceQuality((DeviceDataBox_Quality)this);
                break;

            case "DeviceDataBox_XH3125":
                deviceToChange = new DeviceXH31253127((DeviceDataBox_XH3125)this);
                break;

            case "DeviceDataBox_6517AB":
                deviceToChange = new Device6517AB((DeviceDataBox_6517AB)this);
                break;

            case "DeviceDataBox_JL900":
                deviceToChange = new DeviceJL900((DeviceDataJL900Box)this);
                break;

            case "DeviceDataASM02Box":
                deviceToChange = new DeviceASM02((DeviceDataASM02Box)this);
                break;

            case "DeviceDataBox_DryWet":
                deviceToChange = new DeviceDryWet((DeviceDataDryWetBox)this);
                break;

            default:
                deviceToChange = new Device(this);
                break;
            }
            return(deviceToChange);
        }
Exemple #3
0
        public void InitialData()  //初始化数据
        {
            if (Utils.isFirstIn()) //第一次进入创建数据表和sequence
            {
                initDatabase();
            }
            DBManager        dbOfDevice = new DBManager();
            string           errorCode  = "";
            int              errCode    = (int)ErrorCode.ERR_CODE.OK;
            OracleDataReader odr        = null;
            OracleDataReader odr2       = null;
            OracleDataReader odr3       = null;

            try
            {
                errCode = dbOfDevice.OpenConnection(DBHelper.db_userName, DBHelper.db_userPassWord, DBHelper.db_ip, DBHelper.db_port, DBHelper.db_name, ref errorCode);
                if (errCode != (int)ErrorCode.ERR_CODE.OK)
                {
                    LogUtil.Log(true, "数据库连接建立异常", (int)ErrorCode.ERR_CODE.CONNECTION_OPEN_ERR);
                    return;
                }
                odr = readBuidingFromDb();
                if (odr.HasRows)
                {
                    while (odr.Read()) //找所有的building
                    {
                        string   state    = WpfApplication2.package.DeviceDataBox_Base.State.Normal.ToString();
                        Building building = new Building("" + odr.GetInt32(0), odr.GetString(1), odr.GetString(2), odr.GetString(3), odr.GetFloat(4), odr.GetFloat(5), new List <Cab>(), state, odr.GetString(6));
                        Console.WriteLine(building.Name);
                        odr2 = readCabFromDb(dbOfDevice, odr);
                        if (odr2.HasRows)
                        {
                            while (odr2.Read()) //找每个building对应的cab5
                            {
                                Cab cab = new Cab("" + odr2.GetInt32(0), "" + odr2.GetInt32(1), "" + odr2.GetString(2), odr2.GetString(3), odr2.GetString(4), odr2.GetString(5), odr2.GetString(6), new List <Device>(), state);
                                odr3 = readDeviceFromDb(dbOfDevice, odr2, cab);
                                Console.WriteLine(building.Name + " :" + cab.Name);
                                while (odr3.Read())
                                {
                                    Device device = null;
                                    switch (odr3.GetString(15))
                                    {
                                    case "XH3125":
                                        device = new DeviceXH31253127(odr3);
                                        break;

                                    case "Pump":
                                        device = new DevicePump(odr3);
                                        break;

                                    case "6517AB":
                                        device = new Device6517AB(odr3);
                                        break;

                                    case "Quality":
                                        device = new DeviceQuality(odr3);
                                        break;

                                    case "DryWet":
                                        device = new DeviceDryWet(odr3);
                                        break;

                                    case "Asm02":
                                        device = new DeviceASM02(odr3);
                                        break;

                                    case "Jl900":
                                        device = new DeviceJL900(odr3);
                                        break;

                                    default:
                                        device = new Device(odr3);
                                        break;
                                    }
                                    cab.Devices.Add(device);
                                    Console.WriteLine(building.Name + " :" + cab.Name + ":" + device.Type);
                                    GlobalMapForShow.globalMapForDevice.Add(building.SystemId + "_" + device.DeviceId, device);
                                }
                                GlobalMapForShow.globalMapForCab.Add(building.SystemId + "_" + cab.CabId, cab);
                                odr3.Close();
                                building.Cabs.Add(cab);
                            }
                        }
                        odr2.Close();
                        GlobalMapForShow.globalMapForBuiding.Add(building.SystemId, building);
                    }
                }
                odr.Close();
                dbOfDevice.CloseConnection();
            }
            catch (Exception e)
            {
                LogUtil.Log(true, e.Message, (int)ErrorCode.ERR_CODE.MAP_POINTS_INIT_ERR);
            }
        }