Bosch Building Technologies

    Showing results for 
    Search instead for 
    Did you mean: 

    [FAQ] Example BVMS SDK scriplet to receive and react on server events



    Is there a script example to implement event receiver in BVMS SDK scriplet?


    System overview:

    • BVMS

    Expected result:

    Control Operator Client, whenever a Virtual Input changes state (either ON->OFF or vice-versa).


    • When Virtual Input (any) is open- some action follows in Op Client
    • When Virtual Input (any) is closed, some action follows




    • First, we recommend you to check the document BVMS-SDK help.pdf  and in particular the example executable: "Example executable 8: Control Operator Client in response to a Virtual Input Data event and read out the data" from this article

    Concept for you to use:

    • In BVMS OC use scriplet, that registers for Events (ex. Virtual Input)
    • filter the events and reacts (changes the layout, calls a Favorite, etc.) on particular event

    Please find below an example of script that can be used:

    // ScriptType: ClientScript

    // ScriptLanguage: CS

    using System;
    using System.Diagnostics;
    using System.Collections.Generic;
    using log4net;
    using Bosch.Vms.Core;
    using Bosch.Vms.SDK;

    public class ClientScript : IDisposable
        private readonly IClientApi Api;
        private readonly ILog Logger;  
        Guid almId_global;
        private EventReceiver myEventRecWS;  
        RemoteServerApi RSApi;

    // then declare the EventReceiver class

        private class MyEventRecieverWS : EventReceiver
            private IClientApi myApi;
            public MyEventRecieverWS(IClientApi api)
                myApi = api;
            public override void OnEvent(EventData ed)

                //if((ed.Type=="InputState") && (ed.DeviceName=="Virtual Input 1"))
                // this is just example with the Type of the event. One could also include the Device name - (ed.DeviceName=="Virtual Input 1") and so on
                    //if the VI is open
                    if(ed.State.IsValid == true)
                        //add an action here for example

                        ImagePane ipPane1 = new ImagePane(1, 1);
                        cCam111 = myApi.CameraManager.GetCameraByLogicalNumber(4);
                        DateTime timestamp1 = myApi.ContentManager.GetCurrentTimeStamp(ipPane1);
                        myApi.ContentManager.DisplayCamera(ipPane1, cCam4);
                    if(ed.State.IsValid == false)
                        //add an action here for example

        public ClientScript(IClientApi api)
            this.Logger = LogManager.GetLogger("ClientScript");
            this.Api = api;        

        public void ReactOnEvent()
             // Should be called only as sart up script!!! There is restriction of the numbers of event/alarm receivers per system //
                myEventRecWS = new MyEventRecieverWS(Api);
                catch (Exception mye)
                Api.ApplicationManager.ShowMessage(mye.Message + "Couldn't create event reciever");

                { // here use the IP of the BVMS server and the corresponding credentials valid for the current BVMS OC user
                    RSApi = new RemoteServerApi ("", "Admin", "" );
                    //Api.ApplicationManager.ShowMessage("connected to server");
                catch (Exception mye)
                    Api.ApplicationManager.ShowMessage(mye.Message + "Couldn't connect to server");

                //Api.ApplicationManager.ShowMessage("registered receiver");

            catch (Exception mye)
                Api.ApplicationManager.ShowMessage(mye.Message + "Couldn't register");
            // unregister is made automatically for client scripts when the operator logs off



    Note: This is simplified and generalized example, that could be helpful in building a particular tailored script.  


    🚩 Info:

    Q: What is the maximum number of receivers?

    A: There is no hard limit, but one should take into the account the size of the installation and the expected server load. 

    Version history
    Last update:
    ‎02-10-2023 09:40 AM
    Updated by:
    Labels (7)