[seiscomp, scanloc] Install, add .gitignore
This commit is contained in:
63
share/templates/seedlink/miscSerial/plugins.ini.tpl
Normal file
63
share/templates/seedlink/miscSerial/plugins.ini.tpl
Normal file
@ -0,0 +1,63 @@
|
||||
* Generated at $date - Do not edit!
|
||||
* template: $template
|
||||
|
||||
[$seedlink.source.id]
|
||||
|
||||
* Settings for miscSerial "csv" source
|
||||
|
||||
* Station ID (network/station code is set in seedlink.ini)
|
||||
station=$seedlink.station.id
|
||||
|
||||
* Use the command 'serial_plugin -m' to find out which protocols are
|
||||
* supported.
|
||||
protocol=miscSerial
|
||||
|
||||
* Serial port
|
||||
port=$sources.miscSerial.comport
|
||||
|
||||
* Baud rate
|
||||
bps=$sources.miscSerial.baudrate
|
||||
|
||||
* specific miscSerial entries
|
||||
channelsNumber=$sources.miscSerial.channelsNumber
|
||||
flush_period=$sources.miscSerial.flush_period
|
||||
sample_period=$sources.miscSerial.sample_period
|
||||
serial_clock_period=$sources.miscSerial.serial_clock_period
|
||||
|
||||
* lsb (defaults to 8): least significant bit (relative to 32-bit samples),
|
||||
* normally 8 for 24-bit samples, but can be set for example to 7 to get
|
||||
* 25-bit samples;
|
||||
* statusinterval (defaults to 0): time interval in minutes when "state of
|
||||
* health" information is logged, 0 means "disabled". State of health
|
||||
* channels can be used independently of this option.
|
||||
*
|
||||
* If you set 'checksum' to a wrong value then the driver will not work and
|
||||
* you will get error messages like "bad SUM segment" or "bad MOD segment".
|
||||
lsb=8
|
||||
statusinterval=60
|
||||
|
||||
* Parameter 'time_offset' contains the amount of microseconds to be added
|
||||
* to the time reported by the digitizer.
|
||||
|
||||
* 1.389 sec is possibly the correct offset if you have a version of the
|
||||
* Earth Data digitizer with external GPS unit.
|
||||
* time_offset=1389044
|
||||
|
||||
* Maximum number of consecutive zeros in datastream before data gap will be
|
||||
* declared (-1 = disabled).
|
||||
zero_sample_limit = -1
|
||||
|
||||
* Default timing quality in percents. This value will be used when no
|
||||
* timing quality information is available. Can be -1 to omit the blockette
|
||||
* 1001 altogether.
|
||||
default_tq = -1
|
||||
|
||||
* Timing quality to use when GPS is out of lock
|
||||
unlock_tq = 10
|
||||
|
||||
* Keyword 'channel' is used to map input channels to symbolic channel
|
||||
* names. Channel names are arbitrary 1..10-letter identifiers which should
|
||||
* match the input names of the stream processing scheme in streams.xml,
|
||||
* which is referenced from seedlink.ini
|
||||
|
||||
$sources.miscSerial.channels
|
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/python3 -u
|
||||
|
||||
# Simple Script to generate fix rate ASCII frames and send it througth a serial port
|
||||
# pyserial library have to be installed installed first (https://github.com/pyserial/pyserial)
|
||||
# For testing, you can use socat to get virtual serial ports :
|
||||
# socat -d -d pty,raw,echo=0 pty,raw,echo=0
|
||||
|
||||
###
|
||||
import serial
|
||||
import sys,time
|
||||
from datetime import datetime,timedelta
|
||||
import random
|
||||
|
||||
### Parameters ###
|
||||
channels_nb=3 #How many channnel do you want
|
||||
port="/dev/ttyUSB0" #Serial port used by this script to output data
|
||||
ser_speed=9600 #Serial port speed
|
||||
period_s=1 #Sample Period (second)
|
||||
period_ms=0 #Sample Period (millisecond, can be combined with period_s)
|
||||
|
||||
|
||||
try:
|
||||
|
||||
ser=serial.Serial(port,ser_speed,rtscts=0)
|
||||
next_time=datetime.now()+timedelta(seconds=period_s,microseconds=period_ms*1000)
|
||||
|
||||
while True:
|
||||
data=""
|
||||
for i in range(channels_nb):
|
||||
data=data+","+str(round(random.uniform(-10000,10000),0))
|
||||
timeStr=datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
|
||||
msg=timeStr+data+"\n"
|
||||
print(msg)
|
||||
ser.write(msg.encode())
|
||||
|
||||
time.sleep((next_time-datetime.now())/timedelta(seconds=1))
|
||||
next_time= next_time+timedelta(seconds=period_s,microseconds=period_ms*1000)
|
||||
|
||||
except Exception as msg:
|
||||
raise
|
||||
|
||||
finally:
|
||||
ser.close()
|
7
share/templates/seedlink/miscSerial/seedlink_plugin.tpl
Normal file
7
share/templates/seedlink/miscSerial/seedlink_plugin.tpl
Normal file
@ -0,0 +1,7 @@
|
||||
* template: $template
|
||||
plugin $seedlink.source.id cmd = "$seedlink.plugin_dir/serial_plugin$seedlink._daemon_opt -v -f $seedlink.config_dir/plugins.ini"
|
||||
timeout = 600
|
||||
start_retry = 60
|
||||
shutdown_wait = 10
|
||||
proc = "$sources.miscSerial.proc"
|
||||
|
125
share/templates/seedlink/miscSerial/setup.py
Normal file
125
share/templates/seedlink/miscSerial/setup.py
Normal file
@ -0,0 +1,125 @@
|
||||
import re
|
||||
|
||||
"""
|
||||
Plugin handler for the miscSerial plugin.
|
||||
"""
|
||||
class SeedlinkPluginHandler:
|
||||
# Create defaults
|
||||
def __init__(self):
|
||||
self.instances = {}
|
||||
|
||||
def push(self, seedlink):
|
||||
sta = seedlink.param("seedlink.station.id")
|
||||
|
||||
try:
|
||||
key = sta + "." + str(self.instances[sta])
|
||||
self.instances[sta] += 1
|
||||
except KeyError:
|
||||
key = sta + ".0"
|
||||
self.instances[sta] = 1
|
||||
|
||||
# Check and set defaults
|
||||
try:
|
||||
seedlink.param("sources.miscSerial.comport")
|
||||
except:
|
||||
seedlink.setParam("sources.miscSerial.comport", "/dev/data")
|
||||
|
||||
try:
|
||||
seedlink.param("sources.miscSerial.baudrate")
|
||||
except:
|
||||
seedlink.setParam("sources.miscSerial.baudrate", 9600)
|
||||
|
||||
try:
|
||||
seedlink.param("sources.miscSerial.proc")
|
||||
except:
|
||||
seedlink.setParam("sources.miscSerial.proc", "auto")
|
||||
|
||||
try:
|
||||
seedlink.param("sources.miscSerial.sample_frequency")
|
||||
except:
|
||||
seedlink.setParam("sources.miscSerial.sample_frequency", "1")
|
||||
|
||||
freq = seedlink.param("sources.miscSerial.sample_frequency")
|
||||
|
||||
if re.match("[0-9]+$", freq) != None:
|
||||
seedlink.setParam("sources.miscSerial.sample_period", str(1.0 / int(freq)))
|
||||
else:
|
||||
res = re.match("([0-9]+)/([0-9]+)$", freq)
|
||||
if res != None:
|
||||
seedlink.setParam(
|
||||
"sources.miscSerial.sample_period",
|
||||
str(float(res.group(2)) / float(res.group(1))),
|
||||
)
|
||||
else:
|
||||
print("Sample frequency invalid !!!")
|
||||
raise Exception
|
||||
|
||||
try:
|
||||
seedlink.param("sources.miscSerial.channels")
|
||||
except:
|
||||
seedlink.setParam("sources.miscSerial.channels", "HHZ,HHN,HHE")
|
||||
|
||||
splitted_chans = seedlink.param("sources.miscSerial.channels").split(",")
|
||||
seedlink.setParam("sources.miscSerial.channelsNumber", len(splitted_chans))
|
||||
|
||||
try:
|
||||
seedlink.param("sources.miscSerial.flush_period")
|
||||
except:
|
||||
seedlink.setParam("sources.miscSerial.flush_period", "0")
|
||||
|
||||
try:
|
||||
seedlink.param("sources.miscSerial.serial_clock_period")
|
||||
except:
|
||||
seedlink.setParam("sources.miscSerial.serial_clock_period", "0")
|
||||
|
||||
##### Auto-generate proc conf and channel/source_id mapping
|
||||
|
||||
if seedlink.param("sources.miscSerial.proc") == "auto":
|
||||
seedlink.setParam("sources.miscSerial.proc", "auto:miscSerial_%s" % key)
|
||||
trees = ""
|
||||
channels = ""
|
||||
idx = 0
|
||||
|
||||
for chan in splitted_chans:
|
||||
chan = chan.strip()
|
||||
|
||||
if chan == "none":
|
||||
idx += 1
|
||||
continue
|
||||
|
||||
elif len(chan) == 3:
|
||||
location_val = "00"
|
||||
stream_val = chan[0:2]
|
||||
channel_val = chan[2]
|
||||
|
||||
elif len(chan) == 5:
|
||||
location_val = chan[0:2]
|
||||
stream_val = chan[2:4]
|
||||
channel_val = chan[4]
|
||||
|
||||
else:
|
||||
print("Invalid channel name")
|
||||
raise Exception
|
||||
|
||||
trees += " <tree>\n"
|
||||
trees += """ <input name="{}" channel="{}" location="{}" rate="{}"/>\n""".format(
|
||||
idx,
|
||||
channel_val,
|
||||
location_val,
|
||||
seedlink.param("sources.miscSerial.sample_frequency"),
|
||||
)
|
||||
trees += """ <node stream="{}"/>\n""".format(stream_val)
|
||||
trees += " </tree>\n"
|
||||
|
||||
channels += "channel {} source_id={}\n".format(idx, idx)
|
||||
|
||||
idx += 1
|
||||
|
||||
seedlink.setParam("sources.miscSerial.trees", trees)
|
||||
seedlink.setParam("sources.miscSerial.channels", channels)
|
||||
|
||||
return key
|
||||
|
||||
# Flush does nothing
|
||||
def flush(self, seedlink):
|
||||
pass
|
2
share/templates/seedlink/miscSerial/streams_auto.tpl
Normal file
2
share/templates/seedlink/miscSerial/streams_auto.tpl
Normal file
@ -0,0 +1,2 @@
|
||||
<proc name="$sources.miscSerial.proc">
|
||||
$sources.miscSerial.trees </proc>
|
Reference in New Issue
Block a user