[seiscomp, scanloc] Install, add .gitignore

This commit is contained in:
2025-10-09 15:07:02 +02:00
commit 20f5301bb1
2848 changed files with 1315858 additions and 0 deletions

View File

@ -0,0 +1,61 @@
* Generated at $date - Do not edit!
* template: $template
[$seedlink.source.id]
* Settings for miscScript
* 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=miscScript
*fake port name, for serial_plugin compatibility
port=default
* specific miscScript entries
script_path=$sources.miscScript.script_path
script_args=$sources.miscScript.script_args
channelsNumber=$sources.miscScript.channelsNumber
flush_period=$sources.miscScript.flush_period
sample_period=$sources.miscScript.sample_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.miscScript.channels

View File

@ -0,0 +1,191 @@
#!/usr/bin/python3 -u
# Written by Tristan DIDIER, OVSG/IPGP, 2019
# This script is a front-end script for miscScript plugin
# It has been, in first place, developped for and tested on BeagleBone Black
# It aims at reading i2c data from MCP342X A/D, used for instance on ADC Pi and ADC Differential Pi Boards of ABelectronics.
# This code is freely inspired from the example code provided by ABelectronics : https://www.abelectronics.co.uk/kb/article/10/adc-pi-on-a-beaglebone-black
########## PARAMETERS ##########
#i2c parameters
i2c_bus=2
adc_addresses=[0x68,0x69]
#MCP342X parameters
used_channels=4
resolution=18
pga_gain=1
continuous=1
#Sampling parameter
sampling_period=2
########## IMPORTS ##########
from smbus2 import SMBus
from time import time,gmtime,strftime,sleep
from math import ceil
from sys import stderr
########### CLASS MCP342X ##########
class MCP342X:
""" class to drive ADC Pi Board from ABElectronics """
rate_code={12:0x00, 14:0x01, 16:0x02, 18:0x03} #resolution to sample rate selection bits
pga_code={1:0x00,2:0x01,4:0x02,8:0x03} #PGA gain to PGA gain selection bits
resolutionToSPS={12:240, 14:60, 16:15, 18:3.75} #resolution to sps
#***** __INIT__ *****
def __init__(self,i2c_bus,i2c_address,resolution=18,pga_gain=1,continuous=1):
""" Constructor : initialize object attributs"""
#connect i2c
self.bus=SMBus(i2c_bus)
#get MCP3422 addresses
self.i2c_address=i2c_address
#get MCP3422 expected answer size and generate corresponding data/sign_filter
if resolution==18:
self.read_size=4
else:
self.read_size=3
self.data_filter=pow(2,resolution-1)-1
self.sign_filter=pow(2,resolution-1)
#Generate static configuration
S10=MCP342X.rate_code[resolution] # Sample rate selection
G10=MCP342X.pga_code[pga_gain] # PGA gain selection
C10=0x00 # Channel selection
RDI=1 # Ready bit
OC=continuous # Continuous:1 , One-shot:0
self.staticConf= RDI << 7 | C10 << 5 | OC << 4 | S10 << 2 | G10
self.currentConfig=self.staticConf
#***** GETADCREADING *****
def getAdcReading(self):
""" Read Value. Return None no data available"""
adcreading = self.bus.read_i2c_block_data(self.i2c_address,self.currentConf,self.read_size)#i2c reading
confRead = adcreading[self.read_size-1]#Extract conf byte
if confRead & 128 :# and check if result is ready. If not, return None
return None;
#bitarray to int
data=0
for i in (range(0,self.read_size-1)):
data+=int(adcreading[i]) << 8*(self.read_size-2-i)
#If the result is negative, convert to negative int
if data & self.sign_filter :
data=-(self.sign_filter-(data & self.data_filter))
#Return the result
return data
#***** CHANGECHANNEL *****
def changeChannel(self, channel):
""" Select channel to read """
self.currentConf=self.staticConf | channel << 5 # generate conf byte from staticConf and channel parameter
self.bus.write_byte(self.i2c_address,self.currentConf)
##### EPRINT #####
def eprint(msg):
""" print to stderr """
print(msg,file=stderr)
##########################
########## MAIN ##########
##########################
if __name__=="__main__":
########## SETUP ###########
res_tab=[None]*(len(adc_addresses)*used_channels)
#Initialize ABelec Object
tab_MCP342X=[];
for adc_address in adc_addresses :
tab_MCP342X.append(MCP342X(i2c_bus,adc_address,resolution, pga_gain, continuous))
#Initialize timing
nextTime=ceil(time())
########### LOOP ##########
while(True):
wait=nextTime-time()
#***** Check time sync *****
if wait>0:
if wait < sampling_period :
sleep(wait)
else :
nextTime=ceil(time())
eprint("Time to wait before next loop is greater than sampling_period : {} > {} -> New ref time defined".format(wait,sampling_period))
continue
else :
nextTime=ceil(time())
eprint("Last loop was {} seconds long while sampling_period is {} seconds -> New ref time defined".format(-wait+sampling_period,sampling_period))
continue
#***** read ADCs' channels *****
#reset results' tab
res_tab=[None]*(len(adc_addresses)*used_channels)
#Read channel by channel, in parallel on all MCP342X
for channel in range(used_channels) :
#Select channel on each chip
for MCP in tab_MCP342X :
MCP.changeChannel(channel)
res_counter=0
i_MCP=0
while res_counter<len(adc_addresses):
i_res=channel+i_MCP*used_channels
if res_tab[i_res]==None:
res_tab[i_res]=tab_MCP342X[i_MCP].getAdcReading()
if res_tab[i_res]!=None:
res_counter+=1
i_MCP=(i_MCP+1)%len(adc_addresses)
# generate ASCII frame
frame=strftime("%Y-%m-%d %H:%M:%S", gmtime(nextTime))+','+','.join(map(str,res_tab))#+"\n"
# and print it on stdout
print(frame)
#Set next loop start
nextTime+=sampling_period

