IToolS Blog

Using IToolS in C++/CLI and MFC

by itools@albertoschiassi.it on sabato 2 gennaio 2016 06:44
In questo articolo sono presenti due progetti che mostrano come utilizzare i driver IToolS in un'applicazione MFC ed in un'applicazione console VC++:

 

// IToolSVCClr.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h"
#include <vcclr.h>
 
 
void OnChanged(System::Objectsender, IToolS::Data::ChangedEventArgs ^e)
{
   System::Console::WriteLine(System::String::Format("New value {0}", 
      e->NewValue));
}
 
int _tmain(int argc_TCHARargv[])
{
   gcroot<IToolS::Lite::Communication::Variable^> variable = 
      gcnew IToolS::Lite::Communication::Variable();
   gcroot<IToolS::Lite::Communication::Client^> client = 
      gcnew IToolS::Lite::Communication::Client();
   gcroot<IToolS::Lite::Communication::Group^> group = 
      gcnew IToolS::Lite::Communication::Group();
   gcroot<IToolS::Lite::IOServers::IOServer^> ioserver = 
      gcnew IToolS::Lite::IOServers::IOServer();
 
   variable->VariableName = "var";
   variable->Address = "10";
   variable->Changed += gcnew IToolS::Data::ChangedEventHandler(OnChanged);
 
   group->Add(variable);
 
   ioserver->Name = "Simulation";
 
   client->Group = group;
   client->IOServer = ioserver;
   client->Start();
 
   System::Console::WriteLine("Press ENTER to exit");
   System::Console::ReadLine();
 
   client->Stop();
   client->StopIOServer();
 
   return 0;
}
 

Blogs Parent Separator IToolS Blog
Author

Tags