public override Task <CustomSocketAmperage> FuzzyGetAmperageCircuitByParams(FuzzySocketRequest request,
                                                                                    ServerCallContext context)
        {
            DebugWrite($"RpcCall 'FuzzyGetAmperageCircuitByParams': '{request}' from {context.Peer}");

            var socketAmperage = new CustomSocketAmperage();

            switch (request.Method)
            {
            case FuzzyMethod.Mamdani:
                socketAmperage.AmperageCircuit =
                    _fuzzyProcessor.MamdaniProcessing(SocketParamsToFactSet(request.Socket));
                break;

            case FuzzyMethod.Sugeno:
                socketAmperage.AmperageCircuit =
                    _fuzzyProcessor.SugenoProcessing(SocketParamsToFactSet(request.Socket));
                break;

            case FuzzyMethod.Neural:
                socketAmperage.AmperageCircuit =
                    _neuralProcessor.Process(SocketParamsToFactSet(request.Socket));
                break;

            default:
                throw new RpcException(new Status(StatusCode.FailedPrecondition,
                                                  $"Method must be one of '{FuzzyMethod.Mamdani}', '{FuzzyMethod.Sugeno}', '{FuzzyMethod.Neural}'"
                                                  ));
            }

            return(Task.FromResult(socketAmperage));
        }
示例#2
0
        public void SugenoProcessing_IsCorrect()
        {
            var factSet = new FactSet(
                new Fact(SocketDomain.NumberOfContacts, 50),
                new Fact(SocketDomain.SizeLength, 0.03f),
                new Fact(SocketDomain.SizeWidth, 0.0075f)
                );
            var result = _processor.SugenoProcessing(factSet);

            _output.WriteLine($"SugenoProcessing for {factSet}: {result}");
            Assert.True(result > 45 && result < 110);
        }