コード例 #1
0
ファイル: Fact.cs プロジェクト: UFrameIT/LoViWo
    public CogwheelEqsysFact(int i, int[] ids)
    {
        this.Id          = i;
        this.CogwheelIds = ids;

        List <MMTTerm> typeArguments = new List <MMTTerm>
        {
            new OMS(MMTURIs.Prop)
        };

        List <int>     cogwheelIdList = new List <int>(this.CogwheelIds);
        List <MMTTerm> listArguments  = new List <MMTTerm>();

        cogwheelIdList
        .Select(cogwheelId =>
                new OMS((GameState.Facts.Find(x => x.Id == cogwheelId) as CogwheelFact).backendURI))
        .ToList()
        .ForEach(oms => listArguments.Add(oms));

        List <MMTTerm> eqsysArguments = new List <MMTTerm>
        {
            new OMA(new OMS(MMTURIs.ListOf), listArguments)
        };

        MMTTerm tp = new OMA(new OMS(MMTURIs.List), typeArguments);
        MMTTerm df = new OMA(new OMS(MMTURIs.CogwheelEquationSystem), eqsysArguments);

        MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);
        string body = MMTSymbolDeclaration.ToJson(mmtDecl);

        AddFactResponse res = AddFactResponse.sendAdd(GameSettings.ServerAdress + "/fact/add", body);

        this.backendURI = res.uri;
        Debug.Log(this.backendURI);
    }
コード例 #2
0
    private void init(string pid1, string pid2, string pid3)
    {
        this.Pid1 = pid1;
        this.Pid2 = pid2;
        this.Pid3 = pid3;

        PointFact pf1 = _Facts[pid1] as PointFact;
        PointFact pf2 = _Facts[pid2] as PointFact;
        PointFact pf3 = _Facts[pid3] as PointFact;

        float v = GetAngle(); // sets is_right_angle

        MMTDeclaration mmtDecl;
        string         p1URI = pf1.Id;
        string         p2URI = pf2.Id;
        string         p3URI = pf3.Id;

        if (is_right_angle)
        {
            mmtDecl = generate90DegreeAngleDeclaration(v, p1URI, p2URI, p3URI);
        }
        else
        {
            mmtDecl = generateNot90DegreeAngleDeclaration(v, p1URI, p2URI, p3URI);
        }

        AddFactResponse.sendAdd(mmtDecl, out this._URI);
    }
コード例 #3
0
ファイル: Fact.cs プロジェクト: UFrameIT/LoViWo
    public CogwheelFact(int i, Vector3 P, Vector3 N, float R, float iR, float oR)
    {
        this.Id            = i;
        this.Point         = P;
        this.Normal        = N;
        this.Radius        = R;
        this.InsideRadius  = iR;
        this.OutsideRadius = oR;

        List <MMTTerm> tupleArguments = new List <MMTTerm>
        {
            new OMF(P.x),
            new OMF(P.y),
            new OMF(P.z)
        };

        List <MMTTerm> wheelOfArguments = new List <MMTTerm>
        {
            new OMF(this.Radius),
            new OMF(this.InsideRadius),
            new OMF(this.OutsideRadius),
            new OMA(new OMS(MMTURIs.Tuple), tupleArguments)
        };

        MMTTerm tp = new OMS(MMTURIs.Cogwheel);
        MMTTerm df = new OMA(new OMS(MMTURIs.CogwheelOf), wheelOfArguments);

        MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);
        string body = MMTSymbolDeclaration.ToJson(mmtDecl);

        AddFactResponse res = AddFactResponse.sendAdd(GameSettings.ServerAdress + "/fact/add", body);

        this.backendURI = res.uri;
        Debug.Log(this.backendURI);
    }
