コード例 #1
0
        /// <summary>
        /// Set the token to use when authenticating with the ARCore Cloud Anchor service
        /// on the iOS platform.  This should be called each time the application's
        /// token is refreshed.
        /// </summary>
        /// <param name="anchorManager">The ARAnchorManager instance.</param>
        /// <param name="authToken">The authentication token to set.</param>
        public static void SetAuthToken(this ARAnchorManager anchorManager, string authToken)
        {
            // Only iOS needs AuthToken for Cloud Anchor persistence.
#if ARCORE_EXTENSIONS_IOS_SUPPORT && UNITY_IOS
            if (!string.IsNullOrEmpty(RuntimeConfig.Instance.IOSCloudServicesApiKey))
            {
                Debug.LogError(
                    "Cannot set token in applications built using the 'API Key' " +
                    "authentication strategy. To use it, check Edit > Project Settings " +
                    "> XR > ARCore Extensions > iOS Support Enabled and " +
                    "set iOS Authentication Strategy to Authentication Token.");
                return;
            }

            if (string.IsNullOrEmpty(authToken))
            {
                Debug.LogError("Cannot set empty token in applications.");
                return;
            }

            SessionApi.SetAuthToken(
                ARCoreExtensions._instance.currentARCoreSessionHandle, authToken);
#else
            Debug.LogError("AuthToken only works with iOS Supported enabled in " +
                           "ARCore Extensions Project Settings and the target platform has set to iOS.");
#endif // ARCORE_IOS_SUPPORT && UNITY_IOS
        }
コード例 #2
0
        public static ARCloudReferencePoint ResolveCloudReferenceId(
            this ARAnchorManager referencePointManager,
            string cloudReferenceId)
        {
            // Create the underlying ARCore Cloud Anchor.
            IntPtr cloudAnchorHandle = SessionApi.ResolveCloudAnchor(
                ARCoreExtensions._instance.currentARCoreSessionHandle,
                cloudReferenceId);

            if (cloudAnchorHandle == IntPtr.Zero)
            {
                return(null);
            }

            // Create the GameObject that is the cloud reference point.
            ARCloudReferencePoint cloudReferencePoint =
                (new GameObject(_gameObjectName)).AddComponent <ARCloudReferencePoint>();

            if (cloudReferencePoint)
            {
                cloudReferencePoint.SetAnchorHandle(cloudAnchorHandle);
            }

            // Parent the new cloud reference point to the session origin.
            cloudReferencePoint.transform.SetParent(
                ARCoreExtensions._instance.SessionOrigin.trackablesParent, false);

            return(cloudReferencePoint);
        }
コード例 #3
0
        /// <summary>
        /// Creates a new Cloud Anchor using an existing local ARAnchor.
        /// <example>
        /// The sample code below illustrates how to host a Cloud Anchor.
        /// <pre>
        /// <code>
        /// private ARCloudAnchor _cloudAnchor;
        /// &nbsp;
        /// void HostCloudAnchor(Pose pose)
        /// {
        ///     // Create a local anchor, you may also use another ARAnchor you already have.
        ///     ARAnchor localAnchor = AnchorManager.AddAnchor(pose);
        /// &nbsp;
        ///     // Request the Cloud Anchor.
        ///     _cloudAnchor = AnchorManager.HostCloudAnchor(localAnchor);
        /// }
        /// &nbsp;
        /// void Update()
        /// {
        ///     if (_cloudAnchor)
        ///     {
        ///         // Check the Cloud Anchor state.
        ///         CloudAnchorState cloudAnchorState = _cloudAnchor.cloudAnchorState;
        ///         if (cloudAnchorState == CloudAnchorState.Success)
        ///         {
        ///             myOtherGameObject.transform.SetParent(_cloudAnchor.transform, false);
        ///             _cloudAnchor = null;
        ///         }
        ///         else if (cloudAnchorState == CloudAnchorState.TaskInProgress)
        ///         {
        ///             // Wait, not ready yet.
        ///         }
        ///         else
        ///         {
        ///             // An error has occurred.
        ///         }
        ///     }
        /// }
        /// </code>
        /// </pre>
        /// </example>
        /// </summary>
        /// <param name="anchorManager">The ARAnchorManager instance.</param>
        /// <param name="anchor">The local <c>ARAnchor</c> to be used as the
        /// basis to host a new Cloud Anchor.</param>
        /// <returns>If successful, a <c><see cref="ARCloudAnchor"/></c>,
        /// otherwise <c>null</c>.</returns>
        public static ARCloudAnchor HostCloudAnchor(
            this ARAnchorManager anchorManager, ARAnchor anchor)
        {
            // Create the underlying ARCore Cloud Anchor.
            IntPtr cloudAnchorHandle = SessionApi.HostCloudAnchor(
                ARCoreExtensions._instance.currentARCoreSessionHandle,
                anchor.AnchorHandle());

            if (cloudAnchorHandle == IntPtr.Zero)
            {
                return(null);
            }

            // Create the GameObject that is the Cloud Anchor.
            ARCloudAnchor cloudAnchor =
                (new GameObject(_gameObjectName)).AddComponent <ARCloudAnchor>();

            if (cloudAnchor)
            {
                cloudAnchor.SetAnchorHandle(cloudAnchorHandle);
            }

            // Parent the new Cloud Anchor to the session origin.
            cloudAnchor.transform.SetParent(
                ARCoreExtensions._instance.SessionOrigin.trackablesParent, false);

            return(cloudAnchor);
        }
