Module 46 - PcVue As A Service

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 25

Advanced

Module 46
PcVue as a service
Contents

1 Introduction 4
1.1 PcVue version 4
1.2 In this module you will learn 4
1.3 Files used in this module 4
1.4 Third party products used in this module 4

2 This function in the PcVue architecture 5


3 Introduction 6
3.1 What is a Windows Service and how does it affect PcVue? 6

4 Configuring PcVue to run as a Service 7


4.1 What components are used when running PcVue as a service? 7
4.2 The Core Management Console 7
4.3 Basic configuration for running PcVue as a service 8
4.3.1 Exercise 12
4.4 Advanced configuration for running PcVue as a service 13
4.4.1 Selecting an alternative Service Account 13
4.4.2 13
4.4.3 Adding dependent services 14
4.5 Warning about use of the Component Registration Utility 14

5 Communicating with other applications when running


as a service 15
6 Tools when Running PcVue as a Service 16
6.1 Configuration Tools 16
6.1.1 Exercise 17
6.2 The Log Monitor 19

7 Practical Example – PcVue Running as a Service and


the Kepware OPC Server 20
7.1 Introduction 20
7.2 Installing and configuring KEPServer EX5 20
7.2.1 Configuring the KEPServer DCOM components 21

Module 46 – PcVue as a service Page 2/25


7.3 Configuring PcVue to use KEPServer EX5 23
7.3.1 Exercise 24

8 Resume 25

Module 46 – PcVue as a service Page 3/25


1 Introduction
1.1 PcVue version
This module is for PcVue version 12.

1.2 In this module you will learn


How to configure and run PcVue as a service

1.3 Files used in this module


None.

1.4 Third party products used in this module


Kepware KEPServer EX5 (KEPServerEx5.exe).
The Kepware files can be found in the Third Party folder of Module 46.

Module 46 – PcVue as a service Page 4/25


2 This function in the PcVue architecture
N/A

Module 46 – PcVue as a service Page 5/25


3 Introduction
3.1 What is a Windows Service and how does it affect PcVue?
A Windows Service is a program like any other intended to run on a Windows
operating system. However programs that run as a Windows Service have particular
characteristics.
They are expected to run for long periods or continuously.
Are often run using the privileges of one of the built-in Service Accounts such as
Local Service, Network Service or Local System (not supported by PcVue).
Do not have any user interface and therefore no user interaction.
Can be started, stopped or paused using the Windows Service Control Manager.
Can be configured to start automatically on system start-up.
The main consequence of running PcVue as a service is that there is no Workspace
(and hence no mimics), and no Event Viewer. However, some of the other
characteristics make it ideal for PcVue in certain roles in multi-station applications.
Real time data acquisition server
Historical data server
Gateway server
Web server

Always remember that there is no HMI when running PcVue as a


service. This means you have to be extra careful about anything
that might generate an error message (that you won’t see!) such
as not reading the license correctly at startup.

The Remote Desktop Services architecture is not yet supported


when PcVue is running as a Windows service.

For further information see the help:


Deployment/Deploying server applications/Running the Supervisor as a
Windows service

Module 46 – PcVue as a service Page 6/25


4 Configuring PcVue to run as a Service
4.1 What components are used when running PcVue as a service?
When running PcVue as a desktop application the functionality is provided by two
main components, the PcVue Core Application (sv32.exe), and the Historical Data
Server Application (hds.exe). You can see these processes in the Windows Task
Manager, Processes tab.
When running PcVue as a service it gets a little more complicated with three
additional components involved.
SV Core Daemon. A service which is responsible for the managing the PcVue
components when it is running as a service.
SV Services. PcVue communicates with its own components, like the Historical
Data Server and Application Explorer, and with external components, like the
KEPware OPC server, using DCOM technology. When running as service an
additional component, SV Services, is required to manage this.
SV Core Session Host. A service only used in applications using Remote Desktop
Services. This is not covered in this module.
When running PcVue as a service you can see the SV Core Daemon and SV Core
Session Host services in Windows Task Manager, Services tab.

4.2 The Core Management Console


