Hello CS Pro users and welcome to CS Pro Video Tutorial:
How Do I Synchronize Data and Applications?
CS Pro synchronization allows the exchange of files between the device
and an FTP server or Dropbox directory.
You can send the captured data files from your device to the server
and download new versions of data entry applications
from the server to your device.
In addition, if an internet connection is not available,
you can exchange files between two Bluetooth devices.
In this video, we describe how to:
Create synchronization specification files (.PNC files)
to exchange files between the tablet and Dropbox or FTP servers;
Create synchronization specification files to exchange files between two tablets via bluetooth;
Run a synchronization from logic in a data entry application.
CS Pro synchronization routines with a file extension .PNC
provide the specifications to transfer data and programs
back and forth between Android devices and remote machines.
You can transfer data via a Dropbox account
or by using an FTP server.
Multiple synchronization routines can exist on a device
and you will have to determine how you would like to
have your interviewer synchronize your data and program.
We begin with simple synchronization from the .PFF file.
In cases where you would just like to send the data file to the server
and download the .PEN and .PFF files from the server,
you can simply use the .PFF file for the application
to initiate a synchronization.
Make sure that you have created the .PEN file.
Place the .PFF file and the .PEN file into a directory on the FTP server or Dropbox.
Or you can use the .PFF file that is already on your phone or tablet
Then add a new synchronization on the device using that .PFF file.
From the first screen of CS Entry Android,
Tap to bring up the menu.
Select: Synchronize.
Select: Add New.
Choose the location: Dropbox, FTP server or My Device,
where you have placed the file.
And then browse to the location and select it.
The synchronization is saved
and CS Pro presents a summary of the synchronization.
When you run the synchronization,
the synchronization will copy the .DAT and .NOT files
from your device to a directory on the server.
and download the .PEN and .PFF files
to the device from the server.
To synchronize, tap to bring up the menu.
Tap: Synchronize.
Select the application to synchronize,
and CS Pro runs the synchronization.
When the synchronization is complete,
CS Pro issues a message giving the status of the synchronization.
The files will be copied to the specified folder.
A pending %UID%/%DATETIME% to the path
prevents the overwriting of files.
if multiple users use the synchronization.
%UID% is a replaceable parameter
which will show the user ID.
%datetime% is a replaceable perameter
which will show a string containing the date and time.
If you select the .PFF file from Dropbox or from an FTP server,
the data will be copied from the device to the server.
and the .PFF and the .PEN files
will be copied from the server to the device.
If you select the .PFF from the device,
data are copied from the device to the server
and the .PFF and .PEN files are not copied.
For more advanced cases, you can use the synchronization specification file - the .PNC file.
Using the .PNC file, you can customize the files that get
uploaded and downloaded by writing a sync specification file
that is a .PNC file that lists all transfers of the synchronization.
This file contains one or more of the commands shown here.
You can also refer to the CS Pro Helps to view these commands and their descriptions.
This is a client-server model
where the tablet is the client and the server is either Dropbox or an FTP server.
The client issues commands to transfer files
and the server responds by receiving or sending files.
Get command copy files from the server to the client
and put commands copy from the client to the server.
For example: These commands will copy the file PophousCensusData.dat
from the directory CSEntry/PophousCensus
on the device - that is the phone or the tablet -
to the directory /PophousCensus/data on the server.
When the Put is executed, the data file is placed on the server
in the /PophousCensus/data folder.
In addition to these commands, the .PNC file
must also include information about the server being connected to.
For Dropbox it is sufficient to indicate that the connection type is Dropbox.
For FTP, you need to add the server URL, username and password.
Complete the .PNC file by adding a section at the beginning showing the version.
Here is the completed .PNC file using Dropbox.
To add synchronization to the synchronized menu on the tablet
Use the same method as used to add the synchronization from the .PFF file.
Follow these five steps.
Copy the .PNC file to the Dropbox folder, FTP server
or to the phone or tablet via USB connection.
Select: Synchronize from the drop down menu
Select: Add New
Choose the server where you have placed the file
or choose My Device if it is on the phone or tablet
then choose the location of the .PNC file.
CS Pro connects to the server and finds the .PNC file.
The synchronization is now in the synchronized menu.
Once the synchronization is added to the synchronized menu
the .PNC file is no longer needed.
It is copied to a hidden directory on the tablet that is secured to prevent the discovery of passwords.
Any changes to the original PNC file will have no effect on the synchronization.
To modify an existing synchronization,
you need to repeat the process of adding it in order to replace the existing version.
In the first section of the file we can also add a description.
Description= (for example) Synchronize Pophous Census Data.
This description will be displayed on the screen while performing synchronization.
This will be illustrated in the upcoming example.
In this example we will synchronize the MyCAPI_INTRO application with Dropbox.
We will send the data file
MyCAPI_Data.dat to the server
and download MyCAPI_Intro.PFF
and MyCAPI_Intro.PEN files from the server to the tablet.
All of these files for the application are in the CSEntry/MyCAPI_Intro folder
So we will use that as ClientPath.
CSEntry is the default folder for CS Pro applications on the device.
The specified folders exist within the CSEntry folder.
We will place the .PEN and .PFF files in the SyncMyCAPI_Intro app folder in Dropbox,
so that will be the server path for Get.
We will place the data files in the folder SyncMyCAPI_Intro/data
so that will be the server path for Put.
Here we show the complete .PNC file based on these specifications.
If multiple users use this synchronization,
the second synchronization will replace the first sent.
To avoid this problem
specify different directories on the server for each user.
%Date%
%DateTime%
%UID%
or %DeviceID%
can be included in the directory name.
%Date% is replaced by the date,
%DateTime% is replaced by the date and time,
%UID% is replaced by the name of the tablet user.
This comes from the email used to configure the tablet.
%DeviceID% is replaced by the system-generated,
unique ID of the device.
For example:
If the user name Tailo
and we change the server path in our .PNC file as follows:
ServerPath=/SyncMyCAPI_Intro/data/%UID%/
The file will be placed in the folder /SyncMyCAPI_Intro/data/Tailo/
It may be that this folder does not exist.
In which case, you will get an error when your synchronization tries to copy a file to it.
To avoid this, add the command CreateServerPath
to the folder as shown here.
If you ever have problems with synchronization,
you can view the sync log .txt file in the CS Entry directory.
This file contains a detailed log of all files transferred
and all errors encountered during synchronization.
Using synchronization, you can exchange files between phones and tablets
using bluetooth, even without an internet connection.
In this scenario, one device takes the role of server
and the other is the client.
Only the client issues "Get", "Put",
"ClientPath" and "ServerPath" commands.
On the client device, the only difference in the .PNC file
for Bluetooth synchronization, is the type of connection,
which is Bluetooth,
and the addition of the server device name
indicating the name of the other tablet or phone
that is acting as the server.
The server tablet will also have a .PNC file
with a connection type of Bluetooth server
and without any "Get" or "Put" commands.
This is because all commands are initiated
only on the client.
The root folder line specifies the path on the tablet
from which files are shared.
That is the path specified by the set server path command
is concatenated with the root folder
to establish the full path on the server.
For example:
We want to use Bluetooth to copy data
from the enumerators tablet to the supervisors tablet.
On the enumerators tablet,
we have a data file PophousCensusData.dat
in the CSEntry/PophousCensus folder.
On the supervisors tablet,
we would like to place this file in the folder
CSEntry/PophousCensus/ReceivedFromEnumerator/ %UID%/
Here we show the commands for the client or the enumerators tablet.
Note that the server device name is the device name of the Android device.
You can get this name by navigating to the Android device home screen,
tapping on settings, Bluetooth, choosing rename this device
or edit device name from the menu.
Here we show the .PNC file for the server
which is the supervisors tablet.
Now that we have seen how the synchronization works,
let's apply the synchronization
to the MyCAPIintro application.
The left side of the screen will show what's happening with the client or the enumerator side
and the right side of the screen will show what's happening with the server
or the supervisors tablet.
First we write the .PNC files.
These files can be created with notepad or any other text editor.
Once the .PNC files are created,
copy them to the respective devices.
To add the synchronization,
select Synchronize from the menu,
select Add New.
Select My Device,
select the .PNC file for the enumerator or the supervisor
and the synchronization is created.
CS Pro will then display a summary of the synchronization.
Now that the synchronization is created follow these steps to synchronize.
Select synchronize from the menu,
select the application to synchronize.
The name is from the .PNC file.
If this message appears, select Allow
to allow this tablet or phone to be discovered by other Bluetooth devices.
The Bluetooth devices connect and are synchronized based on the specifications in the .PNC file.
A successful completion message is issued
once the synchronization is complete.
To make changes to the .PNC file,
make the changes for the .PNC file on your Windows machine
using any text editor such as notepad.
Copy the .PNC file to the device.
From the synchronized menu select Add New.
Select the location of the .PNC file
(Dropbox, FTP server or My device)
then navigate to and select the .PNC file.
If the synchronization does not exist,
CS Pro creates a new synchronization.
If the synchronization already exists,
CS Pro will overwrite the old synchronization with the new synchronization.
You can launch synchronizations in CS ProLogic
using the sync function
which takes the name of the synchronization file as the argument.
The synchronization will look for the file in the specified path.
Otherwise it looks for the .PNC file in the same directory as the .PEN file.
And if it does not find it there, it searches for it
among the .PNC files that are installed in the synchronization menu.
The function Sync has an optional second argument,
queue,
that will wait to start the synchronization after data entry is complete.
This can be useful because during data entry
the questionnaire being entered is not yet saved.
queue tells the sync function to synchronize after the questionnaire has been saved.
This brings us to the end of our video tutorial on Synchronization in CS Pro.
Please explore our many other tutorials on the many aspects of CS Pro.