Retreive state of input

I would like to get a suggestion on how to retrieve the state of an HW-input (for example and input on an ADAM module) with a syncronous call. I cannot find any samples showing this.

One possible alternative (which is not prefered in our scenario) is to do a request for all statuses sending the MessageCommunication.ProvideCurrentStateRequest message and picking up the response. When using the “ProvideCurrentStateRequest-approach”, the list of items contain the inputs wanted. However, the value is “Input changed”, as opposed to “Input Activated”.

I guess the problem is more or less the same as this: https://developer.milestonesys.com/s/question/0D50O00003GYFFvSAP/inputoutput-event-handling

Milestone Development made fix for MIP SDK 2019R2, so that the Event Server ignore Output Changed event as it always come right after the much more describing Activated/Deactivated event.

The fix was not mentioned in the documentation. What is worse is the the same issue exists for inputs and was not fixed. I will make a new bug report on this.

I had an idea that the same information would be easier to get using the Status API, and I think it is. It is important to note that the Status API does not work with e-code, only c-code (XProtect Corporate, Expert and all Plus products). My snippet of code (console application):

class Program
{
    const string URI = "http://localhost";
    const string USER = "";
    const string PASSWORD = "";
    const string AUTH = "Negotiate";
    const string GUIDSTRING = "BB96F126-E702-4305-942E-CC974DC487C9";
    static void Main(string[] args)
    {
        VideoOS.Platform.SDK.Environment.Initialize();
        if (Login())
        {                
            VideoOS.Platform.Login.LoginSettings loginSettings = VideoOS.Platform.Login.LoginSettingsCache.GetLoginSettings(EnvironmentManager.Instance.CurrentSite);
            Guid inputGuid = new Guid(GUIDSTRING);
            Item inputItem = VideoOS.Platform.Configuration.Instance.GetItem(inputGuid, Kind.InputEvent);
            VideoOS.Platform.SDK.Proxy.Status2.RecorderStatusService2 client = new VideoOS.Platform.SDK.Proxy.Status2.RecorderStatusService2(inputItem.FQID.ServerId.Uri);
            VideoOS.Platform.SDK.Proxy.Status2.Status status = client.GetCurrentDeviceStatus(loginSettings.Token, new Guid[] { inputGuid });
            string ioStateString = status.InputDeviceStatusArray.FirstOrDefault().State.ToString();
 
            Console.WriteLine("Input: " + inputItem.Name + " is " + ioStateString);
        }
        Console.WriteLine("");
        Console.WriteLine("Press any key");
        Console.ReadKey();
    }
 
    static private bool Login()
    {
        Uri uri = new UriBuilder(URI).Uri;
        CredentialCache cc = VideoOS.Platform.Login.Util.BuildCredentialCache(uri, USER, PASSWORD, AUTH);
        VideoOS.Platform.SDK.Environment.AddServer(uri, cc);
 
        //  You need this to apply Enterprise "basic" credentials. 
        //CredentialCache cc = VideoOS.Platform.Login.Util.BuildCredentialCache(uri, "test", "test", "Basic");
        //  The BuildCredentialCache can aslo build credential for Windows login ..
        //CredentialCache cc = VideoOS.Platform.Login.Util.BuildCredentialCache(uri, "myserver\\testuser", "Str0ngPa$", "Negotiate");
        // For reuse of Windows credentials ..
        //CredentialCache cc = VideoOS.Platform.Login.Util.BuildCredentialCache(uri, "", "", "Negotiate");
 
        try
        {
            VideoOS.Platform.SDK.Environment.Login(uri);
        }
        catch (VideoOS.Platform.SDK.Platform.ServerNotFoundMIPException snfe)
        {
            Console.WriteLine("Server not found: " + snfe.Message);
            VideoOS.Platform.SDK.Environment.RemoveServer(uri);
            return false;
        }
        catch (VideoOS.Platform.SDK.Platform.InvalidCredentialsMIPException ice)
        {
            Console.WriteLine("Invalid credentials for: " + ice.Message);
            VideoOS.Platform.SDK.Environment.RemoveServer(uri);
            return false;
        }
        catch (Exception)
        {
            Console.WriteLine("Internal error connecting to: " + uri.DnsSafeHost);
            VideoOS.Platform.SDK.Environment.RemoveServer(uri);
            return false;
        }
 
        Console.WriteLine("Login succeeded.");
        return true;
    }
}

On a final note. The input has the state “Unknown” until the first time the input has been used, this is a known limitation of the XProtect recording server.