Service connectivity check¶
Standard startup flow:
Activate the vjem environment and start Python
Confirm that the required services are running
TEM3 packages:
TEM3.connect()Other packages:
check_connection()
If not reachable: diagnose with
get_config(), reconfigure withset_ip()
Prerequisites
Miniconda is installed.
A vjem environment is available (for example: vjem38, vjem310).
PyJEM is already installed in the target vjem environment.
For online operation, TEMCenter/TEMServer (or required services) are running.
Step 1: Activate vjem and Start Python¶
Open a command prompt and run:
conda activate vjem38
python
Replace vjem38 with the name of your environment (e.g., vjem310).
Step 2: Confirm that the required services are running¶
The method to use depends on the package:
Package type |
Confirmation method |
|---|---|
TEM3 |
|
All other packages |
|
Run the appropriate code cell below for your target package.
TEM3 package¶
1# Step 2 (TEM3): Confirm TEM3 service is running
2from PyJEM import TEM3
3
4try:
5 TEM3.connect()
6 print("TEM3: Connected")
7except Exception as e:
8 print("TEM3: Connection failed ->", e)
9 print("Verify that TEMCenter / TEMServer is running on the TEM PC.")
TEM3: Connected
others package¶
For packages other than TEM3, call check_connection() on each package.
True — the service is running.
False — the service is not reachable (check IP address and port).
1# Step 2 (other packages): Check that each service is running
2from PyJEM import detector, detectorext, eds, sightx, eels, eftem, stem4d
3
4packages = {
5 "detector": detector,
6 "detectorext": detectorext,
7 "eds": eds,
8 "sightx": sightx,
9 "eels": eels,
10 "eftem": eftem,
11 "stem4d": stem4d,
12}
13
14print(f"{'Package':<14} {'Connected':<12} ip port")
15print("-" * 55)
16for pkg_name, pkg in packages.items():
17 connected = pkg.check_connection()
18 cfg = pkg.get_config()
19 print(f"{pkg_name:<14} {str(connected):<12} {cfg.get('ip', '?')} {cfg.get('port', '?')}")
Package Connected ip port
-------------------------------------------------------
detector True 127.0.0.1 49226
detectorext True 127.0.0.1 49326
eds True 127.0.0.1 49326
sightx False 127.0.0.1 49260
eels True 127.0.0.1 49326
eftem True 127.0.0.1 49326
stem4d True 127.0.0.1 49326
Appendix: If a service is not reachable¶
When check_connection() returns False:
Inspect current settings with
get_config()— check theipandportvalues.Update the IP address with
set_ip("x.x.x.x")to point to the correct host.Retry
check_connection()to confirm the service is now reachable.
1# Appendix: Diagnose and reconfigure (example using detector)
2from PyJEM import detector
3
4if detector.check_connection():
5 print("detector: Connected")
6else:
7 # 1. Inspect current settings
8 config = detector.get_config()
9 print("Not connected. Current config:", config)
10
11 # 2. Update IP address to the correct host and retry
12 new_ip = "127.0.0.1" # Replace with the actual IP address of the service
13 detector.set_ip(new_ip)
14 print(f"IP updated to: {new_ip}")
15 print(f"New config: {detector.get_config()}")
16 print(f"Retry check_connection: {detector.check_connection()}")
detector: Connected