New version in C# with complete visual studio project.

Merge request reports

Loading
+34 −0
Changes for wrapper/c#/WorldAnalysisWrapper/Access/WorldStorageServer.cs: 34 added lines, 0 removed lines.
Original line number Diff line number Diff line
//
// ARF - Augmented Reality Framework (ETSI ISG ARF)
//
// Copyright 2024 ETSI
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Last change: June 2024
//

namespace ETSI.ARF.WorldStorage
{
    public class WorldStorageServer
    {
        public string serverName = "myServerName";
        public string company = "";
        public string basePath = "https://";
        public int port = 8080;

        public WorldStorageUser currentUser = null;

        public string URI => port == 0 ? basePath : basePath + ":" + port.ToString();
    }
}
 No newline at end of file
+29 −0
Changes for wrapper/c#/WorldAnalysisWrapper/Access/WorldStorageUser.cs: 29 added lines, 0 removed lines.
Original line number Diff line number Diff line
//
// ARF - Augmented Reality Framework (ETSI ISG ARF)
//
// Copyright 2024 ETSI
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Last change: June 2024
//

namespace ETSI.ARF.WorldStorage
{
    public class WorldStorageUser
    {
        public string userName = "myName";
        public string company = "";
        public string UUID = System.Guid.Empty.ToString();
    }
}
 No newline at end of file
+38 −0
Changes for wrapper/c#/WorldAnalysisWrapper/OpenAPI/WorldAnalysis/BaseClient.cs: 38 added lines, 0 removed lines.
Original line number Diff line number Diff line
using System;
using System.Collections;
using System.Collections.Generic;

namespace ETSI.ARF.OpenAPI.WorldAnalysis
{
    /// <summary>
    /// Simple class to debug the requests
    /// </summary>
    public class BaseClient
    {
        static public bool EnableClientLog = true;
        public string lastJsonText;
        public long lastPayload;

        protected void _prepareRequest(ETSI.ARF.OpenAPI.WorldAnalysis.IHttpClient client, System.Net.Http.HttpRequestMessage request, string url)
        {
            if (EnableClientLog)
            {
                Console.WriteLine("[REST][URL] Send request: " + client.BaseAddress + url);
                Console.WriteLine("[REST][URL] Send request: " + request);
            }
        }

        protected void _processResponse(ETSI.ARF.OpenAPI.WorldAnalysis.IHttpClient client, System.Net.Http.HttpResponseMessage response)
        {
            lastJsonText = response.Content.ReadAsStringAsync().Result.ToString();
            lastPayload = response.Content.Headers.ContentLength.Value;

            var status_ = (int)response.StatusCode;

            if (EnableClientLog)
            {
                Console.WriteLine("[REST][Data] Status: " + status_ + " Response: " + client.BaseAddress + " Len: " + lastPayload + " JSON: " + lastJsonText);
            }
        }
    }
}
 No newline at end of file
+56 −0
Changes for wrapper/c#/WorldAnalysisWrapper/OpenAPI/WorldAnalysis/DataModels.cs: 56 added lines, 0 removed lines.
Original line number Diff line number Diff line
using System;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using Newtonsoft.Json;

namespace ETSI.ARF.OpenAPI.WorldAnalysis
{
    public interface IModel
    {
        public System.Guid Uuid { get; set; }  // Bug: SylR: Why is Uuid not capitalized (UUID)???

        public string ToJson();
    }

    // Class to monitor the server
    public class Server : IModel
    {
        public System.Guid Uuid { get; set; }
        public string Name { get; set; }

        public Server(string name)
        {
            Uuid = Guid.Empty;
            Name = name;
        }

        public string ToJson() { return JsonConvert.SerializeObject(this); }
    }

    //
    // Implement here some constructors
    //
    public partial class Pose : IModel
    {
        public Pose()
        {
            Uuid = Guid.NewGuid();
        }

        public string ToJson() { return JsonConvert.SerializeObject(this); }
    }

    public partial class Transform3D
    {
        public Matrix4x4 Matrix()
        {
            return new Matrix4x4(
                this[0], this[1], this[2], this[3],
                this[4], this[5], this[6], this[7],
                this[8], this[9], this[10], this[11],
                this[12], this[13], this[14], this[15]
            );
        }
    }
}
 No newline at end of file
+64 −0
Changes for wrapper/c#/WorldAnalysisWrapper/OpenAPI/WorldAnalysis/ResponseObject.cs: 64 added lines, 0 removed lines.
Original line number Diff line number Diff line
// The Fraunhofer HHI Unity Framework
//  ___________                          .__            _____                ___ ___    ___ ___ .___ 
//  \_   _____/___________   __ __  ____ |  |__   _____/ ____\___________   /   |   \  /   |   \|   |
//   |    __) \_  __ \__  \ |  |  \/    \|  |  \ /  _ \   __\/ __ \_  __ \ /    ~    \/    ~    \   |
//   |     \   |  | \// __ \|  |  /   |  \   Y  (  <_> )  | \  ___/|  | \/ \    Y    /\    Y    /   |
//   \___  /   |__|  (____  /____/|___|  /___|  /\____/|__|  \___  >__|     \___|_  /  \___|_  /|___|
//       \/               \/           \/     \/                 \/               \/         \/      
// (C) Fraunhofer HHI, 2024

using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;

namespace ETSI.ARF.OpenAPI.WorldAnalysis
{
    public class CancelToken
    {
        protected CancellationTokenSource tokenSource;
        protected CancellationToken ct;

        public CancellationToken cancellationToken { get => ct; }

        public void Cancel()
        {
            tokenSource.Cancel();
        }
    }

    public class ResponseObject<T> : CancelToken
    {
        // Management stuffs
        static int ID = 0;
        public int transactionId = 0;
        public string message = "";     // custom message, type of data...

        // Time monitoring
        public TimeSpan DeltaTime { get => responseTime - requestTime; }
        public DateTime requestTime;
        public DateTime responseTime;

        // Incoming data
        public T result;
        public int payload;   // size of data

        //public string result = "";      // text result
        //public object data = null;      // custom result

        // Callback
        public Action<ResponseObject<T>> callback;


        public ResponseObject(string msg, Action<ResponseObject<T>> func = null)
        {
            requestTime = DateTime.Now;
            message = msg;
            callback = func;
            transactionId = ++ID;

            tokenSource = new CancellationTokenSource();
            ct = tokenSource.Token;
        }
    }
}
 No newline at end of file
Loading
Loading