Ejemplo n.º 1
0
        public static void DbEventWpf(CommandVModel command, string lpszVal, DateTime lpszdateTime, AlarmType errCode, string errTxt)
        {
            if (lpszVal == null || lpszdateTime.Year < 2000)
            {
                return;
            }
            if (errCode != AlarmType.Sue)
            {
                return;
            }

            DataProcessBLL bll = new DataProcessBLL(command.Ledger, Config.Uid);
            SysPro         pro;

            NCSys.Pro.TryGetValue(command.Ledger, out pro);
            if (pro == null)
            {
                FileLog.Error("CollectAlarm.DbEventWpf 模块没有项目:" + command.Ledger);
                return;
            }
            string        mkey    = pro.ProjectKey + command.LpszDbVarName;
            CollectVModel collect = null;

            if (NCSys.Result.TryGetValue(mkey, out collect) == false)
            {
                return;
            }

            RstVar rst   = collect.RstVar;// MemcachedMgr.GetVal<RstVar>(mkey);
            bool   isAdd = true;

            if (rst != null && !string.IsNullOrEmpty(rst.lpszVal))
            {
                MalignantVModel pp = JsonHelper.Deserialize <MalignantVModel>(rst.lpszVal);
                if (collect.IsDb == false)
                {
                    if (pp.CTime == lpszdateTime)
                    {
                        isAdd = false;
                    }
                }
                collect.IsDb = false;
            }
            if (isAdd == true)
            { /*增加到数据库中*/
                bll.AddAlarmOnCollect(command.Co_id, command.Module_id, command.ModuleAddr, command.FunType, command.Fun_id, lpszVal, (int)errCode, errTxt, lpszdateTime);
            }
        }
