Beispiel #1
0
    private void insertVision(GameObject go, DateTime dt)
    {
        CartesianPos     cPos      = new CartesianPos(go.transform.position.x, go.transform.position.y, go.transform.position.z);
        VisionProperties auxVision = go.GetComponent <VisionProperties>();
        Status           auxStatus = go.GetComponent <Status>();
        RGBValue         rgb;

        OntSenseCSharpAPI.Material material = OntSenseCSharpAPI.Material.unknownMaterial;
        PhysicalState state = PhysicalState.noneState;
        string        tag   = go.tag;
        string        uri   = "";

        if (auxStatus != null)
        {
            state = auxStatus.getStatus();
        }
        if (auxVision != null)
        {
            rgb      = auxVision.getRGB();
            material = auxVision.getMaterial();
            if (auxVision == vision)
            {
                tag = "SelfRobot";
            }
            uri = auxVision.getURI();
        }
        else
        {
            rgb = new RGBValue(0, 0, 0);
        }
        EmotionalState emotion    = EmotionalState.neutralEmotion;
        EmotionStatus  auxEmotion = go.GetComponent <EmotionStatus>();

        if (auxEmotion != null)
        {
            emotion = auxEmotion.getEmotion();
        }
        RobotVision rv;

        switch (go.tag)
        {
        case Constants.TAG_ROBOT:
            Robot auxRobot = new Robot(uIDD.getID(go), go.name, tag, rgb, cPos, state, material, uri);
            rv = new RobotVision(dt, auxRobot);
            break;

        case Constants.TAG_HUMAN:
            Human auxHuman = new Human(uIDD.getID(go), go.name, tag, rgb, cPos, state, material, uri, emotion);
            rv = new RobotVision(dt, auxHuman);
            break;

        default:
            Thing auxThing = new Thing(uIDD.getID(go), go.name, tag, rgb, cPos, state, material, uri);
            rv = new RobotVision(dt, auxThing);
            break;
        }
        try                                    // Try to access a resource.
        {
            rv.insert();                       // using dotNetRDF library inserts the information in the triple store
        }
        catch (Exception e)
        {
            Debug.Log("System>>> " + e.Message);                  // change for your: LogError(e);     // Call a custom error logging procedure.
        }
    }