コード例 #4
0
        public SessionApiTest()
        {
            var sessionManagerMock = new Mock <IAuthTokens>();

            sessionManagerMock.Setup(obj => obj.SessionToken).Returns("sessionToken");
            _apiExecutorMock = new Mock <IApiExecutor>();
            _sessionApi      = new SessionApi(sessionManagerMock.Object, "", new HttpClient(), _apiExecutorMock.Object);
        }
コード例 #5
0
        public SessionApiTest()
        {
            var sessionManagerMock = new Mock <IAuthTokens>();

            sessionManagerMock.Setup(obj => obj.SessionToken).Returns("sessionToken");
            var configuration = new Configuration();

            _apiExecutorMock = new Mock <IApiExecutor>();
            _sessionApi      = new SessionApi(sessionManagerMock.Object, configuration, _apiExecutorMock.Object);
        }
コード例 #6
0
        /// <summary>
        /// Checks whether the provided <c><see cref="GeospatialMode"/></c> is supported on this
        /// device. The current list of supported devices is documented on the <a
        /// href="https://developers.google.com/ar/devices">ARCore supported devices</a>
        /// page. A device may be incompatible with a given mode due to insufficient sensor
        /// capabilities.
        /// </summary>
        /// <param name="mode">The desired geospatial mode.</param>
        /// <returns>
        /// Indicates whether the given mode is supported on this device.
        /// It will return <c>FeatureSupported.Unknown</c> if the session is still under
        /// initialization.
        /// </returns>
        public FeatureSupported IsGeospatialModeSupported(GeospatialMode mode)
        {
            if (ARCoreExtensions._instance.currentARCoreSessionHandle == IntPtr.Zero)
            {
                return(FeatureSupported.Unknown);
            }

            return(SessionApi.IsGeospatialModeSupported(
                       ARCoreExtensions._instance.currentARCoreSessionHandle, mode));
        }
コード例 #7
0
        /// <summary>
        /// Unity's Update method.
        /// </summary>
        public void Update()
        {
            // Ensure Cloud Anchors are enabled or disabled as requested.
            IntPtr sessionHandle = Session.SessionHandle();

            if (sessionHandle != IntPtr.Zero)
            {
                SessionApi.EnableCloudAnchors(
                    sessionHandle,
                    ARCoreExtensionsConfig.EnableCloudAnchors);
            }
        }
コード例 #8
0
        private void BeforeConfigurationChanged(ARCoreBeforeSetConfigurationEventArgs eventArgs)
        {
            if (_cachedConfig == null)
            {
                return;
            }

            if (eventArgs.session != IntPtr.Zero && eventArgs.config != IntPtr.Zero)
            {
                SessionApi.UpdateSessionConfig(eventArgs.session, eventArgs.config, _cachedConfig);
            }
        }
コード例 #9
0
        /// <summary>
        /// Sets the uri for a dataset to be played back. The ARCore Session must be paused when
        /// using this method. Resume the Session for the change to take effect. The AbsoluteUri
        /// property of the Uri will be passed to ARCore to create an android.net.Uri.
        ///
        /// The uri must point to a seekable resource.
        ///
        /// See <c><see cref="SetPlaybackDataset(string)"/></c> for more restrictions.
        /// </summary>
        /// <param name="datasetUri"> The uri of the MP4 dataset. Null if stopping the playback and
        /// resuming a live feed.</param>
        /// <returns><see cref="PlaybackResult"/>.<c>Success</c> if playback uri was set without
        /// issue. Otherwise, the <see cref="PlaybackResult"/> will indicate the error.</returns>
        public PlaybackResult SetPlaybackDatasetUri(Uri datasetUri)
        {
            if (ARCoreExtensions._instance.currentARCoreSessionHandle == IntPtr.Zero &&
                ARCoreExtensions._instance.Session.subsystem != null &&
                ARCoreExtensions._instance.Session.subsystem.nativePtr != null)
            {
                return(PlaybackResult.SessionNotReady);
            }

            return(SessionApi.SetPlaybackDatasetUri(
                       ARCoreExtensions._instance.currentARCoreSessionHandle, datasetUri.AbsoluteUri));
        }
