예제 #1
0
        public IHttpActionResult Status()
        {
            InverterStatusResponse response = new InverterStatusResponse();
            IEngine engine = new TestEngine();

            NumericValue currentValue;
            NumericValue frequencyValue;
            NumericValue voltageValue;

            ConstantValue <EngineModel>  model;
            ConstantValue <EngineStatus> status;

            EngineOperationResult currentResult = engine.GetCurrentValue();

            if (currentResult.isSuccessful())
            {
                currentValue     = (NumericValue)currentResult.GetOutput();
                response.Current = currentValue.value;
            }

            EngineOperationResult voltageResult = engine.GetVoltageValue();

            if (voltageResult.isSuccessful())
            {
                voltageValue     = (NumericValue)voltageResult.GetOutput();
                response.Voltage = voltageValue.value;
            }

            EngineOperationResult frequencyResult = engine.GetFrequencyValue();

            if (frequencyResult.isSuccessful())
            {
                frequencyValue     = (NumericValue)frequencyResult.GetOutput();
                response.Frequency = frequencyValue.value;
            }

            EngineOperationResult modelResult = engine.GetInverterModel();

            if (modelResult.isSuccessful())
            {
                model = (ConstantValue <EngineModel>)modelResult.GetOutput();
                response.EngineModel = model.constant.Model;
            }

            EngineOperationResult statusResult = engine.GetStatus();

            if (statusResult.isSuccessful())
            {
                status = (ConstantValue <EngineStatus>)statusResult.GetOutput();
                response.EngineStatus = status.constant.Status;
            }

            return(Ok(response));
        }
예제 #2
0
        public IHttpActionResult Status()
        {
            try {
                InverterStatusResponse response = new InverterStatusResponse();
                IEngine engine = new TestEngine();

                NumericValue currentValue;
                NumericValue frequencyValue;
                NumericValue voltageValue;


                EngineOperationResult currentResult = engine.GetCurrentValue();
                if (currentResult.isSuccessful())
                {
                    currentValue     = (NumericValue)currentResult.GetOutput();
                    response.Current = currentValue.value;
                }

                EngineOperationResult voltageResult = engine.GetVoltageValue();
                if (voltageResult.isSuccessful())
                {
                    voltageValue     = (NumericValue)voltageResult.GetOutput();
                    response.Voltage = voltageValue.value;
                }

                EngineOperationResult frequencyResult = engine.GetFrequencyValue();
                if (frequencyResult.isSuccessful())
                {
                    frequencyValue     = (NumericValue)frequencyResult.GetOutput();
                    response.Frequency = frequencyValue.value;
                }
                return(Ok(response));
            } catch {
                return(BadRequest());
            }
        }