1.0.25 • Published 2 months ago

epics-tca v1.0.25

Weekly downloads
-
License
ISC
Repository
-
Last release
2 months ago

TypeScript Realization of EPICS Channel Access Client Liberary

About

This is the TypeScript version EPICS Channale Acceess (CA) client library. It provides a TypeScript/JavaScript interface for an EPICS CA client communicating with CA servers.

This library complies the CA protocol specifications.

Install

In your TypeScript/JavaScript project, run

npm install epics-tca

Usage

Get

Create a .ts file (e.g. simpleGet.ts) with following contents:

import { Context } from "epics-tca";
async function simpleGet(name: string) {
    let channel = await context.createChannel(name);
    return await channel?.get();
}

let context = new Context();
context.initialize().then(() => {
    simpleGet("FE:Scope_1:RMS2").then((data: any) => {
        console.log("FE:Scope_1:RMS2", data.data);
        context.destroyHard();
    });
});

Run the transpiled simpleGet.js file, you will get the following result:

$ node simpleGet.js 
FE:Scope_1:RMS2 [ 2.2934632737106067 ]

Put

Create a .ts file (e.g. simplePut.ts) with following contents:

import { Context } from "epics-tca";
async function simplePut(name: string, value: number) {
    let channel = await context.createChannel(name);
    const value0 = await channel?.get();
    console.log("Before:", name, value0?.data);
    await channel?.put([value]);
    return await channel?.get();
}

let context = new Context();
context.initialize().then(() => {
    simplePut("val1", 9527).then((data: any) => {
        console.log("After: ", "val1", data.data);
        context.terminate();
    });
});

Run the transpiled simplePut.js file, you will get the following result:

$ node simplePut.js 
Before: val1 [ 2 ]
After:  val1 [ 9527 ]

Monitor

Create a .ts file (e.g. simpleMonitor.ts) with following contents:

import { Context } from "epics-tca";

async function tcaMonitor(name: string) {
    let channel = await context.createChannel(name);
    let monitor = await channel?.createMonitor(monitorListener);
    await monitor?.subscribe();
}
function monitorListener(monitor: ChannelMonitor) {
    console.log(monitor.name, ":", monitor.data.data);
}

let context = new Context();
context.initialize().then(() => {
    tcaMonitor("FE:Scope_1:RMS2");
});
setTimeout(() => {
    console.log("Terminate program");
    context.terminate();
}, 5 * 1000)

Run the transpiled simpleMonitor.js file, you will get the following result:

$ node simpleMonitor.js
FE:Scope_1:RMS2 : [ 2.296598922566252 ]
FE:Scope_1:RMS2 : [ 2.2929398313489786 ]
FE:Scope_1:RMS2 : [ 2.299754072515923 ]
FE:Scope_1:RMS2 : [ 2.298171626156998 ]
Terminate program

Performance

Benefited from the asynchronous and event driven design of Node.js, the EPICS TCA can create EPICS channels efficiently. Below is the time used to create a batch of channels:

Number of PVsTime seconds
10000.104
20000.184
50000.334
100000.603
150000.728
200000.923
250001.318
300001.553
350002.032
400002.432
450002.748
500003.082
600003.727
800005.583
1000009.095

Each channel updates once every second. During the test, after the channels are created, the test program monitors the updates. For 100000 channels, the memory usage is about 450 MB when they are monitored, and the CPU usage is about 50% on a 2.3 GHz Intel Core i9-9880H processor with MacOS 12.4.

1.0.25

2 months ago

1.0.24

8 months ago

1.0.23

8 months ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago