You are on page 1of 23

Build Up the Earthworm

Platform from Scratch:


Concept & Development
Benjamin Yang
2023.04.11
Materials
• Google Drive Link
• https://reurl.cc/OVel59
• Earthworm Central Document
• http://www.earthwormcentral.org
• Earthworm Community Forum on Google
Groups
• https://groups.google.com/g/earthworm_forum
?hl=en

2
Outline
• Prepare a Linux environment.

• Build up your own Earthworm.

• Write a simple Earthworm module from a


template.

3
Before get into Earthworm…
• Run a Linux operating system.

• Install the build tool chain:


• Debian dist – build-essential
• Red Hat dist – gcc, gcc-c++, kernel-devel, make

• Download the SOURCE CODE of Earthworm.

4
Of Earthworm Platform…
• Developed by USGS since 1993.
• And the newest version is 7.10 (7.11 under alpha).
• An universal seismic processing system.
• Design goal:
• Modularity
• System independence
• Scalability
• Connectivity
• Robustness

5
6

Architecture
Internal Earthworm Architecture

pick hypo
palert2ew

other
WAVE_RING archive
acquisition
modules
other processing
modules
7

Architecture

Chen et al., 2015


Installation
• Create the Earthworm root directory, ex: /ew
• Put the Earthworm source directory inside
the root directory just created
• Under the same root directory, create a run
directory, ex: /ew/run
• Under the run directory, create params & log
directory, ex: /ew/run/params, /ew/run/log

8
Configuration
• Copy the four files inside env directory to
params directory:
• earthworm.d
• earthworm_global.d
• earthworm_commonvars.d
• ew_linux.bash
• Purge some settings inside earthworm.d.
• Modify the real path in the ew_linux.bash.

9
Compilation
• Source for ew_linux.bash
• Go to the /ew/earthworm_7.10/src
• Type “make clean_unix”
• Type “make unix”
• If there is not any ERROR, you get your own
Earthworm Platform!

10
Of startstop…
• The main entry of Earthworm Platform.

• And, some settings inside the startstop.d file.

• Type “startstop”

• The Earthworm is running!!

11
Some modules & files…
• tankplayer
• sniffwave
• import/export
• slink2ew
• template
• trace_buf.h

12
Further testing…
• Put those tank files into you system.
• Add the tankplayer to earthworm.d
• Configure the tankplayer.d
• Configure the startstop.d
• Type “startstop”
• Open a new terminal, type “sniffwave
WAVE_RING”
• Now, you can see the trace inside the ring.
13
Let’s write a module!

14
Start from template…
• Main process
• Initialization
• Ring Attaching
• Processing loop
• Configuration reading func.
• Error & heartbeat message sending func.
• Environment reading func.

15
A simple module
• Read configuration that is inside .d file for
fetching specific SCNL.

• Show out the peak value within the specific


trace every one second.

16
Read the configuration…
• Call the function (template_config).
• Open the .d file.
• Search the keywords.
• Fetch the contents following.
• Save into the variables.

17
Fetch message from Ring.
• Loop for tport_getmsg.

• Check the logo of message (mod & type).

• Compare the SCNL with the setting.

• Get it!

18
Of the trace buffer ver. 2.0
• typedef struct {
• int pinno; /* Pin number */
• int nsamp; /* Number of samples in packet */
• double starttime; /* time of first sample in epoch seconds (seconds since midnight
1/1/1970) */
• double endtime; /* Time of last sample in epoch seconds */
• double samprate; /* Sample rate; nominal */
• char sta[TRACE2_STA_LEN]; /* Site name (NULL-terminated) */
• char net[TRACE2_NET_LEN]; /* Network name (NULL-terminated) */
• char chan[TRACE2_CHAN_LEN]; /* Component/channel code (NULL-terminated)*/
• char loc[TRACE2_LOC_LEN]; /* Location code (NULL-terminated) */
• char version[2]; /* version field */
• char datatype[3]; /* Data format code (NULL-terminated) */
• char quality[2]; /* Data-quality field */
• char pad[2]; /* padding */
• } TRACE2_HEADER;

19
Real Process for trace
• The detailed format of trace buffer.
• Read the data in count with pointer.
• Pick the peak value.
• Show it along with other information on the
terminal.

20
Compile it!
• Using Make
• Set the module name
• Set what kind of library you need here
• Set where to output the execute file
• Configure the startstop.d
• Type “startstop”
• Check the result.

21
After works…
• Log procedure
• Threading
• Networking
• Coding guidance

22
Q&A

23

You might also like