コード例 #10
0
        /// <summary>
        /// Sets an MP4 dataset file to playback instead of using the live camera feed and IMU
        /// sensor data.
        ///
        /// Restrictions:
        /// <list type="bullet">
        /// <item>
        /// Can only be called while the session is paused. Playback of the MP4 dataset file will
        /// start once the session is resumed.
        /// </item>
        /// <item>
        /// The MP4 dataset file must use the same camera facing direction as is configured in the
        /// session.
        /// </item>
        /// <item>
        /// Due to the way session data is processed, ARCore APIs may sometimes produce different
        /// results during playback than during recording and produce different results during
        /// subsequent playback sessions. For exmaple, the number of detected planes and other
        /// trackables, the precise timing of their detection and their pose over time may be
        /// different in subsequent playback sessions.
        /// </item>
        /// <item>
        /// Once playback has started pausing the session (by disabling the ARSession) will
        /// suspend processing of all camera image frames and any other recorded sensor data in
        /// the dataset. Camera image frames and sensor frame data that is discarded in this way
        /// will not be reprocessed when the session is again resumed (by re-enabling the
        /// ARSession). AR tracking for the session will generally suffer due to the gap in
        /// processed data.
        /// </item>
        /// </list>
        /// </summary>
        /// <param name="datasetFilepath"> The filepath of the MP4 dataset. Null if
        /// stopping the playback and resuming a live feed.</param>
        /// <returns><see cref="PlaybackResult"/>.<c>Success</c> if playback filepath was
        /// set without issue. Otherwise, the <see cref="PlaybackResult"/> will indicate the
        /// error.</returns>
        public PlaybackResult SetPlaybackDataset(string datasetFilepath)
        {
            if (ARCoreExtensions._instance.currentARCoreSessionHandle == IntPtr.Zero &&
                ARCoreExtensions._instance.Session.subsystem != null &&
                ARCoreExtensions._instance.Session.subsystem.nativePtr != null)
            {
                return(PlaybackResult.SessionNotReady);
            }

            return(SessionApi.SetPlaybackDataset(
                       ARCoreExtensions._instance.currentARCoreSessionHandle, datasetFilepath));
        }
コード例 #11
0
        /// <summary>
        /// Starts a new recording, using the provided <see cref="ARCoreRecordingConfig"/> to define
        /// the location to save the dataset and other options. If a recording is already in
        /// progress this call will fail. Check <see cref="RecordingStatus"/> before making this
        /// call. When an ARCore session is paused (unless <see
        /// cref="ARCoreRecordingConfig"/>.<c>AutoStopOnPause</c> is enabled), recording may
        /// continue. During this time the camera feed will be recorded as a black screen, but
        /// sensor data will continue to be captured.
        /// </summary>
        /// <param name="config"><see cref="ARCoreRecordingConfig"/> containing the path to save the
        /// dataset along with other recording options.</param>
        /// <returns><see cref="RecordingResult"/>.<c>OK</c> if the recording is started (or will
        /// start on the next Session resume.) Or a <see cref="RecordingResult"/> if there was an
        /// error.
        /// </returns>
        public RecordingResult StartRecording(ARCoreRecordingConfig config)
        {
            if (ARCoreExtensions._instance.currentARCoreSessionHandle == IntPtr.Zero &&
                ARCoreExtensions._instance.Session.subsystem != null &&
                ARCoreExtensions._instance.Session.subsystem.nativePtr != null)
            {
                return(RecordingResult.SessionNotReady);
            }

            return(SessionApi.StartRecording(
                       ARCoreExtensions._instance.currentARCoreSessionHandle, config));
        }
コード例 #12
0
        static void Main(string[] args)
        {
            var sessionApi        = new SessionApi();
            var credentials       = new AuthRequestDto("user", 261, "password");
            var sessionId         = sessionApi.Login(credentials).SessionId;
            var synthesizeApi     = new SynthesizeApi();
            var synthesizeText    = new SynthesizeText("text/plain", "Hello world");
            var synthesizeRequest = new SynthesizeRequest(synthesizeText, "Carol", "audio/wav");
            var synthesizedSound  = synthesizeApi.Synthesize(Guid.Parse(sessionId), synthesizeRequest).Data;
            var soundBytes        = Convert.FromBase64String(synthesizedSound);

            File.WriteAllBytes("F:\\Cloud\\tts\\testWav.wav", soundBytes);
        }
コード例 #13
0
        static void Main(string[] args)
        {
            var sessionApi          = new SessionApi();
            var startSession        = new AuthRequestDto("user", 261, "password");
            var response            = sessionApi.Login(startSession);
            var sessionId           = response.SessionId;
            var diarizationApi      = new DiarizationApi();
            var sound               = File.ReadAllBytes("F:\\Cloud\\diarization\\8khz.wav");
            var audio               = new AudioDto(sound);
            var diarizationResponse = diarizationApi.Diarization(Guid.Parse(sessionId), audio);
            var speakers            = diarizationResponse.Speakers;

            speakers.ForEach(Console.WriteLine);
        }