コード例 #4
0
    private void init(string pid, string rid)
    {
        this.Pid = pid;
        this.Rid = rid;

        PointFact pf   = _Facts[pid] as PointFact;
        RayFact   rf   = _Facts[rid] as RayFact;
        string    pURI = pf.Id;
        string    rURI = rf.Id;

        List <MMTTerm> innerArguments = new List <MMTTerm>
        {
            new OMS(rURI),
            new OMS(pURI)
        };

        List <MMTTerm> outerArguments = new List <MMTTerm>
        {
            new OMA(new OMS(MMTURIs.OnLine), innerArguments)
        };

        //OMS constructor generates full URI
        MMTTerm tp = new OMA(new OMS(MMTURIs.Ded), outerArguments);
        MMTTerm df = null;

        MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);

        AddFactResponse.sendAdd(mmtDecl, out this._URI);
    }
コード例 #5
0
    private void init(string pid1, string pid2)
    {
        SetDistance();

        PointFact pf1 = _Facts[pid1] as PointFact;
        PointFact pf2 = _Facts[pid2] as PointFact;

        string p1URI = pf1.Id;
        string p2URI = pf2.Id;
        float  v     = (pf1.Point - pf2.Point).magnitude;

        MMTTerm lhs =
            new OMA(
                new OMS(MMTURIs.Metric),
                new List <MMTTerm> {
            new OMS(p1URI),
            new OMS(p2URI)
        }
                );

        MMTTerm valueTp = new OMS(MMTURIs.RealLit);
        MMTTerm value   = new OMF(v);

        //see point label
        MMTValueDeclaration mmtDecl = new MMTValueDeclaration(this.Label, lhs, valueTp, value);

        AddFactResponse.sendAdd(mmtDecl, out this._URI);
    }
コード例 #6
0
    public static bool sendAdd(string path, string body, out string uri)
    {
        if (!CommunicationEvents.ServerRunning)
        {
            Debug.LogWarning("Server not running");
            uri = null;
            return(false);
        }

        if (VerboseURI)
        {
            Debug.Log("Sending to Server:\n" + body);
        }

        //Put constructor parses stringbody to byteArray internally  (goofy workaround)
        UnityWebRequest www = UnityWebRequest.Put(path, body);

        www.method = UnityWebRequest.kHttpVerbPOST;
        www.SetRequestHeader("Content-Type", "application/json");
        www.timeout = 1;

        //TODO: implement real asynchronous communication ...
        AsyncOperation op = www.SendWebRequest();

        while (!op.isDone)
        {
            ;
        }

        if (www.result == UnityWebRequest.Result.ConnectionError ||
            www.result == UnityWebRequest.Result.ProtocolError)
        {
            Debug.LogWarning(www.error);
            uri = null;
            return(false);
        }
        else
        {
            string          answer = www.downloadHandler.text;
            AddFactResponse res    = JsonUtility.FromJson <AddFactResponse>(answer);

            if (VerboseURI)
            {
                Debug.Log("Server added Fact:\n" + res.uri);
            }

            uri = res.uri;
            return(true);
        }
    }
コード例 #7
0
    private void init(Vector3 P, Vector3 N)
    {
        this.Point  = P;
        this.Normal = N;

        List <MMTTerm> arguments = new List <MMTTerm>
        {
            new OMF(P.x),
            new OMF(P.y),
            new OMF(P.z)
        };

        //OMS constructor generates full URI
        MMTTerm tp = new OMS(MMTURIs.Point);
        MMTTerm df = new OMA(new OMS(MMTURIs.Tuple), arguments);

        MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);

        AddFactResponse.sendAdd(mmtDecl, out this._URI);
    }
コード例 #8
0
    private void init(string pid1, string pid2)
    {
        PointFact pf1 = _Facts[pid1] as PointFact;
        PointFact pf2 = _Facts[pid2] as PointFact;

        string p1URI = pf1.Id;
        string p2URI = pf2.Id;

        List <MMTTerm> arguments = new List <MMTTerm>
        {
            new OMS(p1URI),
            new OMS(p2URI)
        };

        //OMS constructor generates full URI
        MMTTerm tp = new OMS(MMTURIs.LineType);
        MMTTerm df = new OMA(new OMS(MMTURIs.LineOf), arguments);

        MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);

        AddFactResponse.sendAdd(mmtDecl, out this._URI);
    }