Configuring any application to run as a service can be complicated and require an in-
depth knowledge of Windows. However with PcVue it’s relatively straightforward as
most of the default settings are made automatically by the PcVue Core Management
Console. As well as generating the default settings for running PcVue as a service, the
Core Management Console also provides shortcuts to the related Windows
administration components.
The Core Management Console is started from a shortcut in the Tools folder of the
PcVue program group. It must be run with Administrator rights. When first opened
the Overview tab is displayed.

Module 46 – PcVue as a service Page 7/25


Figure 1

[A] Buttons to select PcVue’s startup mode. The default is As a desktop application.
[B] Buttons to manually start and stop PcVue as a service.
[C] When PcVue is running its processes are shown here.
[D] Startup arguments for PcVue. You will almost certainly need to change these
from the default. Configured using the General Properties tab.
[E] Startup type. Selection of the startup mode. It’s likely you will want to change
this to automatic when running PcVue as a service. Configured using the
Service Properties tab.
[F] The accounts used to run the SV Core Daemon service and the DCOM
Application. THESE MUST BE THE SAME.

4.3 Basic configuration for running PcVue as a service


Step 1. Start the Core Management Console. A shortcut can be found in the
Tools folder of PcVue’s program group.
Step 2. Select the startup mode as Run as a service application.

Module 46 – PcVue as a service Page 8/25


Step 3. Configure the Startup arguments using the General Properties tab.
Typical settings that you may want to change are the project name and
location. Remember that there is no HMI so you can’t use, for example, the –s
argument which allows you select the project at start-up using a dialog.

Figure 2

Step 4. Configure the Startup type using the Services Properties tab. On the
final installation, it’s likely that you will choose automatic, but you might want
to use manual while developing the project. There are also other options. See
the help for more information.

Figure 3

Module 46 – PcVue as a service Page 9/25


Step 5. Select the accounts to be used for both the (SV Core Daemon)
service and the DCOM application using the User Accounts tab. The LOCAL
SERVICE account can be used as a default.

Figure 4

Step 6. Open Windows Component Services configuration dialog. A shortcut


is provided in the Tools menu of the Core Management Console. This is used to
configure DCOM for the SV Services service which cannot be done directly from
the Core Management Console.
Step 7. Expand the tree in the left pane and select the DCOM Config node.
Locate the SV Services object in the middle pane and right click to select
properties.

Figure 5

Module 46 – PcVue as a service Page 10/25


Step 8. Select the Security tab and, for Launch and Activation permissions,
select Customize. Add the LOCAL SERVICE user.

Figure 6

Step 9. For the LOCAL SERVICE user you just added allow Local Launch and
Local Activation.

Figure 7

Module 46 – PcVue as a service Page 11/25


Step 10. Repeat steps 8 and 9 for Access Permissions. Close the Component
Service configuration dialog.
Step 11. That’s it. You should now be able to start PcVue as a service.
You cannot start PcVue as a desktop application from the Core
Management Console.
Conversely, you cannot start PcVue as a service application from a
desktop shortcut.
4.3.1 Exercise

Exercise 1.
Configure PcVue to run as a service

a. Create a new PcVue project MODULE_46 in your normal PcVue


project folder.
b. Start the Core Management Console and configure it to run
PcVue as a service with the project you just created.
c. Run the Windows Component Services configuration dialog and
add the LOCAL SERVICE user to the SV Services service.
d. Start PcVue as a service.

Question?
When PcVue is running as a service you can see two processes in
the Core Management Console. One is PcVue, but what is the
other?

Answer
The other process is the HDS (Historic Data Server). When PcVue
runs as a service the HDS must also run as a service. This is taken
care of by the Core Management Console.

Module 46 – PcVue as a service Page 12/25


4.4 Advanced configuration for running PcVue as a service
4.4.1 Selecting an alternative Service Account
By default the built in Local Service account is used to run PcVue and the DCOM
application. When running as a service, DCOM is used both for communication
between PcVue’s components and between PcVue and other applications. You can
select an alternative account using the User Accounts tab.

Figure 8

When choosing an alternative Service Account to run PcVue the main criteria is to use
an account with the least possible privileges. This is to ensure that the service is run
as securely as possible.
For further information see the help:
Deployment.Deploying server applications.Running the Supervisor as a
Windows service.Choosing a service account