コード例 #14
0
        static void Main(string[] args)
        {
            var sessionApi                 = new SessionApi();
            var startSession               = new AuthRequestDto("user", 261, "password");
            var response                   = sessionApi.Login(startSession);
            var sessionId                  = response.SessionId;
            var recognizeApi               = new RecognizeApi();
            var soundBytes                 = File.ReadAllBytes("F:\\Art\\pcm\\0068_20170407_own_6944_181007-1496930080.wav");
            var audio                      = new AudioFileDto(soundBytes, "audio/x-wav");
            var recognitionRequest         = new RecognitionRequestDto(audio, "FarField");
            var recognitionRequestResponse = recognizeApi.RecognizeWords(Guid.Parse(sessionId), recognitionRequest);

            recognitionRequestResponse.ForEach(Console.WriteLine);
        }
コード例 #15
0
        /// <summary>
        /// Creates a new Cloud Anchor with a given lifetime using an existing local ARAnchor.
        /// </summary>
        /// <param name="anchorManager">The ARAnchorManager instance.</param>
        /// <param name="anchor">The local <c>ARAnchor</c> to be used as the
        /// basis to host a new Cloud Anchor.</param>
        /// <param name="ttlDays">The lifetime of the anchor in days. Must be positive. The
        /// maximum allowed value is 1 if using an API Key to authenticate with the
        /// ARCore Cloud Anchor service, otherwise the maximum allowed value is 365.</param>
        /// <returns>If successful, an <c><see cref="ARCloudAnchor"/></c>,
        /// otherwise <c>null</c>.</returns>
        public static ARCloudAnchor HostCloudAnchor(
            this ARAnchorManager anchorManager, ARAnchor anchor, int ttlDays)
        {
            if (ttlDays <= 0 || ttlDays > 365)
            {
                Debug.LogErrorFormat("Failed to host a Cloud Anchor with invalid TTL {0}. " +
                                     "The lifetime of the anchor in days must be positive, " +
                                     "the maximum allowed value is 1 when using an API Key to authenticate with " +
                                     "the ARCore Cloud Anchor service, otherwise the maximum allowed value is 365.",
                                     ttlDays);
                return(null);
            }

            // Create the underlying ARCore Cloud Anchor with given ttlDays.
            IntPtr cloudAnchorHandle = SessionApi.HostCloudAnchor(
                ARCoreExtensions._instance.currentARCoreSessionHandle,
                anchor.AnchorHandle(), ttlDays);

            if (cloudAnchorHandle == IntPtr.Zero)
            {
                return(null);
            }

            // Create the GameObject that is the Cloud Anchor.
            ARCloudAnchor cloudAnchor =
                new GameObject(_gameObjectName).AddComponent <ARCloudAnchor>();

            if (cloudAnchor)
            {
                cloudAnchor.SetAnchorHandle(cloudAnchorHandle);
            }

            // Parent the new Cloud Anchor to the session origin.
            cloudAnchor.transform.SetParent(
                ARCoreExtensions._instance.SessionOrigin.trackablesParent, false);

            return(cloudAnchor);
        }
コード例 #16
0
        /// <summary>
        /// Creates a new anchor at the specified geodetic location and orientation
        /// relative to the Earth.
        ///
        /// Latitude and longitude are defined by the
        /// <a href="https://en.wikipedia.org/wiki/World_Geodetic_System">WGS84
        /// specification</a>, and altitude values are defined by the elevation above
        /// the WGS84 ellipsoid.
        ///
        /// Creating anchors near the north pole or south pole is not supported. If
        /// the latitude is within 0.1 degrees of the north pole or south pole (90
        /// degrees or -90 degrees), this function will return <c>null</c>.
        ///
        /// The rotation provided by <paramref name="eunRotation"/> is a rotation
        /// with respect to an east-up-north coordinate frame. An identity rotation
        /// will have the anchor oriented such that X+ points to the east, Y+ points up
        /// away from the center of the earth, and Z+ points to the north.
        ///
        /// To create a quaternion that represents a clockwise angle theta from
        /// north around the +Y anchor frame axis, use the following formula:
        /// <code>
        /// Quaternion.AngleAxis(180f - theta, Vector3.up);
        /// </code>
        ///
        /// An anchor's tracking state will be TrackingState.None while
        /// <see cref="AREarthManager.EarthTrackingState"/> is TrackingState.None.
        /// The tracking state will permanently become TrackingState.None if the
        /// configuration is set to <see cref="GeospatialMode"/>.<c>Disabled</c>.
        /// </summary>
        /// <param name="anchorManager">The ARAnchorManager instance.</param>
        /// <param name="latitude">
        /// The latitude of the anchor relative to the WGS84 ellipsoid.</param>
        /// <param name="longitude">
        /// The longitude of the anchor relative to the WGS84 ellipsoid.</param>
        /// <param name="altitude">
        /// The altitude of the anchor relative to the WGS84 ellipsoid.</param>
        /// <param name="eunRotation">The rotation of the anchor with respect to
        /// the east-up-north coordinate frame where X+ points east, Y+ points up
        /// away from gravity, and Z+ points north. A rotation about the Y+ axis
        /// creates a rotation counterclockwise from north.</param>
        /// <returns>
        /// If successful, a <see cref="ARGeospatialAnchor"/>, otherwise, <c>null</c>.
        /// </returns>
        public static ARGeospatialAnchor AddAnchor(
            this ARAnchorManager anchorManager, double latitude, double longitude,
            double altitude, Quaternion eunRotation)
        {
            IntPtr earthHandle = SessionApi.AcquireEarth(
                ARCoreExtensions._instance.currentARCoreSessionHandle);

            if (earthHandle == IntPtr.Zero)
            {
                Debug.LogError("Failed to acquire earth.");
                return(null);
            }

            IntPtr anchorHandle = EarthApi.AddAnchor(
                ARCoreExtensions._instance.currentARCoreSessionHandle,
                earthHandle, latitude, longitude, altitude, eunRotation);

            if (anchorHandle == IntPtr.Zero)
            {
                Debug.LogError("Failed to add geospatial anchor.");
                return(null);
            }

            // Create the GameObject that is the Geospatial Anchor.
            ARGeospatialAnchor anchor =
                new GameObject(_geospatialAnchorName).AddComponent <ARGeospatialAnchor>();

            if (anchor)
            {
                anchor.SetAnchorHandle(anchorHandle);
            }

            // Parent the new Geospatial Anchor to the session origin.
            anchor.transform.SetParent(
                ARCoreExtensions._instance.SessionOrigin.trackablesParent, false);
            return(anchor);
        }