View File

@ -0,0 +1,36 @@
#!/usr/bin/python3 -u
# Simple Script example to generate fix rate ASCII frames with random data and print it on standard output
###
import sys,time
from datetime import datetime,timedelta
import random
### Parameters ###
channels_nb=3 #How many channel do you want ?
period_s=1 #Sample_period (second)
period_ms=0 #Sample_period (millisecond, can be combined with period_s)
try:
next_time=datetime.now()+timedelta(seconds=period_s,microseconds=period_ms*1000)
while True:
data=""
for i in range(channels_nb):
data=data+","+str(int(round(random.uniform(-10000,10000),0)))
timeStr=datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
msg=timeStr+data+"\n"
print(msg)
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

View 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.miscScript.proc"

View File

@ -0,0 +1,122 @@
import re
"""
Plugin handler for the miscScript 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.miscScript.script_path")
except:
seedlink.setParam("sources.miscScript.script_path", "")
try:
seedlink.param("sources.miscScript.script_args")
except:
seedlink.setParam(
"sources.miscScript.script_args", "default"
) # If no argument, set 'default'
try:
seedlink.param("sources.miscScript.proc")
except:
seedlink.setParam("sources.miscScript.proc", "auto")
try:
seedlink.param("sources.miscScript.sample_frequency")
except:
seedlink.setParam("sources.miscScript.sample_frequency", "1")
freq = seedlink.param("sources.miscScript.sample_frequency")
if re.match("[0-9]+$", freq) != None:
seedlink.setParam("sources.miscScript.sample_period", str(1.0 / int(freq)))
else:
res = re.match("([0-9]+)/([0-9]+)$", freq)
if res != None:
seedlink.setParam(
"sources.miscScript.sample_period",
str(float(res.group(2)) / float(res.group(1))),
)
else:
print("Sample frequency invalid !!!")
raise Exception
try:
seedlink.param("sources.miscScript.channels")
except:
seedlink.setParam("sources.miscScript.channels", "HHZ,HHN,HHE")
splitted_chans = seedlink.param("sources.miscScript.channels").split(",")
seedlink.setParam("sources.miscScript.channelsNumber", len(splitted_chans))
try:
seedlink.param("sources.miscScript.flush_period")
except:
seedlink.setParam("sources.miscScript.flush_period", "0")
##### Auto-generate proc conf and channel/source_id mapping
if seedlink.param("sources.miscScript.proc") == "auto":
seedlink.setParam("sources.miscScript.proc", "auto:miscScript_%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.miscScript.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.miscScript.trees", trees)
seedlink.setParam("sources.miscScript.channels", channels)
return key
# Flush does nothing
def flush(self, seedlink):
pass

View File

@ -0,0 +1,2 @@
<proc name="$sources.miscScript.proc">
$sources.miscScript.trees </proc>