Choosing an alternative account should be done by somebody


familiar with the company’s IT policy.

The Service account and DCOM accounts must be the same.

4.4.2

Module 46 – PcVue as a service Page 13/25


4.4.3 Adding dependent services
A dependent service is one that the PcVue application requires to run. PcVue checks
that dependent services have fully started before it attempts to start. For example, if
you were using the HDS with SQL Server, the SQL Server service would be a
dependent service.
Dependent services are selected and added using the Service Properties tab.

Figure 9

4.5 Warning about use of the Component Registration Utility


You probably already know about the Component Registration Utility. It is used to
register PcVue’s components and, if you have several versions of PcVue on the same
PC, it must be run before you start a different version.
What is important to know is that running the Component Registration Utility also
resets certain configuration parameters, associated with running PcVue as a service,
to their default. So after using the Component Registration Utility you should check
and, if necessary, update the configuration in the SV Core Management Console.

Module 46 – PcVue as a service Page 14/25


5 Communicating with other applications when
running as a service
When an application runs as a service it communicates with other applications using
DCOM technology. For applications to communicate, their DCOM configuration must
include the same account.
Some examples for when PcVue is running as a service:
PcVue’s OPC client communicating with a local OPC Server running as service:
DCOM for the OPC Server must accept the PcVue user account which is by
default LOCAL SERVICE.
PcVue’s OPC server communicating with an OPC Client running on a local
Windows session:
DCOM for PcVue must accept the local Windows user account. Could be the
generic AUTHENTICATED USERS account.
PcVue’s OPC server communicating with a remote OPC Client running in a
remote Windows session:
DCOM for PcVue must accept the remote Windows user account (can be
difficult…).
PcVue communicating with the local Application Explorer (or AA, etc.) running in
a local Windows session:
DCOM for PcVue must accept the local windows user. Could be the generic
AUTHENTICATED USERS account.

Figure 10

Module 46 – PcVue as a service Page 15/25


6 Tools when Running PcVue as a Service
6.1 Configuration Tools
You can use both the Application Architect (AA) and the Application Explorer (AE) with
PcVue when it is running as a service. Both the AA and AE are in fact separate
processes although they require the presence of PcVue to run. When running PcVue
as a desktop application the AA and AE are started from within PcVue, but when
running as a service they can be started independently from shortcuts in the Tools
folder of the PcVue Program Group. There is a difference however. When starting
either the AE or AA when PcVue is running as a service the user must log on using a
PcVue user account with appropriate configuration rights.

Figure 11

For the AE the user must have Development rights (Administration tab in User
Profile)

Figure 12

Module 46 – PcVue as a service Page 16/25


For the AA the user must have Development rights and the appropriate
Application Architect rights (Application Architect tab in the User Profile).

Figure 13

6.1.1 Exercise

Exercise 2.
Try the Application Explorer with PcVue running as a service

a. Add Authenticated Users to the SV Services DCOM


configuration. (Similar to Exercise 1 when you added the LOCAL
SERVICE user).
b. Start PcVue as a desktop application and run the MODULE_46
project.
c. Add a profile which has only the Development right.
d. Add a user and associate it with the above profile.
e. Shutdown PcVue and restart as a service.
f. Start the Application Explorer using the shortcut in the Tools
folder of the PcVue program Group.
g. Logon when prompted using the user you just created.

Module 46 – PcVue as a service Page 17/25


Question?
Where can you see the user that is running the AE or AA?

Answer
In the AA/AE status bar bottom right.

Module 46 – PcVue as a service Page 18/25


6.2 The Log Monitor
The Log Monitor is a new tool to monitor PcVue’s operation. When you are running
PcVue as a service you cannot see the Event Viewer and the Log Monitor must be
used to see debug, information, and warning messages from PcVue. The Log Monitor
can be opened from a shortcut in the Tools folder of the PcVue Program Group.

Figure 14

Messages which appear in the Log Monitor are saved in the log file SV.LOG which can
be found in the Log Files folder of PcVue’s Bin (installation) folder.

Module 46 – PcVue as a service Page 19/25


