From c0f9915265878e56e91ee97f7f8d925db1e12626 Mon Sep 17 00:00:00 2001 From: cloudflight <cloudflight@126.com> Date: 星期六, 02 十二月 2023 18:50:45 +0800 Subject: [PATCH] 2023年12月2日_3 --- Hydro.CommonBase/ParamModel.cs | 123 ++++++++++++++++++++++++++++++---------- 1 files changed, 92 insertions(+), 31 deletions(-) diff --git a/Hydro.CommonBase/ParamModel.cs b/Hydro.CommonBase/ParamModel.cs index ee15375..2e3b0e5 100644 --- a/Hydro.CommonBase/ParamModel.cs +++ b/Hydro.CommonBase/ParamModel.cs @@ -11,7 +11,8 @@ //using NPOI.SS.Formula.Eval; using System.Runtime.Serialization; using Newtonsoft.Json; -using Hydro.Core.Model; +using System.Collections.Concurrent; +using Dapper; namespace CommonBase { @@ -25,6 +26,23 @@ Count++; } + public GeneticParams(string ConfigPath, GeneticParams gParam) + { + if (gParam == null) gParam = new GeneticParams(0); + this.Level = gParam.Level; + this.ID = gParam.ID; + if (gParam.Db == null) gParam.Db = new Db(); + if (!string.IsNullOrEmpty(ConfigPath)) gParam.Db.Init(ConfigPath); + this.Db = gParam.Db; + if (gParam.Quene!=null) gParam.Quene.Dispose(); + gParam.Quene = new Quene(); + this.Quene= gParam.Quene; + //鑾峰彇鍏ㄥ眬榛樿璁剧疆 + var globalConfig = gParam.Db.Connection.QueryFirstOrDefault<string>("SELECT FValue FROM MyConfig WHERE FKey='GlobalConfig'"); + gParam.GlobalConfig = JsonConvert.DeserializeObject<GlobalConfig>(globalConfig) ?? new GlobalConfig(); + this.GlobalConfig = gParam.GlobalConfig; + //return gParam; + } public void Dispose() { onReportProgress = null; @@ -60,14 +78,14 @@ public int num; public double BestOptValue; - public DoubleRange tolerance; + public MyDoubleRange tolerance; public FinishEvent onFinished; public FinishEvent onError; public FinishEvent onReportProgress; public SetEvent setVars; public Db Db; - //public SolutionDBHelper SolutionDBHelper = null; + public dynamic SolutionDBHelper = null; public GlobalConfig GlobalConfig; public Quene Quene; public int Level; @@ -143,6 +161,46 @@ public DateTime ScadaTime; public List<TimePoint> TimePoints; public double BestResult=double.MaxValue; + public void Dispose() + { + if (RequestQueues != null) + { + RequestQueues.Clear(); + RequestQueues = null; + } + if (RequestFinished != null) + { + RequestFinished.Clear(); + RequestFinished = null; + } + + if (ResultHash != null) + { + ResultHash.Clear(); + ResultHash = null; + } + if (ResultDictionary != null) + { + ResultDictionary.Clear(); + ResultDictionary = null; + } + if (ResultChrome != null) + { + ResultChrome.Clear(); + ResultChrome = null; + } + if (MissionQuene != null) + { + MissionQuene.Clear(); + MissionQuene = null; + } + if (TimePoints != null) + { + TimePoints.Clear(); + TimePoints = null; + } + + } } [Serializable] @@ -155,6 +213,8 @@ public Guid ID; public List<TimePoint> ScadaPoints { get; set; } = new List<TimePoint>(); + + public ConcurrentDictionary<string, TimePoint> dict_Scada_key = null; public List<TimePoint> ConfigPoints { get; set; } = new List<TimePoint>(); public List<TimePoint> ResultPoints { get; set; } = new List<TimePoint>(); public double Fitness = -1; @@ -303,39 +363,39 @@ } } - //[Serializable] + [Serializable] - //public class TimePoint - //{ - // public TimePoint() - // { + public class TimePoint + { + public TimePoint() + { - // } - // public TimePoint(string key, double value) - // { - // Key = key; - // Value = value; - // } + } + public TimePoint(string key, double value) + { + Key = key; + Value = value; + } - // public string Name; - // public DateTime ValueTime { get; set; } - // public string Key { get; set; } - // public double Value { get; set; } - // public double[] Pattern { get; set; } = null; - // public string ModelObjectID { get; set; } - // public SettingCalcType CType { get; set; } = SettingCalcType.Add; + public string Name; + public DateTime ValueTime { get; set; } + public string Key { get; set; } + public double Value { get; set; } + public double[] Pattern { get; set; } = null; + public string ModelObjectID { get; set; } + public SettingCalcType CType { get; set; } = SettingCalcType.Add; - // public double SearchRange = 0; + public double SearchRange = 0; - // public bool isNeedtoSave = false; + public bool isNeedtoSave = false; - // public string SaveKey = null; + public string SaveKey = null; - // public override string ToString() - // { - // return $"{Name}\t[{Key}]\t{Value}"; - // } - //} + public override string ToString() + { + return $"{Name}\t[{Key}]\t{Value}"; + } + } [Serializable] @@ -416,7 +476,7 @@ public Dictionary<string, variable> dict_Name; public Dictionary<int, variable> dict_ID; - public string inputFileString; + //public string inputFileString; public void buildDict() { @@ -784,12 +844,13 @@ public class OBJFunction { public string Text_origin; + public string Text_change; public string Text; public string ExpressType; public string Name; public double value; - public DoubleRange tolerance; + public MyDoubleRange tolerance; public variable variable; public List<variable> paramVariables; public List<double> paramValues; -- Gitblit v1.9.3