Home » Blog

Quick & Easy File Integration

 · 3 min · Nuno Nunes

IoT File Integration for Dummies

ConnectIoT FileRaw Common V9.x.x

On this blog post we will implement a generic file integration: some file will be read from some folder and it’s contents will be read and passed on to some DEE Action.

COMMON Package

For this integration we will use a COMMON Feature package: Cmf.Custom.IoT-GenericFileIntegration

Feature Packages: COMMON is a repository where projects can implement features that can be shared and reused. This serves to mitigate having to implement the same code throughout different projects. The features are posted to COMMON and every project is free to import it, use it and contributing back to make it even more robust.

Using this package on my project

To use this package on your project, you simply add to your cmfpackage.json file:

Adding to Project - Same MES Version (9.1.11)

Important: If your project is using a different patch version than the one this package was prepared for (9.1.11), please use the components unrooted:

Adding to Project - Different MES Version

Creating a Controller Instance

After the release process, the environment will have a new automation manager, GenericFileIntegration_Manager, and a new controller, GenericFileIntegration_Controller. To use it, just create a controller instance by connecting this controller to a Resource.

Feature Configuration

Available package options are described on package README.md.

Configuration is orchestrated on a smart table <ST>IoTMetaDataDefinition by name/value pairs. Minimal configuration is:

NameValueDescription
FileRaw_filePathc:\iot\Shares\IncomingIncoming folder (where file are created)
FileRaw_SuccessArchiveFilePathc:\iot\Shares\SuccessWhere to store the files on DEE Action Success
FileRaw_ErrorArchiveFilePathc:\iot\Shares\ErrorWhere to store the files on DEE Action Error
FileRaw_DEEActionNameCustomSendNotificationOnDisconnectedDEE to execute
FileRaw_InputParameterNameErrorMessageInput parameter name on DEE/Service

We can reuse the blog post Send a Notification in Connect IoT as a DEE example (CustomSendNotificationOnDisconnected). With this example, whenever a new file is put on the incoming folder, a new notification is created with the content of the file.

Execution time!

Download the manager from MES GUI:

Download manager

Unzip and run it (as Administrator to be able to mount network files):

Run It

Now, drop a file with some content on the incoming folder:

File on Incoming

A new notification should be created:

Notification Created

and the file should be moved to a timestamped subfolder on `Success`` folder:

Moved to Success

Great Success!

Things to consider

Multiple files being dropped at the same time on the incoming folder

If you would need to handle multiple files at the same time, please add to your manager config.json: "controller": {"useClassicEngine": false}.

Error calling DEE/Service

If DEE fails, file is moved to the Error folder (with some date timestamp) and the received error is also stored on a .log file: This is very helpfull to debug whithout the need to check IoT logs.

Log file on Error






Author

Hello my name is Nuno Nunes

I am an IoT Lead for the SMT area You can visit me at LinkedIn

Skills: Connect IoT

Nuno Nunes
IoT Lead