コード例 #17
0
 /// <summary>
 /// Stops the current recording. If there is no recording in progress, this method will
 /// return <see cref="RecordingResult"/>.<c>OK</c>.
 /// </summary>
 /// <returns><see cref="RecordingResult"/>.<c>OK</c> if the recording was stopped
 /// successfully, or <see cref="RecordingResult"/>.<c>ErrorRecordingFailed</c> if there was
 /// an error.</returns>
 public RecordingResult StopRecording()
 {
     return(SessionApi.StopRecording(ARCoreExtensions._instance.currentARCoreSessionHandle));
 }
コード例 #18
0
 /// <summary>
 /// Estimates the quality of the visual feature points seen by ARCore in the
 /// preceding few seconds and visible from the provided camera <paramref name="pose"/>.
 /// Cloud Anchors hosted using higher feature map quality will generally result
 /// in easier and more accurately resolved <c><see cref="ARCloudAnchor"/></c> poses.
 /// If feature map quality cannot be estimated for the given <paramref name="pose"/>,
 /// a warning message "Failed to estimate feature map quality" with the error status
 /// is logged and <c><see cref="FeatureMapQuality"/></c>.<c>Insufficient</c> is returned.
 /// </summary>
 /// <param name="anchorManager">The ARAnchorManager instance.</param>
 /// <param name="pose">The camera pose to use in estimating the quality.</param>
 /// <returns>The estimated feature map quality.</returns>
 public static FeatureMapQuality EstimateFeatureMapQualityForHosting(
     this ARAnchorManager anchorManager, Pose pose)
 {
     return(SessionApi.EstimateFeatureMapQualityForHosting(
                ARCoreExtensions._instance.currentARCoreSessionHandle, pose));
 }