7 Practical Example – PcVue Running as a Service
and the Kepware OPC Server
7.1 Introduction
This section is an example of how you might use PcVue running as a service with the
Kepware OPC server but the principle would be the same for any OPC server.
The version of the Kepware OPC server that we have used up until now (KEPServer
EX4) has limited capability when configured to run as a service and cannot be used
with PcVue running as a service. However, the latest version, KEPServer EX5, was
designed from the start to run as a service and we can use that instead.

7.2 Installing and configuring KEPServer EX5


The installation procedure for KEPServer EX5 is broadly the same as that for
KEPServer EX4 which is explained in Module 16 - OPC Basics.
KEPServer Ex5 is split into two parts. The actual OPC server which runs as a service
and the configuration tool which runs as a desktop application. After installation we
need to run the configuration tool and select the same configuration file,
Server_Configuration.opf, used in Module 16.
The Kepware OPC server service runs using the Local System account by
default. We don’t need to change this for running with PcVue, but for improved
security, you may want to consider changing this to a lower privileged account
such as Local Service.
We have to configure the KEPServer OPC Server DCOM component so that it allows
connection from PcVue. To do this we use Windows’ Component Services
configuration dialog.

Module 46 – PcVue as a service Page 20/25


7.2.1 Configuring the KEPServer DCOM components
Step 1. Open the Windows’ Component Services configuration dialog. The
easy way to do this is from the Core Management Console where you will find a
shortcut.
Step 2. Expand the configuration tree in the left pane and select DCOM
Config. Locate the item Kepware Communications Server 5.20.

Figure 15

Module 46 – PcVue as a service Page 21/25


Step 3. Open the properties dialog for Kepware Communications Server
5.20 (right click) and select the Security tab.

Figure 16

Step 4. Add the Local Service account to the Launch and Activation
Permissions as follows:
a. Select Customize and click the Edit button
b. Add the user account Local Service.

Figure 17

Module 46 – PcVue as a service Page 22/25


c. For Local Service account you just added, tick the permissions Allow Local
Launch and Allow Local Activation.
Step 5. Add the Local Service account to Access Permissions ticking the
permission Allow Local Access.
Step 6. Close all the configuration dialogs by clicking the OK buttons. (Don’t
use Cancel as this forgets the configuration changes.) And that’s it. You can
now connect to the Kepware OPC server with PcVue running as a service.

7.3 Configuring PcVue to use KEPServer EX5


Configuration of PcVue is exactly the same as described in Module 16. You can make
the configuration with PcVue running either a desktop application or as a service. As a
reminder the basic steps, all taking place in the Communication.Data Acquisition.OPC
node of the Application Explorer, are:
Step 1. Add the OPC server
Step 2. Add an OPC group
Step 3. Map the variables

If the Kepware OPC server service is running using the Local System account it
will connect to PcVue running either as a desktop application or a service.
If the Kepware OPC server service is running using the Local Service account it
will only connect to PcVue running as a service.

Module 46 – PcVue as a service Page 23/25


7.3.1 Exercise

Exercise 3.
Install KEPServer EX5, configure its DCOM and configure PcVue
to connect and read some variables.

a. Install KEPServer EX5. The procedure is straightforward and


broadly the same as explained in Module 16. The installation
program KEPServerEx5.exe can be found in the Third Party
folder of Module 46.
b. Run KEPServer EX5 and load the configuration file also found in
the Third Party folder.
c. Configure the KEPServer DCOM so it can communicate with
PcVue (add the Local Service account).
d. Using the Core Management Console add the KEPServer as a
dependent service.
e. Start PcVue as a service. Make sure you are running the
MODULE_46 project. Open the Application Explorer.
f. Configure a connection to the KEPServer EX5 OPC server and
map the items, On-Off, Setpoint & Temperature, to some PcVue
variables.
g. Check that the communications is good and that the variables
are all updating correctly.

Module 46 – PcVue as a service Page 24/25


8 Resume
PcVue can run as a Windows service. There are some limitations but also some
advantages which make it ideal for certain roles in multi-station applications.
When running as a service, PcVue is managed using the Core Management
Console.
When PcVue runs as a service, it can communicate with other applications, such
as a third party OPC server, using DCOM technology.

Module 46 – PcVue as a service Page 25/25

You might also like