-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverride_example.py
44 lines (32 loc) · 1.15 KB
/
override_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""Example override.py that demonstrates how to use the CORSIKA-python
interface.
"""
import os
import sys
# You do not have to add COAST_USER_LIB/python/packages to your search path
# if you only run the interface within CORSIKA.
packpath = os.path.join(os.environ["COAST_USER_LIB"], "python", "packages")
if packpath not in sys.path:
sys.path.append(packpath)
# import CORSIKA-COAST-python interface link.
import interface
# Override interface.Override and implement corresponding methods.
class MyInterface(interface.Override):
def __init__(self):
print("patched interface")
def init(self):
# You can disable and enable the capturing of certain interface parts.
interface.disableWrite()
interface.disableInteraction()
interface.disableTrack()
pass
def close(self):
pass
def write(self, subblock : bytes):
pass
def interaction(self, info : interface.Interaction):
pass
def track(self, pre : interface.Particle, post : interface.Particle):
pass
# Patch the interface to use the newly defined class and run tests (True).
interface.patch(MyInterface, True)