コード例 #19
0
ファイル: LMSWebCore.cs プロジェクト: SalmaAssem/WinJiGoTask
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     AlbumApi               = new AlbumApi(this);
     AnmmarApi              = new AnmmarApi(this);
     AnnouncementApi        = new AnnouncementApi(this);
     AssessmentsMessages    = new AssessmentsMessages(this);
     AttendanceApi          = new AttendanceApi(this);
     AuthorizationApi       = new AuthorizationApi(this);
     BadgeApi               = new BadgeApi(this);
     BehaviourApi           = new BehaviourApi(this);
     CalendarApi            = new CalendarApi(this);
     CertificateApi         = new CertificateApi(this);
     ClassApi               = new ClassApi(this);
     ConfigurationMangerApi = new ConfigurationMangerApi(this);
     CopyApi                 = new CopyApi(this);
     CourseApi               = new CourseApi(this);
     CourseCatalogueApi      = new CourseCatalogueApi(this);
     CourseGroupAuthors      = new CourseGroupAuthors(this);
     CourseImageApi          = new CourseImageApi(this);
     CourseRequestsApi       = new CourseRequestsApi(this);
     CoursesProgress         = new CoursesProgress(this);
     DiscussionApi           = new DiscussionApi(this);
     EduShareApi             = new EduShareApi(this);
     EvaluationApi           = new EvaluationApi(this);
     EventApi                = new EventApi(this);
     FileApi                 = new FileApi(this);
     FormsTemplatesApi       = new FormsTemplatesApi(this);
     GradeApi                = new GradeApi(this);
     GradeBookApi            = new GradeBookApi(this);
     HelpApi                 = new HelpApi(this);
     IenApi                  = new IenApi(this);
     InvitationApi           = new InvitationApi(this);
     InviteApi               = new InviteApi(this);
     LanguageApi             = new LanguageApi(this);
     LearningObjectivesApi   = new LearningObjectivesApi(this);
     LearningPathApi         = new LearningPathApi(this);
     LTILMSConsumerApi       = new LTILMSConsumerApi(this);
     MaterialApi             = new MaterialApi(this);
     MaterialSeenByUser      = new MaterialSeenByUser(this);
     MembersApi              = new MembersApi(this);
     MentorApi               = new MentorApi(this);
     NotificationsApi        = new NotificationsApi(this);
     OfferApi                = new OfferApi(this);
     Office365               = new Office365(this);
     OfficeAddInApi          = new OfficeAddInApi(this);
     Onenote                 = new Onenote(this);
     OrganizationUserAPI     = new OrganizationUserAPI(this);
     OutcomesApi             = new OutcomesApi(this);
     PointsApi               = new PointsApi(this);
     PollApi                 = new PollApi(this);
     PrerequisitesApi        = new PrerequisitesApi(this);
     QtiInteroperability     = new QtiInteroperability(this);
     QuestionBankApi         = new QuestionBankApi(this);
     ReflectionApi           = new ReflectionApi(this);
     RelatedCoursesApi       = new RelatedCoursesApi(this);
     ReportApi               = new ReportApi(this);
     RoleManagementApi       = new RoleManagementApi(this);
     ScheduleVisitApi        = new ScheduleVisitApi(this);
     SchoolTypeApi           = new SchoolTypeApi(this);
     SessionApi              = new SessionApi(this);
     SpaceApi                = new SpaceApi(this);
     StudentApi              = new StudentApi(this);
     SubjectApi              = new SubjectApi(this);
     SystemAdministrationApi = new SystemAdministrationApi(this);
     SystemReportsApi        = new SystemReportsApi(this);
     TagsApi                 = new TagsApi(this);
     Themes                  = new Themes(this);
     TimeTableApi            = new TimeTableApi(this);
     ToolConsumerProfileApi  = new ToolConsumerProfileApi(this);
     TourApi                 = new TourApi(this);
     TrackApi                = new TrackApi(this);
     TrainingPlanApi         = new TrainingPlanApi(this);
     UserApi                 = new UserApi(this);
     UserProfileApi          = new UserProfileApi(this);
     UserProgressApi         = new UserProgressApi(this);
     UserSettingsApi         = new UserSettingsApi(this);
     WallApi                 = new WallApi(this);
     BaseUri                 = new System.Uri("https://xwinji.azurewebsites.net");
     SerializationSettings   = new JsonSerializerSettings
     {
         Formatting            = Newtonsoft.Json.Formatting.Indented,
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new  List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
 }
コード例 #20
0
 /// <summary>
 /// Check the availability of the given module. Can be called at any time, including before
 /// session is resumed for the first time.
 /// </summary>
 /// <param name="module">The name of the feature module for which to check the
 /// availability.</param>
 /// <returns>The availability status of the given module.</returns>
 public static FeatureModuleStatus CheckModuleAvailability(
     FeatureModule module)
 {
     return(SessionApi.CheckModuleAvailability(
                _instance.currentARCoreSessionHandle, module));
 }
コード例 #21
0
        static void Main(string[] args)
        {
            PeerApi peerApi = new PeerApi("http://10.30.10.121:6162");
            var     info    = peerApi.GetHubInfo();

            System.Console.WriteLine(info.ToString());

            string output = "";

            foreach (NetworkInterface item in NetworkInterface.GetAllNetworkInterfaces())
            {
                if (item.NetworkInterfaceType == NetworkInterfaceType.Ethernet && item.OperationalStatus == OperationalStatus.Up)
                {
                    foreach (UnicastIPAddressInformation ip in item.GetIPProperties().UnicastAddresses)
                    {
                        if (ip.Address.AddressFamily == AddressFamily.InterNetwork)
                        {
                            output = ip.Address.ToString();
                        }
                    }
                }
            }

            var myIP = Dns.GetHostAddresses(Dns.GetHostName());

            runServer();

            var peers = peerApi.ListPeers();

            int myPeer = -1;

            for (int i = 0; i < peers.Count; i++)
            {
                if (peers[i].PeerAddr.Contains("10.30.8.5"))
                {
                    myPeer = i;
                    break;
                }
            }

            if (myPeer == -1)
            {
                return;
            }

            {
                string hash = "SHA1:213fad4e430ded42e6a949f61cf560ac96ec9878";
                DeploymentSpecImage specImg = new DeploymentSpecImage(hash, "http://10.30.8.5:6000/generatedID/test1.hdi");
                DeploymentSpec      spec    = new DeploymentSpec(EnvType.Hd, specImg, "compiler", new List <string>()
                {
                    "dupa"
                });
                var    peer  = peers[myPeer];
                string depId = peerApi.CreateDeployment(peer.NodeId, spec);
                depId = depId.Replace("\"", "");

                // Run batch file
                var results = peerApi.UpdateDeployment(peer.NodeId, depId, new List <Command>()
                {
                    new ExecCommand("Debug/golemtest.bat", new List <string>())
                });

                // Upload output.zip
                results = peerApi.UpdateDeployment(peer.NodeId, depId, new List <Command>()
                {
                    new UploadFileCommand("http://10.30.8.5:6000/generatedID/", "output.zip")
                });

                peerApi.DropDeployment(peer.NodeId, depId);
                System.Console.WriteLine(depId);
                stopServer();
                return;
            }

            //session
            {
                SessionApi sessionApi = new SessionApi("http://10.30.10.121:6162");

                //create session
                var  body      = new HubSession();
                long?sessionId = sessionApi.CreateSession(body);
                body = sessionApi.GetSession(sessionId);
                //add peer
                var res1 = sessionApi.AddSessionPeers(sessionId, new List <string>()
                {
                    peers[0].NodeId
                });
                var sPeers = sessionApi.ListSessionPeers(sessionId);
                body = sessionApi.GetSession(sessionId);
                var deploymentSpec = new DeploymentInfo();
                deploymentSpec.Name = "dupa";
                string result = sessionApi.CreateDeployment(sessionId, peers[0].NodeId, deploymentSpec);
                System.Console.WriteLine(result);
            }
        }
