Professional Documents
Culture Documents
<Int>
Technical
Information FCN/FCJ Java Function
Programmer's Guide
TI 34P02K26-01E
Introduction
The STARDOM autonomous controller FCN/FCJ (hereinafter abbreviated as FCN/FCJ)
has not only control functions, but it also has an environment for the execution of Java
applications. The FCN/FCJ function for the execution of Java applications is called the
FCN/FCJ Java function. By application of the FCN/FCJ Java function, sending and
receiving e-mail and Web server functions become possible for FCN/FCJ, and functions
for data accumulation and calculations also can be produced.
This guide explains the outline for the creation of Java applications running on FCN/FCJ
and the tutorial.
y This guide has been written for persons who develop Java applications with
FCN/FCJ.
y This is the programmer's guide for the FCN/FCJ Java function loaded in the
autonomous controller FCN/FCJ.
y The details for each function and the usage are introduced in the online help. This
guide includes a tutorial easy to understand even for first-time users.
y Understanding the contents of this manual requires the knowledge of an outline of
the functions of the Java language and programming of Java applications as well as
the knowledge of the basic operation of FCN/FCJ. Accessing the data of the control
functions with tutorial also requires the knowledge of the construction of the
FCN/FCJ control functions.
1. Outline
Application examples for the FCN/FCJ Java function are shown together with the
operation environment and related documents.
2. Function Specifications
The function outline for the FCN/FCJ Java function is shown.
3. Tutorial
This is a tutorial for actual creation of applications.
All Rights Reserved. Copyright © 2003, Yokogawa Electric Corporation TI 34P02K26-01E 2002.12.15-00
2003.07.25-00
<Toc> <Ind> <Rev> <Introduction> ii
Software Manual
y Online help
The FCN/FCJ Java application development kit is explained from the outline to class
library setting details.
The Webmetry basic library is explained from the outline to program examples and
the class library setting details.
y Technical information
(This guide) The outline of the FCN/FCJ Java function and the tutorial are described.
All Rights Reserved. Copyright © 2003, Yokogawa Electric Corporation TI 34P02K26-01E 2002.12.15-00
2003.07.25-00
<Int> <Ind> <Rev> Toc-1
STARDOM
FCN/FCJ Java Function
Programmer's Guide
TI 34P02K26-01E 2nd Edition
CONTENTS
1. Outline........................................................................................... 1-1
1.1 Positioning of the FCN/FCJ Java Function .......................................... 1-1
1.2 FCN/FCJ Java Function .......................................................................... 1-2
1.3 FCN/FCJ Java Application Development Kit ........................................ 1-3
1.4 Operation Environment .......................................................................... 1-4
1.5 Related Packages and Documents........................................................ 1-5
2. Function Specifications............................................................... 2-1
2.1 FCN/FCJ Java Function .......................................................................... 2-1
2.1.1 JEROS basic part......................................................................... 2-3
2.1.2 JEROS Extended Part ................................................................. 2-4
2.1.3 System Settings ........................................................................... 2-5
2.2 Webmetry Basic Library Portfolio.......................................................... 2-6
3. Tutorial .......................................................................................... 3-1
3.1 Installation Preparations (required software)....................................... 3-1
3.2 Programming Section ............................................................................. 3-7
3.2.1 Development Flow ....................................................................... 3-7
3.2.2 FCN/FCJ Java Function............................................................... 3-8
3.2.3 Sleeper Creation ........................................................................ 3-10
3.2.4 Compiling ................................................................................... 3-15
3.2.5 Operation Confirmation.............................................................. 3-16
3.3 Actual Machine Operation Section...................................................... 3-21
3.3.1 Sleeper Operation...................................................................... 3-21
3.3.2 Start of FCN/FCJ in Maintenance Mode .................................... 3-22
3.3.3 Jar File Creation and Transfer to FCN/FCJ ............................... 3-25
3.3.4 AdditionalClassPath Setting....................................................... 3-27
3.3.5 Restart in Online Mode .............................................................. 3-31
3.3.6 Duolet Execution ........................................................................ 3-32
TI 34P02K26-01E 2002.12.15-00
2003.07.25-00
<Int> <Ind> <Rev> Toc-2
3.4 Mail Examples........................................................................................ 3-40
3.4.1 Mail Replyer Creation ................................................................ 3-40
3.4.2 Mail Function.............................................................................. 3-41
3.4.3 Compile and File Transfer.......................................................... 3-44
3.4.4 E-mail Function Setting.............................................................. 3-45
3.4.5 Execution and Operation Confirmation...................................... 3-50
3.5 FTP Examples ........................................................................................ 3-52
3.5.1 Creation of PeriodicCopy ........................................................... 3-52
3.5.2 Execution and Operation Confirmation...................................... 3-56
3.6 Examples for the Control Data Access Class .................................... 3-57
3.6.1 Reverser Creation...................................................................... 3-57
3.6.2 Device Label .............................................................................. 3-58
3.6.3 Definition of the Device Label Variable ...................................... 3-59
3.6.4 Code Creation ............................................................................ 3-64
3.6.5 Execution ................................................................................... 3-70
3.7 Creation of Combined Applications .................................................... 3-72
3.7.1 Application Outline ..................................................................... 3-72
3.7.2 Preparing the Control application .............................................. 3-73
3.7.3 Code Creation ............................................................................ 3-74
3.7.4 Execution Preparation................................................................ 3-80
3.7.5 Execution and Operation Confirmation...................................... 3-81
Revision......................................................................................................i
TI 34P02K26-01E 2002.12.15-00
2003.07.25-00
<Toc> <Ind> <1. Outline > 1-1
1. Outline
This chapter shows the outline of the FCN/FCJ Java function of the STARDOM
autonomous controller FCN/FCJ (hereinafter abbreviated as FCN/FCJ).
The FCN/FCJ Java function is the function for execution of Java applications on
FCN/FCJ. Control functions programmed with IEC 61131-1 run on FCN/FCJ. The
FCN/FCJ Java function runs independently from these control functions, and Java
functions for monitoring of control data, alarm notification, logging, etc. can be created.
Controller
<<Realtime OS>>
Hardware
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <1. Outline > 1-2
E-mail notification
Storage of trend of alarm messages Java development
data etc. environment
Etc (SMTP)
Controller
Development Environment
y Use of the development environment
JDK (Java Development Kit) and the FCN/FCJ Java application development kit can
be used to develop user original Java application.
y Downloading to FCN/FCJ
A developed Duolet can be loaded to the system card of the FCN/FCJ with ftp.
The user can use this platform to create original Duolets for alarm detection algorithms,
I/O diagnosis, etc. In addition, the following functions also can be implemented for
FCN/FCJ.
y Data monitoring using a Web server
y Alarm notification (e-mail) or operation commands (execution of functions by
receiving e-mail) using sending/receiving e-mail
y Original HTML tag definitions and executions using Web base applications
y Storage of FCN/FCJ data using the FTP client, server function
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <1. Outline > 1-3
Class libraries
The following class libraries used with JDK are offered.
y JADE class library
This is the class library for multitask execution management of Java applications on
FCN/FCJ.
y JEROS class library
This is the class library for system management.
y Control data access library
This is the class library for accessing control function data.
Duolet monitor
This is the software for monitoring Java applications running on FCN/FCJ on a Windows
machine.
Java applications running on FCN/FCJ can be monitored on Windows, and this is used
for debugging of Java applications.
JEROS emulator
This is the software for emulation of the FCN/FCJ Java environment on Windows. This
is used for debugging of Java applications for FCN/FCJ on Windows.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <1. Outline > 1-4
Execution Environment
y Hardware
Machine type : STARDOM autonomous controller FCN/FCJ (*1)
y Software
FCN/FCJ basic software : R1.20.01 or later (*2)
*1: The FCN/FCJ Java function cannot be used with FCN with a dual CPU configuration.
*2: With the FCN/FCJ basic software, the software with Java function must be selected for the basic specifications
code.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <1. Outline > 1-5
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <1. Outline > 1-6
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <2. Function Specifications > 2-1
2. Function Specifications
This chapter explains the outline of the FCN/FCJ Java function.
Correspondence
Hardware
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <2. Function Specifications > 2-2
y JADE class
This is a multitask management system for execution of Java applications called
Duolet.
y Control data access class
Class library for access to data of control functions programmed with IEC 61131-3.
Java applications
FCN/FCJ executes Java applications called Duolet which is managed by the JADE
class. Duolets can use the class provided by JADE, Java standard class and class
library provided by the JEROS system class, control data access class.
System setting
The operation of the JEROS system service is decided by a number of system files
which are read in only once at the time of system start. These configurations are set on
a maintenance homepage using a Web browser. For the operation, please refer to
STARDOM FCN/FCJ Guide (IM 34P02Q01-01E).
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <2. Function Specifications > 2-3
File system function Reads/writes files compatible with the MS-DOS file system. Java System Class
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <2. Function Specifications > 2-4
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <2. Function Specifications > 2-5
Duolet start definition file MDUOLOAD.PRP Setting of the Duolet loaded at the time of FCN/FCJ start
E-mail setting file DEVMAIL.PRP E-mail function
Network function
Host name definition file HOSTS Setting of the e-mail server used for the FCN/FCJ Java function
etc.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <2. Function Specifications > 2-6
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial > 3-1
3. Tutorial
This chapter explains the installation of the FCN/FCJ Java function, environment
setting, and the creation and execution of programs.
Default
Software used for this
Software type URL for the software suppliers installation
tutorial
Folder
Java development
environment Sun Microsystems Corporation
JDK1.1.8 C:\jdk1.1.8
(JDK1.1.8 or later) http://java.sun.com/Products/OV_jdkProducts.html
(*1)
Microsoft Corporation
Web browser Internet Explorer 5.5 SP2
http://www.microsoft.com/ie_intl/ja
C:\YOKOGAWA\
FCN/FCJ Java
FCN/FCJ Java application FCN-
application Yokogawa Electric Corporation
development kit (NT755FJ) FCJ\JavaApDevel
development kit
opmentKit
However, the following software already shall have been installed on the machine.
y Web browser :Internet Explorer 5.5 SP2
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial > 3-2
Installation of JDK1.1.8
The JDK1.1.8 software is downloaded from the Web site java.sun.com and is installed.
Run the downloaded file and install it following the instructions.
Installation method
Set a CD-ROM of the FCN/FCJ software medium and start the installer by selecting
"Product software", "FCN/FCJ Java application development kit". Then install following
the installer instructions.
Table: Folders specified at the time of installation
Folder Explanation Default
Development Kit Folder for storage of the main body of this kit. It is composed C:\YOKOGAWA\FCN-
installation folder of folders for class libraries, documents, sample programs, etc. FCJ\JavaApDevelopmentKit
For the folder configuration, refer to the following
"Development Kit folder configuration after installation
completion".
JEROS emulator Folder for storage of the operation environment file for the C:\JEROS
operation environment JEROS emulator.
file installation folder For operation of the emulator, a folder named "JEROS" must
exist directly under the drive on which Windows is installed.
Accordingly, the default name for the folder should not be
changed, unless there are special reasons.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial > 3-3
Install Folder
(Default = C:\YOKOGAWA\FCN-FCJ)\JavaApDevelopmentKit)
Lib
Document
Tool
Sample
Projcts
Template
Figure: Folder configuration for the FCN/FCJ Java Application Development Kit
Install Folder
Folder for storage of the development kit is specified at the time of installation. The
installer sets the name of this folder to the environment variable
SDCS_JAVAKIT_TOPDIR. This kit uses batch files for program compiling, file transfer,
etc., and these batch files refer to this environment variable.
Lib
Folder for storage of the class library for this kit.
When compiling a program without use of the batch files offered by this kit, specify the
Jar file under this folder in the environment variable CLASSPATH.
Document
Folder for storage of Online help, API references, and PDF files for this technical
information.
Tool
The program for batch transfer of files to FCN/FCJ (FcxRestore.exe), the batch file for
running Duolet monitor, and other development support tools are stored in this folder.
Sample
The sample programs explained in this technical information are stored in this sample in
the project folder format (explained later).
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial > 3-4
Projects
Folder consolidating several project folders (explained later). When creating a new
project folder, it should be created under this folder.
Template
Template for project folders. Template of batch files for compiling and transfer to
FCN/FCJ and template of program source files are stored in this folder.
Please copy this folder and use the copy when creating a new project folder.
Project folder
The unit for development of one Java application is called the project, and the folder for
storage of this project is called the project folder.
The following figure shows the configuration of the project folder created at the time of
installation.
Install Folder
Project
Projects
Template
CallJavac.bat
CallWinJade.bat
Ftp2Fcx.bat
src
Package1
Template.java
class
FtpWork
MNT
JEROS
Figure: Folder configuration in the project folder
The configuration of each folder and file under the project folder will be explained by
referring template folder.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial > 3-5
src
Folder for storage of the Java program source file (extension .java).
For Java, the created classes are categorized as a function called package. The source
file (Template.java) categorized as a package called "Package1" is provided under
template folder.
The following is the source file for Template.java.
Package pakage1;
Public class app
{
}
class
Folder for storage of the compiled result. When the batch file (CallJavac.bat) for
compiling is executed, the class file (extension .class) representing the compile result is
output to this folder or under.
FtpWork
Work folder for transfer of Java application files to FCN/FCJ.
When the batch file (Ftp2Fcx.bat) for file transfer is executed, the class files under Class
file are converted to Jar format and are copied to a suitable position under this folder.
If other original files such as parameter files are to be transferred at the same time, they
will be transferred to FCN/FCJ when they are placed under this folder.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial > 3-6
FtpWork
newProject Copy&Rename
src
class
FtpWork
FtpWork
Copy
Projects
Mail
src
class
FtpWork
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-7
Compiling Work on a PC
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-8
JADE
Event
Application Device
Duolet Duolet
Action
Figure: JADE and Duolet
Duolet
ApplicationDuolet DeviceDuolet
User User
application application
Figure: ApplicationDuolet and DeviceDuolet
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-9
Duolet State
A Duolet has a state. Execution is controlled by JADE, and the state transits according
to creation, execution, stop, deletion, etc. The main state types are LOADED and
READY. LOADED indicates the state where the Duolet has been loaded to JADE, and
READY indicates the execution state. The state types other than LOADED and READY
are transitory state types.
NONE
UNLOAD LOAD
LOADED
STOP START
READY
Figure: Duolet state transition
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-10
JADE
EvDevTimer
Sleeper DevTimer
At the time of Duolet start, the Sleeper makes an event occurrence request to DevTimer.
At the time of termination, it makes an event stop request.
At the time of start, the Duolet once transits to START state. As the start() method is
called at this time, an event occurrence request procedure is described here in the
Sleeper. In the same way, at the time of termination, Duolet transit to STOP state and
as the contents of the stop() method are processed, the event stop procedure is
described.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-11
Source Code
Sample code Sleeper.java
package jp.co.yokogawa.stardom.sample;
import jeros.ade.*;
/**
Sleeper: Sample program for Application Duolet
An event is received every 5 seconds from DevTimer, it sleeps
for 2 seconds when it receives the event.
*/
public class Sleeper extends ApplicationDuolet
{
/**
Event handling method
This method is called by event notification from DevTimer.
*/
public void notificationCall(EvObject ev) {
if(ev instanceof EvDevTimer){
// Output to the log
DevSysLog.logInfoMessage(this,"Notified...");
try {
// Sleep for 2 seconds
Thread.sleep(2000);
}catch(InterruptedException ex) {
DevSysLog.logErrorMessage(this,"Interrupted Exception" + ex ;
}
DevSysLog.logInfoMessage(this,"Done...");
} else {
// When an unexpected event has been received
DevSysLog.logErrorMessage(this,"Unexpected notification"+ ev);
}
return;
}
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-12
/**
Duolet start processing method
Specification for DevTimer to notify an event every 5 seconds
*/
public boolean start() {
try {
// Specification for event notification every 5 seconds
DevTimer.setNotify(this,5000);
} catch(IllegalArgumentException ex) {
DevSysLog.logErrorMessage(this,"IlligalParameter in start " +
ex);
return false;
} catch(NoMoreRequestException ex) {
DevSysLog.logErrorMessage(this,"NoMoreRequest in start " + ex);
return false;
}
return true;
}
/**
Duolet stop processing
Event notification is stopped.
*/
public boolean stop() {
// Stop event notification
DevTimer.resetNotify(this);
return true;
}
}
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-13
Project creation
Create a project for creation of a Sleeper program.
Normally, the Template folder under the Projects folder is copied and the name is
changed to Sleeper for use.
Install Folder
Projects
Template
src
class
FtpWork
newProject Copy&Rename
src
class
FtpWork
Figure: Normal method for project creation
Here, a sample program is used. As shown in the following figure, copy the Sleeper
folder under the Sample folder to the Projects folder and use it.
Install Folder
Sample
Sleeper
src
class
FtpWork
Copy
Projects
Sleeper
src
class
FtpWork
Figure: Copy of the Sleeper project
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-14
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-15
3.2.4 Compiling
Compiling is done with the compiling batch file CallJavac.bat directly under the project
folder.
Run the batch file CallJavac.bat directly under the copied Sleeper folder.
When compiling has been completed, the compiled class file Sleeper.class is created
under the Class folder of the Sleeper folder.
An error caused by a code error as shown below. Modify the respective location and
compile again.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-16
Start of WinJade
WinJade is started with the WinJade start batch file CallWinJade.bat directly under the
project folder.
Run CallWinJade.bat directly under the copied Sleeper folder.
After start, the following screen is displayed.
Figure: WinJade
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-17
Duolet Loading
For operation of a Sleeper, the Sleeper must be loaded onto WinJade.
Select [Load Duolet...] from the [File] menu.
Enter 'Sleeper1' as the Instance Name in the LOAD DUOLET dialog box and enter
'jp.co.yokogawa.stardom.sample.Sleeper' as the Class Name. On JADE, multiple
instances can be created from one Duolet. Each instance is identified by an Instance
Name. For this reason, the Instance Name must be unique.
When [OK] is pressed, 'sleeper1' is loaded and the following window is displayed as
shown below. With this, the Sleeper has been loaded onto JADE. This can be confirmed
by the display of LOADED at the right below Sleeper1. This displays the Duolet state.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-18
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-19
Duolet Execution
When the state is LOAD, the Sleeper is not yet running. In order to run (execute) the
sleeper, it is necessary to change the Sleeper state to READY.
1. Click sleeper1.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-20
When [OK] is clicked in the dialog box, the Sleeper starts and the following screen
appears. When the Sleeper is started, %Timer is loaded to the DeviceDuolet and is
executed. This is DevTimer.
The arrow from DevTimer to sleeper1 indicates "Duolet event notification", and timer
event notification with each timer period can be confirmed.
Operation confirmation
The log output is displayed in the 'LOG WINDOW'. Please confirm that messages are
displayed periodically according to the Sleeper operation.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-21
AdditionalClassPath setting
Execution, debugging
NOTE
For running a Java program on FCN/FCJ, "Use Java" must be checked on the Resource Configurator
(tool for basic setting/operation of FCN/FCJ, included with the basic software).
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-22
Maintenance Mode
Restart FCN/FCJ in maintenance mode as preparation for transfer of the created Java
program to FCN/FCJ.
Open the FCN/FCJ maintenance homepage.
The URL of the maintenance homepage is the IP address/MNT/ of http://FCN(FCJ).
Open this URL with the browser.
The user name and the password at the time of connection are as follows.
y User name :stardom
y Password :YOKOGAWA
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-23
When the [Maintenance Menu] link is clicked, the following page is displayed.
Click [Reboot].
Click [Reboot].
The Reboot FCX page appears. Select [Reboot (Maintenance Mode)] and click [OK].
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-24
When rebooting starts, the following screen appears.
It takes some time until the maintenance mode starts. Look at the FCN/FCJ LED and
confirm the start in maintenance mode.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-25
When creating a JAR file, use the MS-DOS8.3 format (file name: 8 bytes, extension: 3
bytes (JAR)) for the file name.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-26
Log in with the FTP user name 'MNT' and the password 'duonusMNT'.
Move to /JEROS/SYS/CLASSES/PJT
ftp> cd sys/classes/pjt
250 Changed directory to "/JEROS/SYS/CLASSES/PJT".
ftp> bin
Binary mode
200 Type set to I, binary mode.
ftp> put userjava.jar
Transfer userjava.jar.
200 Port set okay.
150 Opening BINARY mode data connection for
/JEROS/SYS/CLASSES/PJT/USERJAVA.JAR
(192.168.50.1,1220).
226 Transfer complete.
ftp: 7945 bytes sent in 0.03Seconds 264.83Kbytes/sec.
ftp> quit
End of FTP
221 Bye...see you later.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-27
Maintenance Homepage
OK
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-28
Open the Maintenance Menu screen of FCN/FCJ. Click the [Edit] link.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-29
Select [JEROS Basic Setting File] and click [OK].
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-30
Add the path of the transferred Jar file to the AdditionalClassPath.
Add a colon (:) after AdditionalClassPath =/JEROS/SYS/CLASSES/STARDOM.JAR and
set the path of the added Jar file.
y AdditionalClassPath =/JEROS/SYS/CLASSES/STARDOM.JAR:/JEROS/SYS/CLAS
SES/PJT/USERJAVA.JAR
Click [OK].
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-31
Select the [Reboot] link on the FCX Maintenance Menu page. The Reboot FCX page is
displayed. Select [Reboot (Online Mode)] and click [OK].
Reboot
(Online Mode)
Starting in online mode takes some time. Look at the FCN/FCJ LEDs to confirm that
start in online mode has been performed (HRDY: Lit, RDY: Lit, CTRL: Not lit).
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-32
Connection to FCN/FCJ
The Duolet Monitor is used to execute a Duolet on FCJ/FCN. Duolet Monitor is a tool for
monitoring the operation status of a Duolet on FCN/FCJ.
Start Duolet monitor from the Start menu by [Programs] - [YOKOGWA FCN-FCJ] -
Duolet Monitor].
For connection to FCN/FCJ, select [Connection...] from the Duolet Monitor [File] menu.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-33
The CONNECT TARGET dialog is displayed. Enter the IP address (192.168.50.10) of
the connection destination FCJ/FCN for [System Name] and click [Connect].
Figure: Connecting
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-34
The following screen is displayed when the connection has been completed.
NOTE
When an error has occurred at the time of connection:
The following error screen may be displayed at the time of connection. This error occurs when the host
name specified in the JEROS basic setting file (DUONUS.PRP) does not match the name specified for
[System Name] in the [Connect Target] dialog.
For example, the default host name for FCJ is 'FCX', but when connection is made with specification of
192.168.50.10 as the IP address, as in the case of the example, an error message is displayed
because FCX and 192.168.50.10 are not the same. In this case, edit the JEROS basic setting file to
change the host name to 192.168.50.10, or set the host name so that 'FCX' is recognized as the IP
address (192.168.50.10) and use FCX as the system name at the time of connection.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-35
Sleeper Execution
In the same way as in the debugging section, the Sleeper must be loaded for execution
of the Sleeper.
Select [Load Duolet...] from the [File] menu.
Then enter the following at the LOAD DUOLET dialog.
y Instance Name :sleeper1
y Class Name :jp.co.yokogawa.stardom.sample.Sleeper
For execution of the Sleeper, select sleeper1 and select [Start...] from the [Duolet] menu.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-36
Confirm the Sleeper operation in the LOG WINDOW of the Duolet Monitor.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-37
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-38
2. Select [Duolet Loader Configuration File] and click [OK].
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-39
3. Add the Sleeper setting.
Specify the class name and the instance name after Duolet2.
Use the following notation for the Sleeper.
y Duolet2=jp.co.yokogawa.stardom.sample.Sleeper,sleeper1
4. Click [OK].
5. Reboot in online mode.
Use Duolet Monitor for operation confirmation. Confirm that the Sleeper runs after
rebooting.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-40
When the user sends an e-mail to duolet@stardom.jp, the MailReplyer receives the e-
mail. The MailReplyer checks the e-mail sender addressee and reply the contents as
they are to the sender addressee. The subject becomes the subject of the original e-
mail, preceded by 'Re:'.
FCN(FCJ)
User
MailReplyer Reply e-mail Receive the (stardom_user@
stardom.jp)
reply e-mail
Figure: MailReplyer
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-41
3: Reply mail
2: Reception JADE 1: Periodic reception
creation
notification of mail (POP3) POP3 server
MailReplyer DevMail
SMTP server
4: Mail sending 5: Mail sending
(SMTP)
Figure: MailReplyer operation
MailReplyer receives an event from DevMail. As this is an event driven type, this
MailReplyer must be ApplicationDuolet. As the received notification event request and
stop are made at the time of Duolet start and stop, they must be described in start() and
stop().
E-mail to a Duolet adds the information required for sending the e-mail to the desired
Duolet as the 'Duolet extended header' to the body of the e-mail.
MailReplyer uses the item 'DataName' in the Duolet extended header. MailReplyer
checks the value of DataName and receives only e-mail with the same value. The
notation for the items in the Duolet extended header is 'item name = value'. The Duolet
extended header and the normal body of the e-mail are separated by one space.
An example for the body of an e-mail sent to MailReplyer is shown below.
DataName=sample
Hello, Duolet!
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-42
Source Code
The MailReplyer source code is shown below.
MailReplyer.java
package jp.co.yokogawa.stardom.sample;
import jeros.ade.*;
import jeros.ade.mail.*;
import java.util.Date;
/**
jp.co.yokogawa.stardom.sample.MailReplyer
/**
Event handler
*/
public void notificationCall(EvObject ev){
if (ev instanceof EvDevMail){
DevSysLog.logInfoMessage(this,"Notified ... ");
try{
String to = mail.getReplyToAddress(true);
if (to == null){
to = mail.getFromAddress(true);
}
DevSysLog.logInfoMessage(this,to);
DevSysLog.logInfoMessage(this,subject);
DevSysLog.logInfoMessage(this,body);
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-43
DevMail.sendMessage(this,to,subject,body);
DevSysLog.logInfoMessage(this,"Done");
}catch(MailException ex){
DevSysLog.logErrorMessage(this,"Mail Exception in
notificationCall: "+ ex);
}
}else{
DevSysLog.logErrorMessage(this,"Unexpected "+ ev);
}
return;
}
/**
Staring process
*/
public boolean start(){
try{
DevMail.setNotify(this,DATA_NAME,false);
DevMail.startSender();
DevMail.startReceiver();
}catch(MailException ex){
evSysLog.logErrorMessage(this,"Mail Exception in start: " + ex);
return false;
}
return true;
}
/**
Stopping process
*/
public boolean stop(){
try{
DevMail.resetNotify(this,DATA_NAME,false);
}catch(MailException ex){
DevSysLog.logErrorMessage(this,"Mail Exception in stop: " + ex);
return false;
}
return true;
}
}
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-44
Copy the MailReplyer folder under the Sample folder to the Projects folder.
Confirm the contents of the MailReplyer.java file under the src folder under the copied
MailReplyer folder.
Execute CallJavac.bat directly under the MailReplyer folder and compile the
MailReplyer.
Consolidate the compiled class files in a Jar file and transfer this file to FCN/FCJ.
The procedure is as shown below.
1. Change to maintenance mode
2. Open Ftp2Fcx.bat directly under the MailReplyer folder with Notepad etc. and
modify the destination FCN/FCJ IP address.
3. Execute Ftp2Fcx.bat for Jar file creation and transfer to FCN/FCJ.
4. Add userjava.jar to AdditionalClassPath of the "JEROS Basic Setting File".
5. Change to online mode
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-45
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-46
3. Click [OK].
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-47
4. Click the [Edit] link.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-48
6. The editing screen for the mail setting file appears.
The notation in the setting file is divided into sections for each function.
(As the default is commented out, please delete the "#" symbol.)
Change the following location in the [General Settings] section.
y PopUser=duolet
Change the following locations in the [Setting Items for Sending Mails] section.
y SmtpServer=smtp_server
y Domain=stardom.jp
y TrueName=Duolet
y SendCycle=1
Change the following locations in the [Setting Items for Receiving Mails] section.
y PopPassword=passwd
y PopServer= pop3_server
y RecvCycle=1
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-49
9. The editing screen for the host name definition file appears.
Add the following two lines to the final line of this file.
192.168.10.1 smtp_server
192.168.10.2 pop3_server
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-50
Operation Confirmation
Send e-mail to MailReplyer to confirm reply e-mail.
Mail is sent according to the following contents.
y Address : duolet@stardom.jp
y Return address : stardom_user@stardom.jp
y Subject : Hello!
DataName=sample
Hello, duolet!
NOTE
The FCN/FCJ function is compatible only with mail in the TEXT format. Be sure to send mail in TEXT
format, as this function is not compatible with the HTML format etc.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-51
Please confirm that the mail has been sent properly. The following e-mail is replied soon.
The replied e-mail includes the header information of the sent e-mail in the body of the
e-mail.
NOTE
The default for the FCN/FCJ Java execution environment corresponds to English. When Japanese is
used in the e-mail contents, the Java start parameters must be modified.
When Japanese is used in the e-mail contents, modify the following part of the JEROS basic setting file
(DUONUS.PRP).
Before modification: JavaStart=jeros.ade.SystemManager /JEROS/CONF/SYS/JADE.PRP
After modification: JavaStart=-Duser.language=ja -Duser.region=JP -Dfile.encoding=SJIS jeros.ade.Sys
temManager /JEROS/CONF/SYS/JADE.PRP
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-52
The FTP server name etc. in the PeriodicCopy example are as follows.
y FTP server name : ftp_server(IP address:192.168.10.3)
y FTP user name : stardom
y FTP password : YOKOGAWA
y Acquired source file : /data.txt
y Write destination file : /copy/data.txt
PeriodicCopy receives an event from the periodic timer DevTimer every hour and gets
the data.txt file. The acquired contents are written to /copy/data.txt.
FTP
JAD
2: Get
"/data txt"
PeriodicCo
p
1 Even 3: Write to
"/copy/data.txt".
DevTimer
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-53
Code Creation
For access to the FTP server, an object of the FtpClient class provided by JEROS is
created. The server name, the user name, and the password are specified as the
Constructor arguments.
The get method is called to get a file. The file name and the transfer mode are specified
as arguments. The transfer mode is made true for ASCII and false for binary. The
acquired file is stored in a byte-type array of the return value of the get method.
The chdir method is used to change the directory. The argument is the directory name.
client.chdir("/copy");
The put method is used to write the file. The data of the byte array type, the write
destination file name, and the transfer mode are specified as the arguments.
client.put(data,"data.txt",false);
Supplement: When the file acquired from the FTP server is stored on
the FCN/FCJ system card
It is possible to save the data directly from the FTP server to a file instead of storing the
file data in the byte array.
In this case, the arguments of the get method become as follows.
It is also possible to send a file on FCN/FCJ as it is to the FTP server. This becomes as
shown below.
For details, refer to the FtpClient item in the 'JEROS API reference' of the online
document.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-54
Source Code
PeriodicCopy.java
package jp.co.yokogawa.stardom.sample;
import jeros.ade.*;
import jeros.ftp.FtpClient;
import jeros.ftp.FtpException;
import java.util.Date;
/**
jp.co.yokogawa.stardom.sample.PeriodicCopy
FTP sample
*/
public class PeriodicCopy extends ApplicationDuolet
{
private static final int COPY_PERIOD = 3600000;
/**
Event Handler
*/
public void notificationCall(EvObject ev) {
if(ev instanceof EvDevTimer) {
try {
DevSysLog.logInfoMessage(this,"Notified... ");
DevSysLog.logInfoMessage(this,"Done");
} catch(FtpException ex) {
DevSysLog.logErrorMessage(this,"Error "+ ex);
}
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-55
} else {
DevSysLog.logErrorMessage(this,"Unexpected "+ ev);
}
return;
}
/**
Starting Process
*/
public boolean start() {
try {
DevTimer.setNotify(this,COPY_PERIOD);
} catch(IllegalArgumentException e) {
DevSysLog.logErrorMessage(this,"IlligalParam in start");
return false;
} catch(NoMoreRequestException e) {
DevSysLog.logErrorMessage(this,"NoMore");
return false;
}
return true;
}
/**
Stopping Process
*/
public boolean stop() {
DevTimer.resetNotify(this);
return true;
}
}
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-56
Execution Preparation
Copy the PeriodicCopy folder under the Sample folder to the Projects folder.
Compile the PeriodicCopy.java and transfer it to FCN/FCJ.
Modify the host name definition file and set the IP address of the FTP server.
Modify data.txt as the acquisition source file on the FTP server. Also create the directory
/copy as the write destination. Please note that an error message (FtpException) will
occur at the time of execution when these files and/or directories do not exist.
Execution
Load PeriodicCopy with copy1 as the instance name. After loading, execute copy1.
Operation Confirmation
Confirm that the file on the FTP server is copied every hour from /data.txt to
/copy/data.txt.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-57
4:Calculation of
the DO value 2:DI value 3:DI value
acquisition acquisition
Data access
Reverser IOHandler API
5:DO value 6:DO output
setting
1:Timer event
DevTimer
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-58
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-59
1. Start LogicDesigner.
2. Select [New Project] from the [File] menu.
3. Select 'STARDOM FCX' and click [OK].
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-60
4. Double-click [DeviceLabelDefinition].
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-61
5. The device label variable definition dialog is displayed.
Add the following items.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-62
The OPC check of the device label variable must be set to ON to access control data
variables from the FCN/FCJ Java function.
1. Double-click Global_Variables and display the following table.
2. Check the OPC item for I_D_01_BOOL and O_D_17_BOOL in the table.
DI has two variables I_D_01 and I_D_01_BOOL. As reference to the boolean type is
made with the Duolet, OPC is checked for I_D_01_BOOL. The same applies for
DO.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-63
The project must be built to make the device label variable effective.
1. Set the IP address 192.168.50.10 of FCJ to the target (TargetSetting).
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-64
C:\YOKOGAWA\FCN-
FCJ\LogicDesigner\Projects\reverser\C\Configuration\R\FCX01\ADLST.csv
After data acquisition, the elements are taken out from the vector. The DI data values
are acquired as a boolean type. For a boolean type, the notation is as follows.
WriteVarData is used to write the value. The arguments are the array of the device label
variable name, the vector of the value to be written, and the array for error storage. In
case of DO data, an object with a boolean value entered for CSDCSBoolValue is stored
in the array.
The return value is the error status.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-65
DuoletManager.unloadDuolt(Duolet instance)
Supplement
Class for array data access:
The array data access class is used for access to large-volume control applications. The details are
explained in the section for the creation of combined applications in this tutorial.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-66
Source Code
The source code for Reverser and IOHandler is shown in the following.
Reverser.java
package jp.co.yokogawa.stardom.sample;
import jeros.ade.*;
import java.io.IOException;
/**
jp.co.yokogawa.stardom.sample.Reverser
I/O sample
*/
public class Reverser extends ApplicationDuolet
{
private IOHandler handler;
/**
Event Handler
*/
public void notificationCall(EvObject ev) {
if(ev instanceof EvDevTimer) {
try {
DevSysLog.logInfoMessage(this,"Notified... ");
// reverse output
boolean diValue = handler.readDI();
DevSysLog.logInfoMessage(this,"DI : "+ diValue);
handler.writeDO(doValue);
DevSysLog.logInfoMessage(this,"Done");
} catch(IOException ex) {
DevSysLog.logErrorMessage(this,"Error "+ ex.getMessage());
}
} else {
DevSysLog.logErrorMessage(this,"Unexpected "+ ev);
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-67
}
return;
}
/**
Starting Duolet
*/
public boolean start() {
try {
// load duolet
handler =(IOHandler)DuoletManager.loadDuolet("jp.co.
yokogawa.stardom.sample.IOHandler","IOHandler1");
DuoletManager.startDuolet(handler);
DevTimer.setNotify(this,5000);
} catch(Exception ex) {
DevSysLog.logErrorMessage(this,ex.getMessage());
return false;
}
return true;
}
/**
Stopping Duolet
*/
public boolean stop() {
try{
// unload duolet
DuoletManager.stopDuolet(handler);
DuoletManager.unloadDuolet(handler);
}catch(DuoletControlException ex){
DevSysLog.logErrorMessage(this,ex.getMessage());
return false;
}
DevTimer.resetNotify(this);
return true;
}
}
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-68
IOHandler.java
package jp.co.yokogawa.stardom.sample;
import jeros.ade.*;
import jp.co.yokogawa.stardom.dataaccess.*;
import java.util.Vector;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
/**
jp.co.yokogawa.stardom.sample.IOHandler
I/O sample
*/
public class IOHandler extends DeviceDuolet
{
// Device Label Variable names
private String diTags[] = {"@GV.I_D_01_BOOL"};
private String doTags[] = {"@GV.O_D_17_BOOL"};
/**
Read DI
Exception : java.io.IOException
*/
public boolean readDI() throws IOException{
errors[0] = 0;
long status=0;
try{
// read DI
status = access.ReadVarData(diTags,varData,errors);
}catch(Exception ex){
throw new IOException("readDI() Not_Succes " +
ex.getMessage());
}
// check status
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-69
if(status != CSDCSAppDataAccess.S_SUCCEED || errors[0] != 0)
{
throw new IOException("readDI() Not_Succes errors[0]=" + errors[0]);
}
/**
Write DO
Exception : java.io.IOException
*/
public void writeDO(boolean value) throws IOException{
varData.removeAllElements();
varData.addElement(new CSDCSBoolVal(value));
errors[0] = 0;
long status = 0;
try{
// read Write
status = access.WriteVarData(doTags,varData,errors);
}catch(java.io.UnsupportedEncodingException ex){
throw new IOException("writeDO() Not_Succes " +
ex.getMessage());
}
// check status
if(status != CSDCSAppDataAccess.S_SUCCEED || errors[0] != 0) {
throw new IOException("writeDO() Not_Succes errors[0]
=" + errors[0]);
}
}
}
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-70
3.6.5 Execution
Copy the Reverser folder under the Sample folder to the Projects folder.
Compile the Duolet according to the normal procedure and transfer it to FCJ.
The control application must be downloaded before Duolet execution.
1. Start LogicDesigner.
2. For loading to FCJ, select [Project Control] from the [Online] menu.
3. The following dialog boxes are displayed.
Click [Download].
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-71
5. Click [Cold] to execute the control application.
Operation Confirmation
Execute Reverser and confirm the operation. Confirm that DO becomes the reversed
output of DI. Also confirm that the value is displayed in the LOG WINDOW.
NOTE
The JEROS emulator (WinJade) is not compatible with the control data access class. Please test
Duolets using the control data access class on FCN/FCJ.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-72
2.1:Value
DevMail
acquisition
2.2:File
1.3:Value
transmission 1.2:Value acquisition
acquisition Data
FTP AnalogReade
Logger access API
function
1.4:Log 1.1:Periodic
creation 1 min timer DevTime
In this sample, the settings for the FTP server and the e-mail server are as follows.
y FTP server :ftp_server(IP address:192.168.10.3)
y FTP user :stardom
y FTP password :YOKOGAWA
y SMTP server :smtp_server(IP address:192.168.10.1)
y E-mail destination :stardom_user@stardom.jp
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-73
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-74
Source Code
The code of Logger and AnalogReader is shown below.
Logger.java
package jp.co.yokogawa.stardom.sample;
import jeros.ade.*;
import jeros.ade.mail.*;
import jeros.ftp.*;
import java.io.*;
import java.util.Date;
/**
jp.co.yokogawa.stardom.sample.Logger
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-75
/**
log writing
*/
private void writeLog(String data){
//DateFormat timeFormatter = DateFormat.getTimeInstance();
//String line = timeFormatter.format(Calendar.getInstance().getTime())
String line = new Date() + " , " + "A_IN_0" + " , "+ data;
try{
PrintWriter writer = new PrintWriter(new
FileWriter(LOG_FILE_DIR+"/"+LOG_FILE_NAME,true));
writer.println(line);
writer.close();
}catch(IOException ex){
DevSysLog.logErrorMessage(this,"File write error :"+
ex.getMessage());
}
}
/**
Preparation of a new file
*/
private void newFile(){
// Directory creation
File dir = new File (LOG_FILE_DIR);
if (!dir.exists()){
dir.mkdirs();
}
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-76
}
/**
Sending e-mail to stardom_user@stardom.jp
*/
private void sendMail(){
String to = "stardom_user@stardom.jp";
String subject = "FCJ report";
String body = "Logging data is modified at " + new Date();
DevSysLog.logInfoMessage(this,"Mail sending");
try{
DevMail.sendMessage(this,to,subject,body);
}catch(MailException ex){
DevSysLog.logErrorMessage(this,"Mail Exception in notificationCall: "+ ex);
}
}
/**
Sending the log file to ftp_server
*/
private void putFile(){
FtpClient ftp = null;
DevSysLog.logInfoMessage(this,"File transfer");
try {
ftp = new FtpClient(serverName,userName,password);
ftp.chdir("/SAMPLE");
ftp.put(LOG_FILE_DIR + "/" + LOG_FILE_NAME,LOG_FILE_NAME,true);
} catch(FtpException ex) {
DevSysLog.logErrorMessage(this,"FTP Error "+ ex);
}finally{
try{
if(ftp != null) {
ftp.close();
}
}catch(FtpException ex){
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-77
DevSysLog.logErrorMessage(this,"Closing FTP connection failed. "+ ex);
}
}
}
/**
Receiving an event
*/
public void notificationCall(EvObject ev) {
if(ev instanceof EvDevTimer) {
count ++;
if (count == 1){
newFile();
}
// AI reading
String dataText = null;
try {
dataText = String.valueOf(reader.read());
}catch(IOException ex){
DevSysLog.logErrorMessage(this,ex.getMessage());
dataText="Read_Error";
}
// log writing
writeLog(dataText);
if (count == DATA_COUNT){
// Processing every hour
putFile();
sendMail();
count = 0;
}
} else {
DevSysLog.logErrorMessage(this,"Unexpected "+ ev);
}
return;
}
/**
Starting Duolet
*/
public boolean start() {
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-78
count = 0;
try {
// load duolet
reader =(AnalogReader)DuoletManager.loadDuolet("jp.co.
yokogawa.stardom.sample.AnalogReader",
"AnalogReader1");
DuoletManager.startDuolet(reader);
DevTimer.setNotify(this,READ_PERIOD);
} catch(Exception ex) {
DevSysLog.logErrorMessage(this,ex.getMessage());
return false;
}
return true;
}
/**
Stopping Duolet
*/
public boolean stop() {
try{
// unload duolet
DuoletManager.stopDuolet(reader);
DuoletManager.unloadDuolet(reader);
}catch(DuoletControlException ex){
DevSysLog.logErrorMessage(this,ex.getMessage());
return false;
}
DevTimer.resetNotify(this);
return true;
}
}
AnalogReader.java
package jp.co.yokogawa.stardom.sample;
import jeros.ade.*;
import jp.co.yokogawa.stardom.dataaccess.*;
import java.util.Vector;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
/**
jp.co.yokogawa.stardom.sample.AnalogReader
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-79
/**
Read AI
Exception : java.io.IOException
*/
public int read() throws IOException{
errors[0] = 0;
vars.removeAllElements();
infos.removeAllElements();
long status=0;
try{
// read @GV.A_IN array
status = access.ReadVarAryData(diTags,vars,infos,errors);
}catch(Exception ex){
throw new IOException("read() Not_Succes " + ex.getMessage());
}
// check status
if(status != CSDCSAryAppDataAccess.S_SUCCEED || errors[0] != 0) {
throw new IOException("read() Not_Succes errors[0]=" +
errors[0]);
}
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-80
E-mail Server
Make the following settings in the FCJ e-mail setting file (DEVMAIL.PRP).
y SMTP server :smtp_server
y POP3 user name :duolet
HOSTS setting
Set the IP addresses for smtp_server and ftp_server in the FCJ host name definition file
(HOSTS).
FTP Server
Prepare the directory /sample for storage of the log file on the FTP server.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-81
Execution
Perform execution according to the following procedures.
1. Copy the Logger folder under the Sample folder to the Projects folder.
2. Compile the source file.
3. Consolidate the created class files in a Jar file and transfer it to FCJ.
4. Use Logic Designer to download the control application to FCJ.
5. Execute the control application.
6. Use Duolet monitor to load the Logger.
Operation Confirmation
Execute Logger and confirm the operation. The current AI value is displayed every
minute in the LOG WINDOW of Duolet Monitor.
Confirm updating of the file /sample/anlg_dat.csv on the FTP server every hour. The log
file has the following contents.
TI 34P02K26-01E 2003.07.25-00
<Toc> <Ind> <3. Tutorial> 3-82
Also confirm notification via e-mail.
TI 34P02K26-01E 2003.07.25-00
<Int> <Toc> <Ind> i
* : Denotes the release number of the software corresponding to the contents of this Technical Information.
The revised contents are valid until the next edition is issued.
TI 34P02K26-01E 2002.12.15-00
2003.07.25-00