Ejemplo n.º 2
0
        private void HandleCommand(CommandVModel command, NetworkResource Network)
        {
            if (Network == null)
            {
                FileLog.Error("ID:" + command.Module_id + "地址:" + command.ModuleAddr + "采集码:" + command.FunType + "采集ID:" + command.Fun_id + "采集名:" + command.FunName + "网络资源错误");
                return;
            }
            string msg = "";

            byte[]    send    = null, result = null;
            string    lpszVal = null;
            AlarmType errCode = AlarmType.Sue;
            bool      rst     = false;

            command.CollectTime = DateTime.Now;
            DateTime lpszdateTime = DateTime.Now;

            if (command.FunType.Equals(V0Fun.E.ToString()))/*有功总电能*/
            {
                rst = Drive.ARM(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.RdVal.ToString()))/*当前电表剩余电量*/
            {
                rst = Drive.RdVal(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Ia.ToString()))/*当前电表剩余电量*/
            {
                rst = Drive.GetIa(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Ib.ToString()))
            {
                rst = Drive.GetIb(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Ic.ToString()))
            {
                rst = Drive.GetIc(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Ua.ToString()))
            {
                rst = Drive.GetUa(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Ub.ToString()))
            {
                rst = Drive.GetUb(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Uc.ToString()))
            {
                rst = Drive.GetUc(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Psum.ToString()))
            {
                rst = Drive.GetPsum(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Pa.ToString()))
            {
                rst = Drive.GetPa(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Pb.ToString()))
            {
                rst = Drive.GetPb(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Pc.ToString()))
            {
                rst = Drive.GetPc(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Qsum.ToString()))
            {
                rst = Drive.GetQsum(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Qa.ToString()))
            {
                rst = Drive.GetQa(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Qb.ToString()))
            {
                rst = Drive.GetQb(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Qc.ToString()))
            {
                rst = Drive.GetQc(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Pfav.ToString()))
            {
                rst = Drive.GetPfav(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.PFa.ToString()))
            {
                rst = Drive.GetPFa(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.PFb.ToString()))
            {
                rst = Drive.GetPFb(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.PFc.ToString()))
            {
                rst = Drive.GetPFc(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Ssr.ToString()) && string.IsNullOrEmpty(command.DataValue))/*拉合闸状态*/
            {
                rst = Drive.Ssr(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Ssr.ToString()) && CommFunc.ConvertDBNullToInt32(command.DataValue) == 0)/*合闸*/
            {
                rst = Drive.Ssr0(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Ssr.ToString()) && CommFunc.ConvertDBNullToInt32(command.DataValue) == 1)/*拉闸*/
            {
                rst = Drive.Ssr1(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Pay.ToString()))/*充值*/
            {
                rst = Drive.Pay(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Refund.ToString()))/*退费*/
            {
                rst = Drive.Refund(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.PaySb1.ToString()))/*充值*/
            {
                rst = Drive.PaySb1(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.PaySb2.ToString()))/*充值*/
            {
                rst = Drive.PaySb2(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.IsPaul.ToString()) && string.IsNullOrEmpty(command.DataValue))/*保电状态*/
            {
                rst = Drive.SetPaul(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.IsPaul.ToString()) && !string.IsNullOrEmpty(command.DataValue))/*保电设置*/
            {
                rst = Drive.SetPaul(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Nrp.ToString()))/*有功功率负荷限值(kW)*/
            {
                rst = Drive.SetNrp(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.McNrp.ToString()))/*恶性负载判定有功功率增量(kW)(瞬时额定功率)*/
            {
                rst = Drive.SetMcNrp(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Wpf.ToString()))/*恶性负载判定无功功率(kW)*/
            {
                rst = Drive.SetWpf(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Uep.ToString()))/*违规用电判定功能的功率下限(kW)*/
            {
                rst = Drive.SetUep(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Miss.ToString()))/*一天内违规断电次数限值(0~255)*/
            {
                rst = Drive.SetMiss(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Rest.ToString()))/*违规断电后重启时间(S)*/
            {
                rst = Drive.SetRest(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Saf.ToString()))/*单次功率增量限值(kW)*/
            {
                rst = Drive.SetSaf(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Avlm.ToString()))/*过流门限值(A)*/
            {
                rst = Drive.SetAvlm(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Phase.ToString()))/*启用移相器监测功率下限(kW)*/
            {
                rst = Drive.SetPhase(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.Resist.ToString()))/*设置阻行负载(kW)*/
            {
                rst = Drive.SetResist(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.IsPhase.ToString()))/*移相器(=1启用)*/
            {
                rst = Drive.SetIsPhase(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.IsRelay.ToString()))/*继电器参数(=0电平式A路继电器设置;=1电平式B路继电器设置;=127脉冲式设置)*/
            {
                rst = Drive.SetIsRelay(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.IsStdby.ToString()))/*待机检测=0 不检测 =1 检测*/
            {
                rst = Drive.SetStandby(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Equals(V0Fun.TiVal.ToString()))/*获取定时断送电表*/
            {
                rst = Drive.SetTiVal(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.ToLower().Length == 5 && command.FunType.ToLower().Contains("leak") && CommFunc.ConvertDBNullToInt32(command.FunType.Substring(command.FunType.Length - 1, 1)) > 0)/*漏电流*/
            {
                rst = Drive.GetMeterLeak(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.ToLower().Length == 5 && command.FunType.ToLower().Contains("temp") && CommFunc.ConvertDBNullToInt32(command.FunType.Substring(command.FunType.Length - 1, 1)) > 0)/*漏电流*/
            {
                rst = Drive.GetMeterTemp(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.ToLower().Length == 8 && command.FunType.ToLower().Contains("maxleak") && CommFunc.ConvertDBNullToInt32(command.FunType.Substring(command.FunType.Length - 1, 1)) > 0)/*电流阀值*/
            {
                rst = Drive.SetMaxLeak(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.ToLower().Length == 8 && command.FunType.ToLower().Contains("maxtemp") && CommFunc.ConvertDBNullToInt32(command.FunType.Substring(command.FunType.Length - 1, 1)) > 0)/*温度阀值*/
            {
                rst = Drive.SetMaxTemp(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.ToLower().Length >= 8 && command.FunType.ToLower().Contains("StatusLeak".ToLower()) && CommFunc.ConvertDBNullToInt32(command.FunType.Substring(command.FunType.Length - 1, 1)) > 0)/*电流使能*/
            {
                rst = Drive.SetStatusLeak(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.ToLower().Length >= 8 && command.FunType.ToLower().Contains("StatusTemp".ToLower()) && CommFunc.ConvertDBNullToInt32(command.FunType.Substring(command.FunType.Length - 1, 1)) > 0)/*温度使能*/
            {
                rst = Drive.SetStatusTemp(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }
            else if (command.FunType.Contains(V0Fun.LeakAlarm.ToString()))/*漏电设备告警*/
            {
                rst = Drive.GetLeakAlarm(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }

            else if (command.FunType.Equals(V0Fun.Alarm1.ToString()))/*获取报警电量1限值*/
            {
                rst = Drive.GetAlarm1(command, Network, out send, out result, out lpszVal, out errCode, out msg);
            }


            else if (command.FunType.Equals(V0Fun.EventWpf.ToString()))/*记录恶性负载事件*/
            {
                #region 记录恶性负载事件
                Dictionary <string, string> list = new Dictionary <string, string>();
                rst = Drive.GetEventWpf(command, Network, out send, out result, out list, out errCode, out msg);
                if (rst == true)
                {
                    MalignantVModel mv = new MalignantVModel();
                    mv.CTime = new DateTime(1900, 1, 1);
                    foreach (var item in list)
                    {
                        if (item.Key.Equals("CTime"))
                        {
                            mv.CTime = CommFunc.ConvertDBNullToDateTime(item.Value);
                        }
                        else if (item.Key.Equals("SsrS"))
                        {
                            mv.Status = item.Value;
                        }
                        else if (item.Key.Equals("Ua"))
                        {
                            mv.Ua = CommFunc.ConvertDBNullToDecimal(item.Value);
                        }
                        else if (item.Key.Equals("Ia"))
                        {
                            mv.Ia = CommFunc.ConvertDBNullToDecimal(item.Value);
                        }
                        else if (item.Key.Equals("Psum1"))
                        {
                            mv.Psum1 = CommFunc.ConvertDBNullToDecimal(item.Value);
                        }
                        else if (item.Key.Equals("Psum2"))
                        {
                            mv.Psum2 = CommFunc.ConvertDBNullToDecimal(item.Value);
                        }
                        else if (item.Key.Equals("Psum3"))
                        {
                            mv.Psum3 = CommFunc.ConvertDBNullToDecimal(item.Value);
                        }
                        else if (item.Key.Equals("Psum4"))
                        {
                            mv.Psum4 = CommFunc.ConvertDBNullToDecimal(item.Value);
                        }
                    }
                    lpszVal      = null;
                    lpszdateTime = mv.CTime;
                    if (mv.CTime.Year != 1900)
                    {
                        lpszVal      = JsonHelper.Serialize(mv);
                        lpszdateTime = mv.CTime;
                    }
                }
                #endregion
            }
            else
            {
                errCode = AlarmType.Err_Nd;
            }

            try
            {
                DataProcess.YdProcess.Helper.YdDriveSaveCollectCache(command, lpszVal, lpszdateTime, 0, rst, errCode, msg, send, result);
            }
            catch (Exception ex)
            {
                FileLog.Error("处理ID号:" + this.HandledBY + "处理采集数据错误:" + ex.Message + ex.StackTrace);
            }
        }