コード例 #22
0
 /// <summary>
 /// Sets the filepath for a dataset to be played back. The ARCore session
 /// must be paused when using this method. Resume the session for the
 /// change to take effect.
 /// <param name="datasetFilepath"> The filepath of the dataset. Null if
 /// stopping the playback and resuming a live feed.</param>
 /// <returns><cref="PlaybackResult"/>.<c>Success</c> if playback filepath was
 /// set without issue. Otherwise, the <cref="PlaybackResult"/> will indicate the
 /// error.</returns>
 public static PlaybackResult SetPlaybackDataset(string datasetFilepath)
 {
     return(SessionApi.SetPlaybackDataset(
                ARCoreExtensions._instance.currentARCoreSessionHandle, datasetFilepath));
 }
コード例 #23
0
 /// <summary>
 /// Requests that one or more feature modules be downloaded and installed at some point in
 /// the future. Use <c><see cref="RequestModuleInstallImmediate"/></c> to begin immediately.
 /// Use <c><see cref="CheckModuleAvailability"/></c> to determine module availability before
 /// configuring the session. Only modules that are supported on this device will be
 /// scheduled for download and installation.
 /// Any modules that were already scheduled for immediate installation will continue to be
 /// installed immediately.
 /// </summary>
 /// <param name="modules">The list of modules to be installed.</param>
 public static void RequestModuleInstallDeferred(List <FeatureModule> modules)
 {
     SessionApi.RequestModuleInstallDeferred(
         _instance.currentARCoreSessionHandle, modules);
 }
コード例 #24
0
 /// <summary>
 /// Starts a new recording, using the provided <cref="ARCoreRecordingConfig"/> to define the
 /// location to save the dataset and other options. If a recording is already in progress
 /// this call will fail. Check <cref="RecordingStatus"/> before making this call. When an
 /// ARCore session is paused (unless <cref="ARCoreRecordingConfig"/>.<c>AutoStopOnPause</c>
 /// is enabled), recording may continue. During this time the camera feed will be recorded
 /// as a black screen, but sensor data will continue to be captured.
 /// </summary>
 /// <param name="config"><cref="ARCoreRecordingConfig"/> containing the path to save the
 /// dataset along with other recording options.</param>
 /// <returns><cref="RecordingResult"/>.<c>OK</c> if the recording is started (or will start
 /// on the next Session resume.) Or a <cref="RecordingResult"/> if there was an error.
 /// </returns>
 public static RecordingResult StartRecording(ARCoreRecordingConfig config)
 {
     return(SessionApi.StartRecording(
                ARCoreExtensions._instance.currentARCoreSessionHandle, config));
 }
コード例 #25
0
 void Update()
 {
     SessionApi.SetTrackingState(m_TrackingState);
 }
コード例 #26
0
 public void Init()
 {
     instance = new SessionApi();
 }
