protected static MasterloopLiveConnection GetMCSLiveTemporary()
        {
            MasterloopServerConnection mcs = GetMCSAPI();
            LiveAppRequest             lar = new LiveAppRequest()
            {
                MID = GetMID(),
                ConnectAllCommands     = true,
                ConnectAllObservations = true,
                InitObservationValues  = false,
                ReceiveDevicePulse     = true
            };
            LiveConnectionDetails lcd = mcs.RequestLiveConnection(new LiveAppRequest[] { lar });

            return(new MasterloopLiveConnection(lcd));
        }
        protected static MasterloopLiveConnection GetMCSPersistentConnection()
        {
            MasterloopServerConnection mcs = GetMCSAPI();
            string subscriptionKey         = GetPersistentSubscriptionKey();

            mcs.DeleteLivePersistentSubscription(subscriptionKey);
            LivePersistentSubscriptionRequest request = new LivePersistentSubscriptionRequest()
            {
                SubscriptionKey    = subscriptionKey,
                TID                = GetTID(),
                ConnectAllCommands = true
            };

            if (mcs.CreateLivePersistentSubscription(request))
            {
                LiveConnectionDetails lcd = mcs.GetLivePersistentSubscriptionConnection(subscriptionKey);
                return(new MasterloopLiveConnection(lcd));
            }
            else
            {
                throw new Exception("Could not create subscription");
            }
        }
Exemple #3
0
        public void SendDeviceCommandWithMetadata()
        {
            Command cmd = new Command()
            {
                Id        = MLTEST.Constants.Commands.PollSingle,
                Timestamp = DateTime.UtcNow,
                ExpiresAt = DateTime.UtcNow.AddMinutes(5),
                Arguments = new CommandArgument[] {
                    new CommandArgument()
                    {
                        Id = MLTEST.Constants.Commands.PollSingleArguments.ObsId, Value = "4"
                    }
                }
            };
            MasterloopServerConnection mcs = GetMCSAPI();

            mcs.Metadata = new ApplicationMetadata()
            {
                Application = "Tests.ServerConnection",
                Reference   = "SendDeviceCommandWithMetadata"
            };
            Assert.True(mcs.SendDeviceCommand(GetMID(), cmd));
        }