================================================================================ PAGE 101 ================================================================================ Example–Receiving andDispatching GeViScope ActionsinsideGeViSoft: PseudoCode: 1.CreateaninstanceoftheGscActionDispatcher classthatwilldispatchtheGeV- iScopeactionstoyourhandlers 2.CreateaneventhandlerthatreceivestheGeViSoftGscAction. Insidethisevent handler,callthedispatchmethodofyourGscActionDispatcher instanceforevery receivedGscAction. 3.RegistertheGeViSoftGscAction eventhandlerwithyourGeViSoftdatabasecon- nectionobject. 4.CreateaneventhandlermethodforanyGeViScope actionyouwanttoprocess 5.RegisteryourGeViScope actionseventhandleratthedispatcher. C#: //Createaninstance oftheGscActionDispatcher class GscActionDispatcher myGscDispatcher =newGscActionDispatcher (); //GscAction eventhandler thatdispatches theGscAction voidmyDB_ReceivedGscAction (objectsender, GeViAct_ GscActionEventArgs e) { myGscDispatcher.Dispatch (e.m_GscAction); } //Addthehandler forGscAction (thisiscalledforanynewlyreceived GeV- iScopeaction) myDB.ReceivedGscAction +=new GeViAct_ GscActionEventHandler (myDB_ReceivedGscAction); //Don'tforgettoregister thecallbacks! myDB.RegisterCallback (); //Eventhandler methodfortheGeViScope Action ================================================================================ PAGE 102 ================================================================================ voidmyGscDispatcher_ OnCustomAction (objectsender, GscAct_Cus- tomActionEventArgs e) { Console.WriteLine "Received GEVISCOPE CustomAction ("+e.aInt+"," +e.aString +")"); } //Register theGeViScope CustomAction eventhandler withthedispatcher myGscDispatcher.OnCustomAction +=new GscAct_CustomActionEventHandler (myGscDispatcher_ OnCustomAction);  NOTICE Youcanfindacomplete example application thatsendsandreceives GeViScope actions inCS_ SimpleGscActionClient. StateQueries inC# Thisparagraph describes howyoucansendandreceiveStateQueriesfromwithinC#.Foran introduction toStateQueriesingeneralseechapterSDK-Usage->StateQueries. Creating andSending StateQueries YoucancreateStateQuerieswiththeirrespective constructors andsendthemafterwards by callingtheSendQuery ()methodofyourdatabaseconnection instance.TheSendQuery () methodreturnstheGeViSoftStateAnswerviaanoutparameter. //myAnswer isfilledbytheSendQuery ()method //withtheStateAnswer. GeViMessage myAnswer; //Thisisyourquery GeViMessage myQuery =newGeViSQ_GetFirstVideoInput (true,true); ================================================================================ PAGE 103 ================================================================================ //Sendthequery myDB.SendQuery (myQuery, outmyAnswer); if(myAnswer isGeViSA_VideoInputInfo ) { //Dosomething withmyanswerhere... } SettingtheStateQueryTimeout ThemethodSendQuery ()blocksuntilthedatabaseanswerisretrievedfromtheGeViServer. Iftheserverdoesnotanswer,thisleadstoadeadlock. Amaximum timeouttimerforthe SendQuery existstopreventwaitingendlesslyforadatabaseanswer.Bydefault,thetimeout issetto3000ms.YoucanchangethistimeoutgloballybycallingtheSetQueryTimeoutInMs ()methodofyourdatabaseconnection instance. Example–SettingtheSendQuery timeouttoonesecond: myDB.SetQueryTimeoutInMs (1000); Enumeration ofallvideoinputs Pseudocode 1.Createastatequerytogetthefirstvideoinput(classGeViSQ_GetFirstVideoInput) 2.Sendthequerytotheserver 3.Iftheanswerisavalidinputchannelthen 4.REPEAT a)Gettheactualchannel’sinformation fromtheanswerandprocessitasneeded (e.g.printitout,storeittoalist) b)CreateastatequerytogetthenextvideoInput(classGeViSQ_ ================================================================================ PAGE 104 ================================================================================ GetNextVideoInput) c)Sendthequery 5.UNTILthereisnomorevideoinputleft C#Example: private ListgetVideoInputsList () { ListmyVideoInputs = newList(0); if(myDB!=null) { GeViMessage myAnswer; myDB.SendQuery (newGeViSQ_GetFirstVideoInput (true,true), outmyAnswer); while(myAnswer isGeViSA_VideoInputInfo ) { inttempID=(myAnswer asGeViSA_VideoInputInfo ).sG- lobalID; myVideoInputs.Add (myAnswer asGeViSA_VideoInputInfo ); myDB.SendQuery ( newGeViSQ_GetNextVideoInput (true,true,tem- pID), outmyAnswer); } } returnmyVideoInputs; }  NOTICE Youcanfindacomplete example application thatsendsStateQueries andreceives StateActions inCS_SimpleClient. Thisexample showsyouhowtoenumerate videoin-andoutputs aswellas digitalIO. ================================================================================ PAGE 105 ================================================================================ Supported Development Platforms TheSDKisdesignedforandtestedtoworkwiththefollowingdevelopment environments: lMicrosoftVisualStudio2008,C++ lMicrosoftVisualStudio2010,C++ lMicrosoftVisualStudio2008,C# lMicrosoftVisualStudio2010,C# lEmbarcadero RADStudioXE,Delphi ================================================================================ PAGE 106 ================================================================================ Examples TheSDKisshippedwithvariousexamples showingyouhowtoimplement commontasks. Theexamples aregroupedbyfunctionality andplatform. ByFunctionality Connecting/disconnecting toGeViServer lCPP_SimpleActionClient (VS2008/VS2010, C++) lCPP_SimpleClient (VS2008/VS2010, C++) lCPP_SimpleDatabaseClient (VS2008/VS2010, C++) lCPP_MonitoredConnectionClient (VS2008/VS2010, C++) lCPP_ConsoleClient (VS2008/VS2010, C++) lCS_SimpleActionClient (VS2008/VS2010, C#) lCS_SimpleClient (VS2008/VS2010, C#) lCS_SimpleDatabaseClient (VS2008/VS2010, C#) lCS_SimpleGscActionClient (VS2008/VS2010, C#) lDelphi_SimpleActionClient (RADStudioXE) lDelphi_SimpleClient (RADStudioXE) lDelphi_SimpleDatabaseClient (RADStudioXE) lDelphi_ConsoleClient (RADStudioXE) Monitoring aGeViSoft connection lCPP_MonitoredConnectionClient (VS2008/VS2010, C++) Automatically reconnecting aGeViSoft connection onloss lCPP_MonitoredConnectionClient (VS2008/VS2010, C++) Sending/receiving ofGeViSoft actions/messages lCPP_SimpleActionClient (VS2008/VS2010, C++) lCPP_MonitoredConnectionClient (VS2008/VS2010, C++) lCPP_SimpleClient (VS2008/VS2010, C++) ================================================================================ PAGE 107 ================================================================================ lCPP_SimpleDatabaseClient (VS2008/VS2010, C++) lCPP_ConsoleClient (VS2008/VS2010, C++) lCS_SimpleActionClient (VS2008/VS2010, C#) lCS_SimpleClient (VS2008/VS2010, C#) lCS_SimpleDatabaseClient (VS2008/VS2010, C#) lCS_ConsoleClient (VS2008/VS2010, C#) lDelphi_SimpleActionClient (RADStudioXE) lDelphi_SimpleClient (RADStudioXE) lDelphi_SimpleDatabaseClient (RADStudioXE) lDelphi_ConsoleClient (RADStudioXE) Sending/receiving ofGeViScope actions/messages lCS_SimpleGscActionClient (VS2008/VS2010, C#) Receiving anddispatching ofservernotifications lCPP_SimpleActionClient (VS2008/VS2010, C++) lCPP_MonitoredConnectionClient (VS2008/VS2010, C++) lCPP_SimpleDatabaseClient (VS2008/VS2010, C++) lCPP_ConsoleClient (VS2008/VS2010, C++) lCS_SimpleActionClient (VS2008/VS2010, C#) lCS_SimpleClient (VS2008/VS2010, C#) lCS_SimpleDatabaseClient (VS2008/VS2010, C#) lCS_SimpleGscActionClient (VS2008/VS2010, C#) lCS_ConsoleClient (VS2008/VS2010, C#) lDelphi_SimpleActionClient (RADStudioXE) lDelphi_SimpleClient (RADStudioXE) Converting between ASCIIandbinaryrepresentation ofmessages lCPP_SimpleActionClient (VS2008/VS2010, C++) lCPP_SimpleDatabaseClient (VS2008/VS2010, C++) lCPP_ConsoleClient (VS2008/VS2010, C++) lDelphi_SimpleActionClient (RADStudioXE) lDelphi_SimpleDatabaseClient (RADStudioXE) lDelphi_ConsoleClient (RADStudioXE) ================================================================================ PAGE 108 ================================================================================ Sending/receiving statequeries andanswers lCPP_SimpleClient (VS2008/VS2010, C++) lCS_SimpleGscActionClient (VS2008/VS2010, C#) lDelphi_SimpleClient (RADStudioXE) Enumeration ofvideoinputandoutputchannels lCPP_SimpleClient (VS2008/VS2010, C++) lCS_SimpleClient (VS2008/VS2010, C#) lDelphi_SimpleClient (RADStudioXE) Enumeration ofdigitalIOcontacts lCPP_SimpleClient (VS2008/VS2010, C++) lCS_SimpleClient (VS2008/VS2010, C#) lDelphi_SimpleClient (RADStudioXE) Sending database actionqueries lCPP_SimpleDatabaseClient (VS2008/VS2010, C++) lCS_SimpleDatabaseClient (VS2008/VS2010, C#) lDelphi_SimpleDatabaseClient (RADStudioXE) Sending database alarmqueries lCPP_SimpleDatabaseClient (VS2008/VS2010, C++) lCS_SimpleDatabaseClient (VS2008/VS2010, C#) lDelphi_SimpleDatabaseClient (RADStudioXE) Navigating through database entries lCPP_SimpleDatabaseClient (VS2008/VS2010, C++) lCS_SimpleDatabaseClient (VS2008/VS2010, C#) lDelphi_SimpleDatabaseClient (RADStudioXE) Converting database answers frombinarytoASCIIrepresentation lCPP_SimpleDatabaseClient (VS2008/VS2010, C++) lDelphi_SimpleDatabaseClient (RADStudioXE) ================================================================================ PAGE 109 ================================================================================ Building GeViSoft messages fromuserinput lCPP_ConsoleClient (VS2008/VS2010, C++) lCS_ConsoleClient (VS2008/VS2010, C#) lDelphi_ConsoleClient (RADStudioXE) ================================================================================ PAGE 110 ================================================================================ ByPlatform Microsoft VisualStudio2008/2010, C++,MFC CPP_SimpleActionClient lConnecting/disconnecting toGeViServer lSending/receiving ofactions lReceiving anddispatching ofservernotifications lConverting betweenASCIIandbinaryrepresentation ofmessages. CPP_MonitoredConnectionClient lConnecting/disconnecting toGeViServer lSending/receiving ofactions lReceiving anddispatching ofservernotifications lConverting betweenASCIIandbinaryrepresentation ofmessages lMonitoring aGeViSoftconnection lAutomatically reconnecting aGeViSoftconnection onloss CPP_SimpleClient lConnecting/disconnecting toGeViServer lSending/receiving statequeriesandanswers lSending/receiving ofactions lEnumeration ofvideoinputandoutputchannels lEnumeration ofdigitalIOcontacts lReceiving anddispatching ofservernotifications CPP_SimpleDatabaseClient lConnecting/disconnecting toGeViServer lSendingdatabaseactionqueries lSendingdatabasealarmqueries lNavigating throughdatabaseentries lReceiving databaseentries lConverting databaseanswersfrombinarytoASCIIrepresentation