Exemplo n.º 1
0
 public FuzzyReasoning(FuzzyParameter rainParam, FuzzyParameter temperatureParam, FuzzyParameter fogParam /*, FuzzyParameter darknessParam*/, FuzzyParameter resultParam)
 {
     _rainParam        = rainParam;
     _temperatureParam = temperatureParam;
     _fogParam         = fogParam;
     // _darknessParam = darknessParam;
     _resultParam = resultParam;
 }
Exemplo n.º 2
0
        private async Task <string> Reasoning(string rainInput, string temperatureInput, string fogInput /*, string darknessInput*/)
        {
            Debug.WriteLine(rainInput);
            Debug.WriteLine(fogInput);
            Debug.WriteLine(temperatureInput);
            //Debug.WriteLine(darknessInput);
            return(await Task.Run(() =>
            {
                decimal rain;
                decimal fog;
                decimal temperature;
                decimal darkness;

                if (!Decimal.TryParse(rainInput, out rain))
                {
                    return String.Empty;
                }
                if (!Decimal.TryParse(fogInput, out fog))
                {
                    return String.Empty;
                }
                if (!Decimal.TryParse(temperatureInput, out temperature))
                {
                    return String.Empty;
                }
                // if (!Decimal.TryParse(darknessInput, out darkness))
                //    return String.Empty;
                var condParameter = new FuzzyParameter
                {
                    PositiveSet = GoodCondControl.FuzzySet,
                    NegativeSet = BadCondControl.FuzzySet,
                    Dimension = CondDimension,
                };
                _fr = new FuzzyReasoning(RainControl.Parameter, TemperatureControl.Parameter, FogControl.Parameter,
                                         /*DarknessControl.Parameter,*/ condParameter);

                var r = _fr.Work(rain, temperature, fog /*, darkness*/, (DefuzzificationFactory.DefuzzificationMethod)(Method + 1)); //,temperature,hour);
                var chart = (PictureBox)Wfh.Child;
                var imgBuyIt = new RelationImage(r.Relation, r.Inputs, r.OutputDimension);
                var bmpBuyIt = new Bitmap(chart.Width, chart.Height);
                imgBuyIt.DrawImage(Graphics.FromImage(bmpBuyIt));
                chart.Image = bmpBuyIt;
                return r.CrispValue.ToString();
            }));
        }