//---------------------------------------------

    void Start()
    {
        patternArchiveList = new List <Archive>();

        // streamingAssetsPath = Application.streamingAssetsPath + "/";
        streamingAssetsPath = "http://jojo-studio.de/Projekte/NeuralNetwork/StreamingAssets/";


        netWorkInit  = GetComponent <NetworkInit>();
        sensorField  = GetComponent <SensorField>();
        learnManager = GetComponent <LearnManager>();

        StartCoroutine(LoadNetworkFromWeb());
        ///StartCoroutine(LoadPatternArchive("ExercisePattern"));
        //StartCoroutine(LoadPatternArchive("TestPattern"));
        StartCoroutine(WaitForLoadingFiles());
    }
    //-----------------------------------------------------

    private void Start()
    {
        //Button btn = button.GetComponent<Button>();
        // btn.onClick.AddListener(NewNetwork);

        networkStructure = new List <int> {
            400, 20, 10
        };

        sensorField  = GetComponent <SensorField>();
        learnManager = GetComponent <LearnManager>();
        storeManager = GetComponent <StoreManager>();

        Result zero = new Result();

        zero.iD   = 0;
        zero.name = "Null";
        zero.outputConfiguration = new List <float>()
        {
            1, 0, 0, 0, 0, 0, 0, 0, 0, 0
        };
        // zero.outputConfiguration = new List<float>() { 0 , 0, 0, 0, 0};
        Result one = new Result();

        one.iD   = 1;
        one.name = "Eins";
        one.outputConfiguration = new List <float>()
        {
            0, 1, 0, 0, 0, 0, 0, 0, 0, 0
        };
        //one.outputConfiguration = new List<float>() { 1 , 0, 0, 0, 0};
        Result two = new Result();

        two.iD   = 2;
        two.name = "Zwei";
        two.outputConfiguration = new List <float>()
        {
            0, 0, 1, 0, 0, 0, 0, 0, 0, 0
        };
        // two.outputConfiguration = new List<float>() { 0, 1, 0, 0, 0};

        Result three = new Result();

        three.iD   = 3;
        three.name = "Drei";
        three.outputConfiguration = new List <float>()
        {
            0, 0, 0, 1, 0, 0, 0, 0, 0, 0
        };
        //three.outputConfiguration = new List<float>() { 0 , 0, 1, 0, 0};
        Result four = new Result();

        four.iD   = 4;
        four.name = "Vier";
        four.outputConfiguration = new List <float>()
        {
            0, 0, 0, 0, 1, 0, 0, 0, 0, 0
        };
        // four.outputConfiguration = new List<float>() { 0 , 0, 0, 1, 0};
        Result five = new Result();

        five.iD   = 5;
        five.name = "Fünf";
        five.outputConfiguration = new List <float>()
        {
            0, 0, 0, 0, 0, 1, 0, 0, 0, 0
        };
        //five.outputConfiguration = new List<float>() { 0 , 0, 0, 0, 1};
        Result six = new Result();

        six.iD   = 6;
        six.name = "Sechs";
        six.outputConfiguration = new List <float>()
        {
            0, 0, 0, 0, 0, 0, 1, 0, 0, 0
        };
        //six.outputConfiguration = new List<float>() { 1 , 1, 0, 0, 0};
        Result seven = new Result();

        seven.iD   = 7;
        seven.name = "Sieben";
        seven.outputConfiguration = new List <float>()
        {
            0, 0, 0, 0, 0, 0, 0, 1, 0, 0
        };
        //seven.outputConfiguration = new List<float>() { 1 , 0, 1, 0, 0};
        Result eight = new Result();

        eight.iD   = 8;
        eight.name = "Acht";
        eight.outputConfiguration = new List <float>()
        {
            0, 0, 0, 0, 0, 0, 0, 0, 1, 0
        };
        //eight.outputConfiguration = new List<float>() { 1 , 0, 0, 1, 0};
        Result nine = new Result();

        nine.iD   = 9;
        nine.name = "Neun";
        nine.outputConfiguration = new List <float>()
        {
            0, 0, 0, 0, 0, 0, 0, 0, 0, 1
        };
        //nine.outputConfiguration = new List<float>() {1, 0, 0, 0, 1};

        expectedResults = new List <Result>()
        {
            zero, one, two, three, four, five, six, seven, eight, nine
        };
    }
Beispiel #3
0
        // POST: api/Readings
        public IHttpActionResult Post([FromBody] SensorData reading)
        {
            Sensor      sensor;
            Location    readingLocation;
            SensorField field;

            if (reading == null || (sensor = Sensor.GetById(reading.SensorId)) == null)
            {
                return(this.Content(HttpStatusCode.BadRequest, new ApiError("Invalid sensor")));
            }
            if (sensor.LocationId == null && (readingLocation = Location.GetById(reading.LocationId)) == null)
            {
                return(this.Content(HttpStatusCode.BadRequest, new ApiError("Invalid location")));
            }
            if ((field = SensorField.GetById(reading.FieldId)) == null)
            {
                return(this.Content(HttpStatusCode.BadRequest, new ApiError("Invalid field")));
            }
            if (sensor.Id != field.SensorId)
            {
                return(this.Content(HttpStatusCode.BadRequest, new ApiError("Invalid field and sensor; the sensor doesn't have the specified field")));
            }
            if (reading.Value == null)
            {
                return(this.Content(HttpStatusCode.BadRequest, new ApiError("Value is required")));
            }

            switch (field.Type)
            {
            case "float":
                float valueF;
                if (!float.TryParse(reading.Value, out valueF))
                {
                    return(this.Content(HttpStatusCode.BadRequest, new ApiError("Invalid value; the provided value can't be casted to the correct type")));
                }
                reading.Value = valueF.ToString();

                if (field.MinValue != null && valueF < float.Parse(field.MinValue))
                {
                    return(this.Content(HttpStatusCode.BadRequest, new ApiError("Invalid value; the provided value is not in the field range")));
                }
                if (field.MaxValue != null && valueF > float.Parse(field.MaxValue))
                {
                    return(this.Content(HttpStatusCode.BadRequest, new ApiError("Invalid value; the provided value is not in the field range")));
                }

                break;

            case "int":
                int valueI;
                if (!int.TryParse(reading.Value, out valueI))
                {
                    return(this.Content(HttpStatusCode.BadRequest, new ApiError("Invalid value; the provided value can't be casted to the correct type")));
                }
                reading.Value = valueI.ToString();

                if (field.MinValue != null && valueI < int.Parse(field.MinValue))
                {
                    return(this.Content(HttpStatusCode.BadRequest, new ApiError("Invalid value; the provided value is not in the field range")));
                }
                if (field.MaxValue != null && valueI > int.Parse(field.MaxValue))
                {
                    return(this.Content(HttpStatusCode.BadRequest, new ApiError("Invalid value; the provided value is not in the field range")));
                }

                break;

            case "bool":
                bool valueB;
                if (!bool.TryParse(reading.Value, out valueB))
                {
                    return(this.Content(HttpStatusCode.BadRequest, new ApiError("Invalid value; the provided value can't be casted to the correct type")));
                }
                reading.Value = valueB.ToString();
                break;
            }

            reading.Insert();

            return(Created("/readings/" + reading.Id, reading));
        }
 void Start()
 {
     networkInit  = GetComponent <NetworkInit>();
     sensorField  = GetComponent <SensorField>();
     storeManager = GetComponent <StoreManager>();
 }