コード例 #27
0
        public void Provisioning_API__Awaiting_dbUpdated_event()
        {
            #region Obtain token

            object baseUrl = TestContext.Properties["BaseUrl"];
            var    authApi = new AuthenticationApi(
                new Genesys.Internal.Authentication.Client.Configuration
            {
                BasePath      = baseUrl + "/auth/v3",
                DefaultHeader = new Dictionary <string, string>()
                {
                    ["x-api-key"] = (string)TestContext.Properties["ApiKey"],
                },
            });

            var clientId     = (string)TestContext.Properties["ClientId"];
            var clientSecret = (string)TestContext.Properties["ClientSecret"];
            var tenant       = (string)TestContext.Properties["UserNamePath"];
            var userName     = (string)TestContext.Properties["UserName"];
            var userPassword = (string)TestContext.Properties["Password"];

            var tokenResponse = authApi.RetrieveToken(
                grantType: "password",
                authorization:
                "Basic " +
                Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes(
                                           clientId + ":" + clientSecret)),
                username: tenant == null ? userName : tenant + "\\" + userName,
                clientId: clientId,
                password: userPassword);

            Debug.WriteLine("Access token obtained: " + tokenResponse.AccessToken);

            #endregion

            #region Initialize Provisioning API, cookies, and notifications
            Debug.WriteLine("Initializing Provisioning API...");

            var provisioningBaseUrl = (string)TestContext.Properties["ProvisioningBaseUrl"];
            var apiKey = (string)TestContext.Properties["ApiKey"];

            var provisioningApiConfig = new Genesys.Internal.Provisioning.Client.Configuration
            {
                BasePath      = provisioningBaseUrl + "/provisioning/v3",
                DefaultHeader = new Dictionary <string, string>()
                {
                    ["x-api-key"]     = apiKey,
                    ["Authorization"] = "Bearer " + tokenResponse.AccessToken,
                },
            };

            var cookieContainer = new System.Net.CookieContainer();

            provisioningApiConfig.ApiClient.RestClient.CookieContainer = cookieContainer;

            var sessionApi = new SessionApi(provisioningApiConfig);

            var initResponse = sessionApi.InitializeProvisioning();
            Debug.WriteLine("Provisioning API initialized: " + initResponse);

            Debug.WriteLine("Starting notifications...");
            var bayeuxClient = new BayeuxClient(new HttpLongPollingTransportOptions
            {
                HttpClient = new HttpClient(new HttpClientHandler {
                    CookieContainer = cookieContainer
                }),
                Uri = provisioningBaseUrl + "/provisioning/v3/notifications",
            });

            bayeuxClient.EventReceived += (e, eventArgs) =>
                                          //Debug.WriteLine($"Event received on channel {eventArgs.Channel} with data\n{eventArgs.Data}\nFull message:\n{eventArgs.Message}");
                                          Debug.WriteLine($"Event received:\n{eventArgs.Message}");

            bayeuxClient.ConnectionStateChanged += (e, eventArgs) =>
                                                   Debug.WriteLine($"Bayeux connection state changed to {eventArgs.ConnectionState}");

            bayeuxClient.AddSubscriptions("/**");
            bayeuxClient.Start().Wait();
            Debug.WriteLine("Notifications started.");
            #endregion

            var provisioningApiLoaded = new ManualResetEventSlim();

            EventHandler <EventReceivedArgs> dbUpdatedHandler = (_, e) =>
            {
                bool?dbUpdated = e.Data["data"]?["dbUpdated"]?.ToObject <bool>();
                if (dbUpdated.GetValueOrDefault(false))
                {
                    provisioningApiLoaded.Set();
                }
            };

            bayeuxClient.EventReceived += dbUpdatedHandler;

            #region Trigger cache load
            Debug.WriteLine("Calling /args...");
            IRestResponse argsResponse = (IRestResponse)provisioningApiConfig.ApiClient.CallApi(
                method: Method.GET,
                path: "/args",
                queryParams: new List <KeyValuePair <String, String> >(),
                postBody: null,
                headerParams: new Dictionary <String, String>(provisioningApiConfig.DefaultHeader)
            {
                { "Accept", "application/json" },
            },
                formParams: new Dictionary <String, String>(),
                fileParams: new Dictionary <String, FileParameter>(),
                pathParams: new Dictionary <String, String>(),
                contentType: provisioningApiConfig.ApiClient.SelectHeaderContentType(new String[] { "application/json" }));

            Debug.WriteLine("/args called: " + argsResponse);

            int localVarStatusCode = (int)argsResponse.StatusCode;

            var exception = Genesys.Internal.Provisioning.Client.Configuration.DefaultExceptionFactory?.Invoke("GetArgs", argsResponse);
            if (exception != null)
            {
                throw exception;
            }
            #endregion

            Debug.WriteLine("Waiting for dbUpdated...");
            provisioningApiLoaded.Wait(timeout: TimeSpan.FromSeconds(5));
            bayeuxClient.EventReceived -= dbUpdatedHandler;
            Debug.WriteLine("dbUpdated received.");

            //Debug.WriteLine("Sleeping...");
            //Thread.Sleep(TimeSpan.FromSeconds(0));
            //Debug.WriteLine("Finished sleep.");

            #region Call GET users
            var usersApi = new UsersApi(provisioningApiConfig);

            Debug.WriteLine("GETting users...");

            var usersResponse = usersApi.GetUsers(
                //limit: 1,
                //offset: 0,
                filterName: "FirstNameOrLastNameMatches",
                filterParameters: "*****@*****.**"
                //filterParameters: "*****@*****.**",
                //filterParameters: "*****@*****.**",
                //userEnabled: false
                );

            var firstUser = (Newtonsoft.Json.Linq.JObject)usersResponse.Data.Users.FirstOrDefault();

            Debug.WriteLine("User found: {0}", firstUser.ToString() ?? "none");
            #endregion
        }