Implementing a Simple ThingPoint Application
Go Up to ThingPoint Overview
You can create a new ThingPoint application to listen for requests from the EMS Server, and respond with the needed data.
You need the following components in your ThingPoint application:
- The TEMSProvider component is used to set up the connection with the EMS Server.
- The TEMSEdgeService component is used to listen for requests from the EMS Server.
You need the following components in your EMS Client application:
- The TEMSProvider component is used to set up the connection with the EMS Server.
- The TBackendEndpoint component is used to access a particular resource from the ThingPoint.
The EMS Server should be set up and running for this sample.
Contents
Creating a ThingPoint Application
- Create a new Multi-Device Application.
- For Delphi: Open File > New > Multi-Device Application - Delphi
- For C++: Open File > New > Multi-Device Application - C++Builder
- In the Tool Palette, search for a TEMSProvider component and drop it on the form.
- In the Object Inspector, configure the EMS Server parameters according to the EMS server configuration:
- URLHost:
localhost
- URLPort:
8080
- URLProtocol: http
- URLHost:
- Click the Test Connection button. If the connection is successfully set up, you will get a message with the current version of the EMS Server.
- In the Tool Palette, search for a TEMSEdgeService component and drop it on the form.
- In the Object Inspector, configure the following TEMSEdgeService parameters:
- Provider:
EMSProvider1
- ModuleName:
WinEdge1
- Provider:
- In the Object Inspector, configure the following TEMSEdgeService parameters to listen to EMS server requests:
- ListenerProtocol:
http
- ListenerService.Host:
localhost
- ListenerService.Port:
8081
- ListenerProtocol:
- Build and run your application. Click F9 or Run.
- Note: You can only run a ThingPoint on the 32-bit Windows, 64-bit Windows, and OS X target platforms.
Creating an EMS Client Application to Retrieve ThingPoint Data
- Create a new Multi-Device Application:
- For Delphi: Open File > New > Multi-Device Application - Delphi
- For C++: Open File > New > Multi-Device Application - C++Builder
- In the Tool Palette, search for a TEMSProvider component and drop it on the form.
- In the Object Inspector, configure the EMS server parameters according to the EMS server configuration:
- URLHost:
localhost
- URLPort:
8080
- URLProtocol:
http
- URLHost:
- Drop a TBackendEndpoint component on the form.
- In the Object Inspector, set the following parameters of the TBackendEndpoint to use the ThingPoint resource:
- Provider. In the drop-down list, select the name of the TEMSProvider component (
EMSProvider1
). - Resource:
edgemodules/WinEdge1/version
- Resource suffix: Leave it blank for this tutorial.
- Method:
rmGET
- Provider. In the drop-down list, select the name of the TEMSProvider component (
Visually Binding the Response Data
- Open the LiveBindings Designer to visually bind the response data from the ThingPoint. Select View > LiveBindings Designer.
- In the LiveBindings Designer, right-click the Response.JSONText property of the TBackendEndpoint component and choose the Link to new control option to link the response to a new TMemo component.
- Drop a new TButton component on your form.
- In the Object Inspector, set Text property to
Get ThingPoint Version
- In the Object Inspector, set Text property to
- Create the OnClick event of the TButton component (double-click on it) and add the following code:
- Delphi:
procedure TForm1.Button1Click(Sender: TObject); begin BackendEndpoint1.Execute; end;
- C++:
void __fastcall TForm1::Button1Click(TObject *Sender) { BackendEndpoint1->Execute(); }
- Build and run your application.