id
int64
0
45.1k
file_name
stringlengths
4
68
file_path
stringlengths
14
193
content
stringlengths
32
9.62M
size
int64
32
9.62M
language
stringclasses
1 value
extension
stringclasses
6 values
total_lines
int64
1
136k
avg_line_length
float64
3
903k
max_line_length
int64
3
4.51M
alphanum_fraction
float64
0
1
repo_name
stringclasses
779 values
repo_stars
int64
0
882
repo_forks
int64
0
108
repo_open_issues
int64
0
90
repo_license
stringclasses
8 values
repo_extraction_date
stringclasses
146 values
sha
stringlengths
64
64
__index_level_0__
int64
0
45.1k
exdup_ids_cmlisp_stkv2
sequencelengths
1
47
37,579
help.lisp
open-rsx_rsbag-tools-cl/bag-play/help.lisp
;;;; help.lisp --- Help text generation for the bag-play program. ;;;; ;;;; Copyright (C) 2012-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.play) (defun make-help-string (&key (show :default)) "Return a help that explains the commandline option interface." (with-output-to-string (stream) (format stream "Replay events from INPUT-FILE+ on RSB channels ~ derived from BASE-URI.~@ ~@ ") (with-abbreviation (stream :uri show) (format stream "BASE-URI which has to be of the form~@ ~@ ~2@T") (print-uri-help stream :uri-var "BASE-URI")) (rsbag.tools.commands::augment-documentation-with-backends "~@ ~@ The file format(s) of INPUT-FILE+ is/are guessed based on the ~ filename(s)."))) (defun make-examples-string (&key (program-name "bag play")) "Make and return a string containing usage examples of the program." (format nil "~2@T~A /tmp/everything.tide spread://azurit:4803/~@ ~@ Replay all events from all channels stored in the log ~ file \"/tmp/everything.tide\" mimicking the recorded ~ timing as closely as possible. Publish replayed events ~ on the channels they were originally published on. Use ~ the Spread daemon listening on port 4803 of host azurit ~ to connect to the bus.~@ ~@ ~2@T~:*~A -r as-fast-as-possible -c /nao/vision/top ~ /tmp/nao.tide 'spread:/mynamespace'~@ ~@ Replay events recorded from the log file ~ \"/tmp/nao.tide\" for the channel designated by ~ \"/nao/vision/top\" (and potentially recorded ~ sub-channels) as fast as possible, discarding the ~ recorded timing information. Publish replayed on ~ channels with the prefix \"/mynamespace\", ~ i.e. \"/mynamespace/nao/vision/top\" for events ~ recorded for \"/nao/vision/top\"." program-name))
2,253
Common Lisp
.lisp
48
35.291667
72
0.571753
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
7a540b586e14c653349808dbceba73ff5a84114ec57f7fd2f219cbce21258be6
37,579
[ -1 ]
37,580
package.lisp
open-rsx_rsbag-tools-cl/src/common/package.lisp
;;;; package.lisp --- Package definition for common module. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.tools.common (:use #:cl #:alexandria #:let-plus #:more-conditions #:net.didierverna.clon #:rsbag.rsb.replay #:rsb.tools.common) ;; Commandline options (:export #:make-replay-options #:process-bounds-options #:make-index-timestamp-option #:make-channel-allocation-option) ;; Help text generation (:export #:make-replay-strategy-help-string #:make-channel-strategy-help-string) (:documentation "This package contains some common utility functions for RSBag: + Commandline option definition and processing + Help text generation"))
796
Common Lisp
.lisp
28
24.928571
66
0.717105
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f876ec53110330312bf3132c24911e625ed0efe7b704fd6d46bf2bc97d559fe4
37,580
[ -1 ]
37,581
options.lisp
open-rsx_rsbag-tools-cl/src/common/options.lisp
;;;; options.lisp --- Common functions related to commandline options. ;;;; ;;;; Copyright (C) 2012-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.common) (defun %make-group (header &rest items) (apply #'make-group :header header (mapcan #'list (circular-list :item) (remove nil items)))) (defun make-replay-options (&key (show :default) (channel? t) (loop? t) (replay-strategy? t) (replay-strategy-default "recorded-timing") (show-progress-default :none) (action (missing-required-argument :action))) "Return a `clon:group' instance containing some or all of the replay-related commandline options: + channel + start-{time,index} + end-{time,index} + loop + filter + replay-strategy + show-progress" (%make-group (format nil "~:(~a~) options" action) (when channel? (make-stropt :long-name "channel" :short-name "c" :argument-name "NAME-OR-REGEXP" :description (format nil "Select the channels matching ~ NAME-OR-REGEXP for ~A. This option can ~ be supplied multiple times.~@ ~@ By default, NAME-OR-REGEXP can match ~ any substring of the channel name. to ~ match the whole name instead, ^REGEXP$ ~ can used.~@ ~@ Again by default, channel names are of ~ the form SCOPE:TYPE-NAME. To only ~ match the scope or type, the regular ~ expressions ^SCOPE-REGEXP: or ~ :TYPE-REGEXP$ can be used ~ respectively." action))) (make-lispobj :long-name "start-time" :short-name "s" :typespec 'range-boundary/timestamp :argument-name "TIMESTAMP-OR-SECONDS" :description (format nil "Start ~A of entries at the point in time ~ indicated by TIMESTAMP-OR-SECONDS.~@ ~@ When the value should be parsed as a ~ timestamp, the syntax ~ @[YYYY-MM-DDT]HH:MM:SS has to be ~ used.~@ ~@ A single positive real number is ~ interpreted as time in seconds relative ~ to the beginning of the log ~ file. Similarly, a single negative real ~ number is interpreted as time in seconds ~ relative to the end of the log file, ~ e.g. -2.5 indicates \"2.5 seconds before ~ the end of the log file\".~@ ~@ Mutually exclusive with --start-index." action)) (make-lispobj :long-name "start-index" :short-name "S" :typespec 'integer :argument-name "INDEX" :description (format nil "Index of the entry at which the ~A ~ should start.~@ ~@ A non-negative integer N is interpreted ~ as the (N+1)-th entry relative to the ~ beginning of the log file, i.e. 0 ~ designates the first entry. A negative ~ integer N is interpreted as |N| entries ~ back from the end of the log file.~@ ~@ Mutually exclusive with --start-time." action)) (make-lispobj :long-name "end-time" :short-name "e" :typespec 'range-boundary/timestamp :argument-name "TIMESTAMP-OR-SECONDS" :description (format nil "Stop ~A of entries at the point in time ~ indicated by TIMESTAMP-OR-SECONDS.~@ ~@ When the value should be parsed as a ~ timestamp, the syntax ~ @[YYYY-MM-DDT]HH:MM:SS has to be ~ used.~@ ~@ A single real number is interpreted as ~ time in seconds relative to the ~ beginning of the ~:*~A. Similarly, a ~ single negative real number is ~ interpreted as time in seconds relative ~ to the end of the log file, e.g. -2.5 ~ indicates \"2.5 seconds before the end ~ of the log file\".~@ ~@ Mutually exclusive with --end-index." action)) (make-lispobj :long-name "end-index" :short-name "E" :typespec 'integer :argument-name "INDEX" :description (format nil "Index of the entry at which the ~A ~ should end.~@ ~@ A non-negative integer N is interpreted ~ as the (N+1)-th entry relative to the ~ beginning of the log file, i.e. 0 ~ designates the first entry. A negative ~ integer N is interpreted as |N| entries ~ back from the end of the log file.~@ ~@ Mutually exclusive with --end-time." action)) (when loop? (make-lispobj :long-name "loop" :short-name "n" :typespec '(or (eql t) positive-integer) :default-value 1 :argument-name "NUMBER-OF-TIMES-OR-T" :description (format nil "Number of times the ~A should be ~ repeated.~@ ~@ The character \"t\" indicates that the ~ ~:*~A should be repeated ~ indefinitely." action))) (make-stropt :long-name "filter" :short-name "f" :argument-name "SPEC" :description (rsb.tools.common:make-filter-help-string :show show)) (when replay-strategy? (make-stropt :long-name "replay-strategy" :short-name "r" :default-value replay-strategy-default :argument-name "SPEC" :description (make-replay-strategy-help-string :show show))) (make-enum :long-name "show-progress" :short-name "p" :enum '(:none :line :ready) :default-value show-progress-default :argument-name "STYLE" :description (format nil "Indicate progress of the ongoing ~A ~ using style STYLE." action)))) (defun process-bounds-options () "Retrieve values of the {start,end}-{time,index} commandline options, check their consistency and return them as four values: 1. start-time: `local-time:timestamp' or nil 2. start-index: `integer' or nil 3. end-time: `local-time:timestamp' or nil 4. end-index: `integer' or nil" (let+ (((start-time start-index end-time end-index) (mapcar (curry #'getopt :long-name) '("start-time" "start-index" "end-time" "end-index")))) ;; Check mutually exclusive options. (when (and start-time start-index) (error "~@<The commandline options \"start-time\" and ~ \"start-index\" are mutually exclusive.~@:>")) (when (and end-time end-index) (error "~@<The commandline options \"end-time\" and ~ \"end-index\" are mutually exclusive.~@:>")) (values start-time start-index end-time end-index))) (defun make-index-timestamp-option (&key default) (apply #'make-stropt :long-name "index-timestamp" :argument-name "NAME" :description (format nil "Name of the timestamp which should ~ be used to index events in the ~ created log file.") (when default (list :default-value "SEND")))) (defun make-channel-allocation-option (&key default (show :default)) (apply #'make-stropt :long-name "channel-allocation" :short-name "a" :argument-name "SPEC" :description (make-channel-strategy-help-string :show show) (when default (list :default-value default))))
9,928
Common Lisp
.lisp
206
28.951456
73
0.44441
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
2a336b5ef94d2309867e9cb78967820708bb16efaa54b14cd9bcb539242cd483
37,581
[ -1 ]
37,582
help.lisp
open-rsx_rsbag-tools-cl/src/common/help.lisp
;;;; help.lisp --- Automatic generation of help strings. ;;;; ;;;; Copyright (C) 2012-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.common) (defun make-replay-strategy-help-string (&key (show :default)) "Return a help string that explains how to specify replay strategies and lists the available replay strategies." (with-output-to-string (stream) (format stream "Replay events form the specified input file ~ according to SPEC which has to be of the form~@ ~@ ~2@TKIND KEY1 VALUE1 KEY2 VALUE2 ...~@ ~@ where keys and values depend on KIND and are ~ optional in most cases. Examples (note that the ~ single quotes have to be included only when used ~ within a shell):~@ ~@ ~2@T--replay-strategy recorded-timing~@ ~2@T-r as-fast-as-possible~@ ~2@T--replay-strategy 'fixed-rate :rate 10'~@ ~2@T-r 'remote-controlled :uri ~ \"spread://localhost:4803/myplayback/control\"'~@ ~@ ") (with-abbreviation (stream :strategies show) (format stream "Currently, the following strategies are supported:~@ ~@ ") (print-classes-help-string (mapcar (lambda (provider) (list (service-provider:provider-name provider) (service-provider:provider-class provider))) (service-provider:service-providers 'rsbag.rsb.replay:strategy)) stream :initarg-blacklist '(:start-index :end-index :start-time :end-time :num-repetitions :error-policy :stream :previous-command))))) (defun make-channel-strategy-help-string (&key (show :default)) "Return a help string that explains how to specify channel allocation strategies and lists the available strategies." (with-output-to-string (stream) (format stream "Allocate channels for received events in the ~ output bag file according to the strategy ~ designated by SPEC which has to be of the form~@ ~@ ~2@TKIND KEY1 VALUE1 KEY2 VALUE2 ...~@ ~@ where keys and values depend on KIND and are ~ optional in most cases. Examples (note that the ~ single quotes have to be included only when used ~ within a shell):~@ ~@ ~2@T-a scope-and-type~@ ~@ ") (with-abbreviation (stream :channel-strategies show) (format stream "Currently, the following strategies are supported:~@ ~@ ") (print-classes-help-string (mapcar (lambda (provider) (list (service-provider:provider-name provider) (service-provider:provider-class provider))) (service-provider:service-providers 'rsbag.rsb.recording:strategy)) stream))))
3,383
Common Lisp
.lisp
71
32.56338
79
0.537927
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
0fec2b412258f0ae28f55d1ad4b648e8911e95b5dd8e638e84f19416013b804b
37,582
[ -1 ]
37,583
package.lisp
open-rsx_rsbag-tools-cl/src/commands/package.lisp
;;;; package.lisp --- Package definition for the commands module. ;;;; ;;;; Copyright (C) 2013, 2014, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.tools.commands (:use #:cl #:alexandria #:let-plus #:iterate #:more-conditions #:rsbag #:rsb.tools.common) (:import-from #:rsb.tools.commands #:style-service) (:documentation "Package definition for the commands module."))
476
Common Lisp
.lisp
18
23.333333
65
0.686534
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
bec05a484f32a853deebc43865abf76be9fe4a6b695304766cb37b1595f56413
37,583
[ -1 ]
37,584
util.lisp
open-rsx_rsbag-tools-cl/src/commands/util.lisp
;;;; util.lisp --- Utilities used by commands. ;;;; ;;;; Copyright (C) 2013, 2014, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.commands) ;;; (defun coding-transform (&optional (data-access? t)) (let ((converter (if data-access? (rsb.tools.common::maybe-ensure-idl-loading-converter :converters (rsb:default-converter 'nibbles:octet-vector)) :fundamental-null))) `(&from-source :converter ,converter))) ;;; (defun print-replay-progress (stream progress index start-index end-index timestamp) ;; Print the progress of the current replay onto STREAM. (when (and progress index start-index end-index) (format stream "~C~:[N/A~:;~:*~A~] ~6,2,2F % ~9:D [~9:D,~9:D]" #\Return timestamp progress index start-index end-index) (force-output stream))) (defun print-ready (stream &rest args) (when (notany #'identity args) (format stream "ready~%") (force-output stream)))
1,083
Common Lisp
.lisp
25
36.48
82
0.63308
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
a9dfd8ca0e6b27d9ba390acf1ea0554b8388b631d6d1a8f79abafe460b95c97a
37,584
[ -1 ]
37,585
protocol.lisp
open-rsx_rsbag-tools-cl/src/commands/protocol.lisp
;;;; protocol.lisp --- Protocol provided by the commands module. ;;;; ;;;; Copyright (C) 2013, 2014, 2015 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.commands) ;;; Command service (service-provider:define-service command (:documentation "Providers of this service define commands which can be executed by the bag commandline tool."))
411
Common Lisp
.lisp
11
35.272727
70
0.740554
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
6aa9ecfeb24d57c19f9e0e804c21abfee405bad50c730de9d14d703bd731046e
37,585
[ -1 ]
37,586
introspect.lisp
open-rsx_rsbag-tools-cl/src/commands/introspect.lisp
;;;; introspect.lisp --- Implementation of the introspect command. ;;;; ;;;; Copyright (C) 2013, 2014, 2015, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.commands) (defun introspection-channel? (channel) (starts-with-subseq (load-time-value (rsb:scope-string rsb.introspection:+introspection-participants-scope+) t) (channel-name channel))) (defclass introspect (file-input-mixin bag->events-mixin rsb.tools.commands:style-mixin rsb.tools.commands:output-stream-mixin progress-mixin print-items:print-items-mixin) ((rsb.tools.commands::style-service :allocation :class :initform 'rsb.formatting.introspection::style) (progress-style :initform :line)) (:default-initargs :channels #'introspection-channel?) (:documentation "Gather introspection information from log files. The file formats of input files are determined based on the file type (extension).")) (augment-class-documentation-with-backends 'introspect) (service-provider:register-provider/class 'command :introspect :class 'introspect) (defmethod rsb.tools.commands:command-execute ((command introspect) &key error-policy) ;; Gather the following things: ;; + input file(s) ;; + selected channels for replay ;; + temporal/index range for replay ;; + formatting style ;; Pass all of these to `bag->events' for and start the resulting ;; connection. (let+ (((&accessors-r/o (input-files command-input-files) (channels command-replay-channels) ((&values start-time start-index end-time end-index) command-replay-bounds) (style rsb.tools.commands:command-style) (stream rsb.tools.commands:command-stream) (progress-style command-progress-style)) command) (database (make-instance 'rsb.introspection::remote-introspection-database)) ((&flet process-entry (timestamp event) (declare (ignore timestamp) ) (when (and (not (rsb:event-method event)) (not (typep (rsb:event-data event) 'rsb.introspection:bye))) (rsb.ep:handle database event))))) (rsbag.rsb:with-open-connection (connection (apply #'rsbag.rsb:bag->events input-files #'process-entry :error-policy error-policy :channels channels :transform `(&from-source :converter ,rsb.introspection::*introspection-all-converters*) :replay-strategy :as-fast-as-possible (append (when start-time (list :start-time start-time)) (when start-index (list :start-index start-index)) (when end-time (list :end-time end-time)) (when end-index (list :end-index end-index))))) (log:info "~@<Replaying using connection ~A~@:>" connection) (rsbag.rsb.replay:replay connection (rsbag.rsb.replay:connection-strategy connection) :progress (case progress-style (:line (curry #'print-replay-progress *info-output*))))) (case progress-style (:line (fresh-line *info-output*))) (setf (rsb.formatting.introspection::style-database style) database) (rsb.formatting:format-event :dummy style stream)))
3,837
Common Lisp
.lisp
79
35.987342
97
0.581333
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
6e6f9b284051abdc40f8235104dd8e46a0bf10ce2fb56f66f8680e1d07225d63
37,586
[ -1 ]
37,587
transform.lisp
open-rsx_rsbag-tools-cl/src/commands/transform.lisp
;;;; transform.lisp --- Implementation of the transform command. ;;;; ;;;; Copyright (C) 2013, 2014, 2015, 2016, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.commands) ;;; `transform' command class (eval-when (:compile-toplevel :load-toplevel :execute) (defclass transform (file-input-mixin file-output-mixin bag->events-mixin rsb.tools.commands:filter-mixin index-timestamp-mixin channel-allocation-mixin progress-mixin print-items:print-items-mixin) ((index-timestamp :initform nil) (channel-allocation :initform (make-instance 'clone)) (transform/datum :initarg :transform/datum :reader command-transform/datum :initform nil :documentation "If not nil, a function designator for transforming entries. The function is called with an entry and must return the transformed entry. ") (transform/timestamp :initarg :transform/timestamp :reader command-transform/timestamp :initform nil :documentation "If not nil, a function designator for transforming timstamps. The function is called with the original timestamp and the (potentially already transformed) entry and must return the transformed timestamp.")) (:documentation "Copy events from input log files into a new log file. Copy entries from input files matching GLOB-EXPRESSION or from an explicitly given list of INPUT-FILEs into the specified output file. In addition to the canonical globbing syntax, expressions of the form SOMESTUFF/**/MORESTUFF can be used to search directories recursively. The file formats of input files and the output file are determined based on the file type (extension)."))) (augment-class-documentation-with-backends 'transform) (service-provider:register-provider/class 'command :transform :class 'transform) (defmethod rsb.tools.commands:command-execute ((command transform) &key error-policy) (let+ (((&accessors-r/o (input-files command-input-files) (channels command-replay-channels) ((&values start-time start-index end-time end-index) command-replay-bounds) (filters rsb.tools.commands:command-filters) (output-file command-output-file) (force? command-force?) (index-timestamp command-index-timestamp) (channel-allocation command-channel-allocation) (transform/datum command-transform/datum) (transform/timestamp command-transform/timestamp) (progress-style command-progress-style)) command) ;; Plumbing starts here. (sink) (store-datum (if index-timestamp (lambda (timestamp datum) (declare (ignore timestamp)) (rsbag.rsb.recording:process-event sink nil datum)) (lambda (timestamp datum) (rsbag.rsb.recording:process-event sink timestamp datum)))) ((&flet wrap-process-datum-for-clone () (let+ (((&flet note-source-and-store (source timestamp event) (push (cons event source) (strategy-%events channel-allocation)) (funcall store-datum timestamp event)))) (note-source-channel (curry #'%compose-transform transform/datum transform/timestamp) #'note-source-and-store)))) (sink-function (cond ((typep channel-allocation 'clone) (wrap-process-datum-for-clone)) ((rsb.ep:access? channel-allocation :meta-data :read) (annotate-wire-schema (%compose-transform transform/datum transform/timestamp store-datum))) (t (%compose-transform transform/datum transform/timestamp store-datum)))) (access (%access filters transform/datum index-timestamp channel-allocation)) (make-transform (ecase access (:data (lambda () (coding-transform t))) (:event (lambda () (coding-transform nil))) ((nil) (constantly '(nil)))))) (rsbag.rsb:with-open-connection (input (apply #'rsbag.rsb:bag->events input-files sink-function :error-policy error-policy :channels channels :filters filters :transform (funcall make-transform) :replay-strategy :as-fast-as-possible (append (when start-time (list :start-time start-time)) (when start-index (list :start-index start-index)) (when end-time (list :end-time end-time)) (when end-index (list :end-index end-index))))) (rsbag.rsb:with-open-connection (output (apply #'rsbag.rsb:events->bag nil output-file :error-policy error-policy :if-exists (if force? :supersede :error) :transform (funcall make-transform) :channel-strategy channel-allocation (when index-timestamp (list :timestamp index-timestamp)))) (setf sink output) (rsbag.rsb.replay:replay input (rsbag.rsb.replay:connection-strategy input) :progress (case progress-style (:line (curry #'print-replay-progress *info-output*)) (:ready (curry #'print-ready *info-output*)))))))) ;;; Determine required amount of de/encoding (defun %access (filters transform? index-timestamp channel-strategy) (let+ ((processors (list* channel-strategy filters)) ((&flet parts () (mapcar #'car rsb.event-processing:*event-parts*)))) (cond ((or transform? (rsb.ep:access? processors :data :read)) :data) ((or index-timestamp (rsb.ep:access? processors (parts) :read)) :event) (t nil)))) ;;; Datum and timestamp transform (defun %compose-transform (transform/datum transform/timestamp cont) (declare (type function cont)) (cond ((and transform/datum transform/timestamp) (locally (declare (type function transform/datum transform/timestamp)) (lambda (timestamp datum) (when-let* ((datum/transformed (funcall transform/datum datum)) (timestamp/transformed (funcall transform/timestamp timestamp datum/transformed))) (funcall cont timestamp/transformed datum/transformed))))) (transform/datum (locally (declare (type function transform/datum)) (lambda (timestamp datum) (when-let ((datum/transformed (funcall transform/datum datum))) (funcall cont timestamp datum/transformed))))) (transform/timestamp (locally (declare (type function transform/timestamp)) (lambda (timestamp datum) (when-let ((timestamp/transformed (funcall transform/timestamp timestamp datum))) (funcall cont timestamp/transformed datum))))) (t cont))) ;;; `clone' channel allocation strategy ;;; ;;; In the `channels' slot, the strategy instance stores a mapping ;;; from channels in the source bag(s) to channels in the destination ;;; bag. This mapping is initially empty when the strategy object is ;;; created. ;;; ;;; When an event is processed, a cell of the form ;;; ;;; (EVENT . SOURCE-CHANNEL) ;;; ;;; must be pushed onto the alist stored in the `events' slot. This is ;;; used to look up SOURCE-CHANNEL when EVENT is processed in the ;;; `ensure-channel-for' method. (defclass clone () ((channels :reader strategy-channels :initform (make-hash-table :test #'eq) :documentation "Maps channels in the source bag(s) to channels in the destination bag.") (events :accessor strategy-%events :initform '() :documentation "An always almost empty alist of elements of the form (EVENT . SOURCE-CHANNEL) .")) (:documentation "Clones channels in the source into the destination.")) (defmethod rsbag.rsb.recording:ensure-channel-for ((connection t) (event t) (strategy clone)) (let+ (((&structure strategy- channels %events) strategy) (source-channel (prog1 (assoc-value %events event :test #'eq) (removef %events event :test #'eq :key #'car))) (found? t) ((&flet make-channel (condition) (declare (ignore condition)) (setf found? nil) (let ((meta-data (rsbag:channel-meta-data source-channel))) (invoke-restart 'rsbag:create meta-data)))) ((&flet maybe-make-channel () (let ((bag (rsbag.rsb:connection-bag connection)) (name (rsbag:channel-name source-channel))) (rsbag:bag-channel bag name :if-does-not-exist #'make-channel))))) (values (ensure-gethash source-channel channels (maybe-make-channel)) found?))) ;;; `note-source-channel' ;;; ;;; Helper construct which wraps a function for recording source ;;; channels of events around the function provided to `bag->events'. (defstruct (note-source-channel (:constructor note-source-channel (make-sink note-function)) (:predicate nil) (:copier nil)) (make-sink nil :type function :read-only t) (note-function nil :type function :read-only t)) (defmethod rsbag.rsb:bag->events ((source channel) (dest note-source-channel) &rest args &key) (let+ (((&structure-r/o note-source-channel- make-sink note-function) dest) (sink (funcall make-sink (curry note-function source)))) (apply #'rsbag.rsb:bag->events source sink args))) ;;; `annotate-wire-schema' ;;; ;;; Helper construct which wraps a function for injecting the RSB ;;; wire-schema into the meta-data of events around the sink function ;;; provided to `bag->events'. (defstruct (annotate-wire-schema (:constructor annotate-wire-schema (function)) (:predicate nil) (:copier nil)) (function nil :type function :read-only t)) (defmethod rsbag.rsb:bag->events ((source channel) (dest annotate-wire-schema) &rest args &key) (let+ ((type (getf (channel-meta-data source) :type)) ((&flet rsb-type? (type) (and (typep type '(cons keyword (cons symbol null))) (starts-with-subseq "RSB-EVENT" (symbol-name (first type)))))) (wire-schema (when (rsb-type? type) (second type))) ((&structure-r/o annotate-wire-schema- function) dest) ((&flet annotate (timestamp event) (setf (rsb:meta-data event :rsb.transport.wire-schema) wire-schema) (funcall function timestamp event))) (sink (if wire-schema #'annotate function))) (apply #'rsbag.rsb:bag->events source sink args)))
12,795
Common Lisp
.lisp
257
34.867704
83
0.547794
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
6350d349b43cc80822cef487a9efef0bd3a42f3872458ed677e8a904c3f92c4c
37,587
[ -1 ]
37,588
cat.lisp
open-rsx_rsbag-tools-cl/src/commands/cat.lisp
;;;; cat.lisp --- Implementation of the cat command. ;;;; ;;;; Copyright (C) 2013, 2014, 2015, 2016, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.commands) (defclass cat (file-input-mixin bag->events-mixin rsb.tools.commands:filter-mixin replay-mixin rsb.tools.commands:style-mixin rsb.tools.commands:output-stream-mixin progress-mixin print-items:print-items-mixin) () (:documentation "Format events from log files onto the standard output stream. The file formats of input files are determined based on the file type (extension).")) (augment-class-documentation-with-backends 'cat) (service-provider:register-provider/class 'command :cat :class 'cat) (defmethod rsb.tools.commands:command-execute ((command cat) &key error-policy) ;; Gather the following things: ;; + input file(s) ;; + selected channels for replay ;; + temporal/index range for replay ;; + formatting style ;; Pass all of these to `bag->events' for and start the resulting ;; connection. (let+ (((&accessors-r/o (input-files command-input-files) (channels command-replay-channels) ((&values start-time start-index end-time end-index) command-replay-bounds) (num-repetitions command-replay-num-repetitions) (filters rsb.tools.commands:command-filters) (replay-strategy command-replay-strategy) (style rsb.tools.commands:command-style) (stream rsb.tools.commands:command-stream) (progress-style command-progress-style)) command) (access? (rsb.ep:access? (list* style filters) :data :read)) (sink (lambda (timestamp datum) ; TODO should be a mixin from rsb-tools-cl (declare (ignore timestamp)) (if (typep datum 'rsb:event) (rsb.formatting:format-event datum style stream) (rsb.formatting:format-payload datum (rsb.formatting:style-payload-style style) stream))))) (rsbag.rsb:with-open-connection (connection (apply #'rsbag.rsb:bag->events input-files sink ; TODO should return connection and strategy as two values :error-policy error-policy :channels channels :filters filters :transform (coding-transform access?) :replay-strategy replay-strategy (append (when start-time (list :start-time start-time)) (when start-index (list :start-index start-index)) (when end-time (list :end-time end-time)) (when end-index (list :end-index end-index)) (when num-repetitions (list :num-repetitions num-repetitions))))) (log:info "~@<Replaying using connection ~A~@:>" connection) (rsbag.rsb.replay:replay connection (rsbag.rsb.replay:connection-strategy connection) :progress (case progress-style (:line (curry #'print-replay-progress *info-output*)) (:ready (curry #'print-ready *info-output*)))))))
3,685
Common Lisp
.lisp
73
35.931507
116
0.554631
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f638fbef2a834a41a5be59b760b5cbfd385652d794b3a38f4bb55688475ab1e6
37,588
[ -1 ]
37,589
info.lisp
open-rsx_rsbag-tools-cl/src/commands/info.lisp
;;;; info.lisp --- Implementation of the info command. ;;;; ;;;; Copyright (C) 2014, 2015, 2016, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.commands) ;;; `info-style' service (service-provider:define-service info-style (:documentation "Providers of this service implement printing and other processing of bag information")) (service-provider:register-provider/class 'info-style :json :class 'rsb.formatting:style-json :allow-forward-reference t) ;;; `bag-style-tree' class (defclass bag-style-tree () ((builder :initarg :builder :reader style-builder :documentation "Stores the builder that should be used to traverse the bag and its channels.")) (:default-initargs :builder (missing-required-initarg 'bag-style-tree :builder)) (:documentation "Format bag and channel info as a textual tree.")) (declaim (special *stream*)) (defmethod rsb.formatting:format-event ((event bag) (style bag-style-tree) (stream t) &key) (let+ (((&structure-r/o style- builder) style) ((&flet format* (format-control &rest format-arguments) (apply #'format *stream* format-control format-arguments))) ((&flet format-slot (name value &key (format "~A") (newline? t)) (format *stream* "~@(~8A~): ~:[~2*N/A~;~?~]~:[~;~@:_~]" name value format (list value) newline?))) ((&flet format-default-slots (&key event-count data-size start end duration rate &allow-other-keys) (format-slot :events event-count :format "~,,',:D") (when data-size (format-slot :size data-size :format "~,,',:D")) (format-slot :start start) (format-slot :end end) (format-slot :duration duration :format "~,6F") (format-slot :rate rate :format "~,3F" :newline? nil))) ((&flet format-bag (recurse &rest initargs &key location &allow-other-keys) (format* "File ~S~@:_~2@T" location) (pprint-logical-block (*stream* nil) (apply #'format-default-slots initargs) (pprint-newline :mandatory *stream*) (funcall recurse)))) ((&flet format-channel (recurse &rest initargs &key name &allow-other-keys) (format* "Channel ~S~@:_~2@T" name) (pprint-logical-block (*stream* nil) (funcall recurse) (apply #'format-default-slots initargs)) (pprint-newline :mandatory *stream*))) ((&flet format-node (recurse relation relation-args node kind relations &rest initargs) (declare (ignore relation relation-args node relations)) (apply (ecase kind (rsbag:bag #'format-bag) (rsbag:channel #'format-channel)) recurse initargs))) ((&flet peek (builder relation relation-args node) (declare (ignore builder relation-args)) (case relation ((:type :format) (format-slot relation (list node) :format "~<~@;~A~:>")) (t t)))) (*stream* stream)) (pprint-logical-block (*stream* (list event)) (architecture.builder-protocol:with-unbuilder (builder builder) (architecture.builder-protocol:walk-nodes builder (architecture.builder-protocol:peeking #'peek #'format-node) event))) (fresh-line stream))) (service-provider:register-provider/class 'info-style :tree :class 'bag-style-tree) ;;; `info' command class (defclass info (file-input-mixin rsb.tools.commands:style-mixin rsb.tools.commands:output-stream-mixin print-items:print-items-mixin) ((style-service :allocation :class :initform 'info-style) (compute-sizes? :initarg :compute-sizes? :type boolean :reader info-compute-sizes? :initform nil :documentation "Compute the sizes of the content of the whole log file and individual channels. This may take some time for large files." #+later (:short-name "s")) (print-format :initarg :print-format :type (member nil :short :full) :reader info-print-format :initform :short :documentation "Print format information for each channel?." #+later (:short-name "f"))) (:documentation "Display information about a log file. The file format of the log file is guessed based on the filename.")) (augment-class-documentation-with-backends 'info) (service-provider:register-provider/class 'command :info :class 'info) (defmethod rsb.tools.commands:command-execute ((command info) &key error-policy) (declare (ignore error-policy)) (let+ (((&accessors-r/o (input-files command-input-files) (style rsb.tools.commands:command-style) (stream rsb.tools.commands:command-stream)) command) ((&flet process-bag (input) (with-simple-restart (continue "~@<Skip ~A.~@:>" input) (with-bag (bag input :direction :input :transform '(nil)) (rsb.formatting:format-event bag style stream)))))) (mapc #'process-bag input-files))) (defmethod rsb.tools.commands:command-make-style ((command info) (spec cons) (service t)) (let+ (((&structure-r/o info- compute-sizes? print-format) command) (builder (make-instance 'rsbag.builder:unbuilder :compute-sizes? compute-sizes? :format? print-format)) (spec (append spec (list :builder builder)))) (call-next-method command spec service)))
6,614
Common Lisp
.lisp
140
33.571429
78
0.539331
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e8f601f85a36fd50ab23dbbcdbd1e44fbcd8d4738402197c1436c0d506c435fb
37,589
[ -1 ]
37,590
redump.lisp
open-rsx_rsbag-tools-cl/src/commands/redump.lisp
;;;; redump.lisp --- Redump command. ;;;; ;;;; Copyright (C) 2013, 2014, 2015 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.commands) (service-provider:register-provider/class 'command :redump :class 'rsb.tools.commands:redump)
294
Common Lisp
.lisp
8
35.375
61
0.728873
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
b5b0f36855df246c99b4eae70079020165c11b3ac78005075e9116128257c5fb
37,590
[ -1 ]
37,591
package.lisp
open-rsx_rsbag-tools-cl/bag-merge/package.lisp
;;;; package.lisp --- Package definition for the bag-merge program. ;;;; ;;;; Copyright (C) 2011, 2012, 2013, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.tools.merge (:use #:cl #:alexandria #:let-plus #:iterate #:net.didierverna.clon #:rsbag #:rsb.tools.common #:rsbag.tools.common) (:export #:main) (:documentation "Package definition for the bag-merge program."))
477
Common Lisp
.lisp
19
21.947368
67
0.675497
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
ed54435a94882624bec39766d484d277e64fd711d8dded1881a65ba254073ee2
37,591
[ -1 ]
37,592
main.lisp
open-rsx_rsbag-tools-cl/bag-merge/main.lisp
;;;; main.lisp --- Main function of the bag-merge program. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.merge) (defun make-help-string () "Return a help that explains the commandline option interface." (rsbag.tools.commands::augment-documentation-with-backends "Copy entries from input files matching GLOB-EXPRESSION or from an ~ explicitly given list of INPUT-FILEs into the specified output ~ file. In addition to the canonical globbing syntax, expressions of ~ the form~@ ~@ ~2@TSOMESTUFF/**/MORESTUFF~@ ~@ can be used to search directories recursively.~@ ~@ The file formats of input files and the output file are determined ~ based on the file type (extension).")) (defun make-example-string (&key (program-name "bag merge")) "Make and return a string containing usage examples of the program." (format nil "~2@T~A -o bla.tide '/vol/my-separate-logs/*.tide'~@ ~@ Merge all log files matching the glob expression ~ \"/vol/my-separate-logs/*.tide\" into a single log file ~ named \"bla.tide\". Note the quotes which prevent the ~ shell from interpreting the glob expression.~@ ~@ " program-name)) (defun update-synopsis (&key (show :default) (program-name "bag merge")) "Create and return a commandline option tree." (make-synopsis :postfix "GLOB-EXPRESSION | INPUT-FILE+" :item (make-text :contents (make-help-string)) :item (make-common-options :show show) :item (make-error-handling-options :show show) :item (make-replay-options :show show :loop? nil :replay-strategy? nil :show-progress-default :line :action "processing") :item (defgroup (:header "Transform Options") (path :long-name "output-file" :short-name "o" :type :file :description (rsbag.tools.commands::augment-documentation-with-backends "Name of the file into which captured events ~ should be written. The file format is ~ determined based on the file ~ type (extension).")) (flag :long-name "force" :description "Should the output file be overwritten in case it already exists?") (make-index-timestamp-option) (make-channel-allocation-option :show show) (stropt :long-name "transform-datum" #+todo :argument-name #+todo :description #+todo "TODO") (stropt :long-name "transform-timestamp" :argument-name "TIMESTAMP-NAME" :description "Index events by TIMESTAMP-NAME instead of the create timestamp.")) ;; Append IDL options. :item (make-idl-options) :item (defgroup (:header "Examples") (make-text :contents (make-example-string :program-name program-name))))) (defun make-channel-filter (specs) (when specs (apply #'disjoin (mapcar (lambda (spec) (lambda (channel) (cl-ppcre:scan spec (channel-name channel)))) specs)))) (defun main (program-pathname args) "Entry point function of the bag-merge program." (let ((program-name (concatenate 'string (namestring program-pathname) " merge")) (*readtable* (copy-readtable *readtable*))) (update-synopsis :program-name program-name) (local-time:enable-read-macros) (process-commandline-options :commandline (list* program-name args) :version (cl-rsbag-tools-merge-system:version/list :commit? t) :more-versions (list :rsbag (cl-rsbag-system:version/list :commit? t) :rsbag-tidelog (cl-rsbag-system:version/list :commit? t)) :update-synopsis (curry #'update-synopsis :program-name program-name) :return (lambda () (return-from main)))) (let+ ((error-policy (maybe-relay-to-thread (process-error-handling-options))) (input-files (remainder)) (channels (let ((specs (iter (for channel next (getopt :long-name "channel")) (while channel) (collect channel)))) (or (make-channel-filter specs) t))) ((&values start-time start-index end-time end-index) (process-bounds-options)) (filters (iter (for spec next (getopt :long-name "filter")) (while spec) (collect (apply #'rsb.filter:filter (parse-instantiation-spec spec))))) (progress-style (getopt :long-name "show-progress")) (transform/datum (getopt :long-name "transform-datum")) (transform/timestamp (getopt :long-name "transform-timestamp")) (output-file (or (getopt :long-name "output-file") (error "~@<No output file specified.~@:>"))) (force? (getopt :long-name "force")) (index-timestamp (when-let ((value (getopt :long-name "index-timestamp"))) (make-keyword value))) (channel-allocation (getopt :long-name "channel-allocation"))) (rsb.formatting:with-print-limits (*standard-output*) (with-logged-warnings (with-error-policy (error-policy) ;; Load IDLs as specified on the commandline. (process-idl-options :purpose '(:packed-size :serializer :deserializer)) (let* ((transform/datum (when transform/datum (eval (read-from-string transform/datum)))) (transform/timestamp (when transform/timestamp (read-from-string transform/timestamp))) (command (apply #'rsb.tools.commands:make-command :transform :service 'rsbag.tools.commands::command :input-files input-files :channels channels :start-time start-time :start-index start-index :end-time end-time :end-index end-index :filters filters :output-file output-file :force? force? :progress-style progress-style (append (when index-timestamp (list :index-timestamp index-timestamp)) (when channel-allocation (list :channel-allocation-spec channel-allocation)) (when transform/datum (list :transform/datum transform/datum)) (etypecase transform/timestamp (null '()) (keyword (list :transform/timestamp (lambda (timestamp datum) (declare (ignore timestamp)) (rsb:timestamp datum transform/timestamp))))))))) (rsb.tools.commands:command-execute command :error-policy error-policy)))))))
8,159
Common Lisp
.lisp
158
35.550633
97
0.515015
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e6ab4ba76749e5ceabe1ad3e93ca184cea1351ba5e16859ad517a08ba67a7f5e
37,592
[ -1 ]
37,593
export-video-as-pngs.lisp
open-rsx_rsbag-tools-cl/scripts/export-video-as-pngs.lisp
;;;; export-video-as-pngs.lisp --- Export rst.vision.Image payloads as PNG files. ;;;; ;;;; Copyright (C) 2012, 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> #.(unless (when-let* ((package (find-package "RST.VISION")) (symbol (find-symbol "IMAGE-WIDTH" package))) (ignore-errors (fdefinition `(setf ,symbol)))) (error "~@<Class RST.VISION:IMAGE is not loaded properly. Did you ~ load the Image.proto file using the --load-idl ~ option?~@:>")) (let* (;; Directory into which output images should be written. Note ;; trailing `/'. (output-directory "./") ;; Width and height can be specified as follows: ;; ;; + t -> retain the width/height of the input ;; image ;; + (:% PERCENT) -> scale to PERCENT percent of the ;; width/height of the input image ;; + (:px PIXELS) -> scale to PIXELS width/height ;; ;; The latter two forms may not support arbitrary output sizes ;; and silently use to the nearest possible sizes when a ;; requested size is not supported. (style (make-style '(:image/png :width t :height t))) ;; Create an output filename within the specified output ;; directory based on the timestamp of the current event. (filename (merge-pathnames (format nil "~A.~A" (floor create-unix/nsec 1000) "png") output-directory))) (format t "~CProcessing frame ~A -> ~A" #\Return create-unix/nsec filename) (force-output *standard-output*) ;; Make sure the output directory actually exists, creating it if ;; necessary. (ensure-directories-exist output-directory) ;; Write the payload of the current event into the output file, ;; formatting the data as a PNG image. (with-output-to-file (stream filename :if-exists :overwrite :if-does-not-exist :create :element-type '(unsigned-byte 8)) (format-payload data style stream)))
2,244
Common Lisp
.lisp
45
40.088889
81
0.575661
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
cf7a5e1c12e905df39e95a13b4614f06c9ac6014b84827078db8eee209979b42
37,593
[ -1 ]
37,594
export-audio-as-wav.lisp
open-rsx_rsbag-tools-cl/scripts/export-audio-as-wav.lisp
;;;; export-audio-as-wav.lisp --- Export rst.audition.SoundChunk as WAV stream. ;;;; ;;;; Copyright (C) 2012, 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> ;;;; Note: this script exists mainly for educational purposes. In most ;;;; cases, the :audio-stream/wav formatting style can be used ;;;; instead. #.(unless (when-let* ((package (find-package "RST.AUDITION")) (symbol (find-symbol "SOUND-CHUNK-CHANNELS" package))) (ignore-errors (fdefinition `(setf ,symbol)))) (error "~@<Class RST.AUDITION:SOUND-CHUNK is not loaded ~ properly. Did you load the SoundChunk.proto file using the ~ --load-idl option?~@:>")) (let+ (((&accessors-r/o (channels rst.audition:sound-chunk-channels) (sample-rate rst.audition:sound-chunk-rate) (sample-format rst.audition:sound-chunk-sample-type) (samples rst.audition:sound-chunk-data)) data) (width (ecase sample-format ((:sample-s8 :sample-u8) 1) ((:sample-s16 :sample-u16) 2) ((:sample-s24 :sample-u24) 3))) (byte-rate (* channels sample-rate width))) ;; Write WAV header, if we have not done that yet. We record the ;; fact that the header has been written by binding the variable ;; header-written? to t. (unless (boundp 'header-written?) (format *error-output* "Writing wave header for ~A (~D ~ byte~:P/sample) x ~D channel~:P @ ~:D Hz~%" sample-format width channels sample-rate) (format *error-output* "Begin timestamp ~A~%" create) ;; The non-constant fields have the following meanings: ;; 0 Size ;; 1 Format ;; 2 Number of Channels ;; 3 Sample Rate ;; 4 Byte Rate ;; 5 Block Alignment ;; 6 Bits per Sample ;; 7 Sub Chunk Size (let ((wave-header-template (vector #x52 #x49 #x46 #x46 0 0 0 0 #x57 #x41 #x56 #x45 #x66 #x6d #x74 #x20 #x10 #x00 #x00 #x00 1 1 2 2 3 3 3 3 4 4 4 4 5 5 6 6 #x64 #x61 #x74 #x61 7 7 7 7)) (fake-size #x7fffffff)) ;; Assumed maximum possible size) (macrolet ((set-field (start size value) (once-only (value) `(iter (for i :below ,size) (setf (aref wave-header-template (+ ,start i)) (ldb (byte 8 (* i 8)) ,value)))))) ;; Regarding "Size" and "Sub chunk size": We use ;; ;; Size: fake-size ;; Sub chunk size: (- fake-size 44) ;; ;; where SIZE is the assumed maximum size, since we cannot know ;; the file size in advance. This seems to make most software do ;; the right thing. (set-field 4 4 fake-size) ; Size. (set-field 20 2 1) ; PCM format (set-field 22 2 channels) ; Number of channels (set-field 24 4 sample-rate) ; Sample rate (set-field 28 4 byte-rate) ; Byte rate (set-field 32 2 width) ; Block alignment (set-field 34 2 (* width 8)) ; Bits per sample (set-field 40 4 (- fake-size 44))) ; Sub chunk size (write-sequence wave-header-template stream)) (set 'header-written? t)) (format *error-output* "~CProcessing buffer ~A" #\Return create) (force-output *error-output*) (write-sequence samples stream))
3,619
Common Lisp
.lisp
74
39.310811
79
0.553859
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
7d555b640c614e3ddb1f7000951b36a7adb0d0b8a51e9228e8010985c1de9c49
37,594
[ -1 ]
37,595
package.lisp
open-rsx_rsbag-tools-cl/bag-introspect/package.lisp
;;;; package.lisp --- Package definition for the bag-introspect program. ;;;; ;;;; Copyright (C) 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.tools.introspect (:use #:cl #:alexandria #:let-plus #:iterate #:net.didierverna.clon #:rsb.tools.common #:rsbag.tools.common) (:export #:main) (:documentation "Package definition for the bag-introspect program."))
463
Common Lisp
.lisp
18
22.611111
72
0.690909
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
d1eab9995c700e84628823a84c69a6a93bc7f1fc5b107badc61f4c6ed0f6686f
37,595
[ -1 ]
37,596
main.lisp
open-rsx_rsbag-tools-cl/bag-introspect/main.lisp
;;;; main.lisp --- Main function of the bag-introspect program. ;;;; ;;;; Copyright (C) 2015, 2016, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.introspect) ;;; Help and main functions (defun make-help-string () "Return a help that explains the commandline option interface." (rsbag.tools.commands::augment-documentation-with-backends "Gather introspection information from the log file(s) ~ INPUT-FILE+ (or standard input, if \"-\" is specified) and ~ display it on standard output (or otherwise process it).~@ ~@ The file format(s) of INPUT-FILE+ is/are guessed based on the ~ filename(s).")) (defun make-examples-string (&key (program-name "bag introspect")) "Make and return a string containing usage examples of the program." (format nil "~2T~A log-file.tide~@ ~@ Gather introspection information from the log file ~ log-file.tide and display it using the default formatting ~ style." program-name)) (defun update-synopsis (&key (show :default) (program-name "bag introspect")) "Create and return a commandline option tree." (make-synopsis ;; Basic usage and specific options. :postfix "INPUT-FILE+ or -" :item (make-text :contents (make-help-string)) :item (make-common-options :show show) :item (make-error-handling-options :show show) :item (make-replay-options :show show :action "introspection" :channel? nil :loop? nil :replay-strategy? nil :show-progress-default :line) :item (defgroup (:header "Output Options") (stropt :long-name "style" :default-value "object-tree :stateful? nil :delay nil" :argument-name "SPEC" :description (with-output-to-string (stream) (with-abbreviation (stream :styles show) (write-string (rsb.formatting::make-style-service-help-string :service 'rsb.formatting.introspection::style :initarg-blacklist '(:database)) stream)))) (enum :long-name "target-stream" :enum '(:stdout :standard-output :stderr :error-output) :default-value :standard-output :argument-name "STREAM-NAME" :description "Stream to which produced output should be sent.")) ;; Append examples. :item (defgroup (:header "Examples") (make-text :contents (make-examples-string :program-name program-name))))) (defun main (program-pathname args) "Entry point function of the bag-introspect program." (let ((program-name (concatenate 'string (namestring program-pathname) " introspect")) (*readtable* (copy-readtable *readtable*))) ; TODO still necessary? (update-synopsis :program-name program-name) (local-time:enable-read-macros) (process-commandline-options :commandline (list* program-name args) :version (cl-rsbag-tools-introspect-system:version/list :commit? t) :more-versions (list :rsbag (cl-rsbag-system:version/list :commit? t) :rsbag-tidelog (cl-rsbag-system:version/list :commit? t)) :update-synopsis (curry #'update-synopsis :program-name program-name) :return (lambda () (return-from main)))) (when (emptyp (remainder)) (error "~@<Specify at least one input file.~@:>")) (let+ ((error-policy (maybe-relay-to-thread (process-error-handling-options))) (input-files (remainder)) ((&values start-time start-index end-time end-index) (process-bounds-options)) (style (getopt :long-name "style")) (target-stream (getopt :long-name "target-stream")) (progress-style (getopt :long-name "show-progress"))) (rsb.formatting:with-print-limits (*standard-output*) (with-logged-warnings (with-error-policy (error-policy) ;; Gather the following things from commandline options: ;; + input file(s) ;; + temporal/index range for replay ;; + formatting style ;; Pass all of these to `bag->events' for and start the ;; resulting connection. (let ((command (rsb.tools.commands:make-command :introspect :service 'rsbag.tools.commands::command :input-files input-files :start-time start-time :start-index start-index :end-time end-time :end-index end-index :style-spec style :stream-spec target-stream :progress-style progress-style))) (with-interactive-interrupt-exit () (rsb.tools.commands:command-execute command :error-policy error-policy))))))))
5,582
Common Lisp
.lisp
111
37.018018
97
0.549698
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
ddadd79c6f852cd277f25c0ce32ec087df0caf4a273964521d54a2f4bdcb4c1b
37,596
[ -1 ]
37,597
package.lisp
open-rsx_rsbag-tools-cl/bag-record/package.lisp
;;;; package.lisp --- Package definition for the bag-record program. ;;;; ;;;; Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.tools.record (:shadowing-import-from #:rsbag #:direction #:meta-data #:meta-data-count #:meta-data-keys #:meta-data-values #:meta-data-plist #:meta-data-alist) (:use #:cl #:alexandria #:iterate #:let-plus #:net.didierverna.clon #:rsb #:rsb.patterns.request-reply #:rsb.tools.common #:rsbag #:rsbag.rsb) (:export #:main) (:documentation "Package definition for the bag-record program."))
691
Common Lisp
.lisp
29
20.310345
68
0.668196
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
05bd48146ed35384168763be6f2166093dcb216c1ddc4cb02fe8965d61485ff8
37,597
[ -1 ]
37,598
main.lisp
open-rsx_rsbag-tools-cl/bag-record/main.lisp
;;;; main.lisp --- Main function of the bag-record program. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.record) (defun update-synopsis (&key (show :default) (program-name "rsbag record")) "Create and return a commandline option tree." (make-synopsis ;; Basic usage and specific options. :postfix "[URIS]" :item (make-text :contents (make-help-string :show show)) :item (make-common-options :show show) :item (make-error-handling-options :show show) :item (defgroup (:header "Recording Options") (path :long-name "output-file" :short-name "o" :type :file :description (rsbag.tools.commands::augment-documentation-with-backends "Name of the file into which captured events ~ should be written. The file format is ~ determined based on the file ~ type (extension).")) (switch :long-name "force" :default-value nil :description "Should the output file be overwritten in case it already exists?") (rsbag.tools.common:make-index-timestamp-option :default "SEND") (rsbag.tools.common:make-channel-allocation-option :default "collapse-reserved :next :scope-and-type" :show show) (stropt :long-name "filter" :short-name "f" :argument-name "SPEC" :description (make-filter-help-string :show show)) (stropt :long-name "flush-strategy" :argument-name "SPEC" :description (make-flush-strategy-help-string :show show)) (stropt :long-name "control-uri" :short-name "c" :argument-name "URI" :description (format nil "An URI specifying the root scope ~ and transport configuration of a remote interface which allows ~ controlling the recording process. The remote interface consists of ~ two parts: 1) an event-based interface for change notification 2) a ~ request-reply interface for manipulating the recording.~@_ ~@_ Event-based Part~@_ ~@_ State changes are communicated using an event-based interface below ~ the scope CONTROL-SCOPE/state with the following sub-scopes:~@_ ~@_ CONTROL-SCOPE/state/ready : void~@_ ~@_ An event without payload is published on this scope when the ~ recording and its remote interface become available.~@_ ~@_ CONTROL-SCOPE/state/terminated : void~@_ ~@_ An event without payload is published on this scope when the ~ remote interface terminates.~@_ ~@_ CONTROL-SCOPE/state/open : string~@_ ~@_ An event carrying the name of the currently opened log file as its ~ payload is published on this scope when a log file is newly opened ~ or a recording is stopped.~@_ ~@_ CONTROL-SCOPE/state/started : string~@_ ~@_ An event carrying the name of the currently opened log file as its ~ payload is published on this scope when a recording is started.~@_ ~@_ The following state transitions can occur:~@_ ~@_ --> ready <-> open <-> started~@_ |~@_ v~@_ terminated~@_ ~@_ Request/Reply Part~@_ ~@_ CONTROL-SCOPE/isstarted : void -> bool~@_ ~@_ Return true if a log file has been opened for recording and ~ recording is currently in progress and false otherwise.~@_ ~@_ CONTROL-SCOPE/start : void -> void~@_ ~@_ Restart recording after it has been stopped. Only applicable if a ~ bag has been opened. ~@_ CONTROL-SCOPE/stop : void -> void~@_ ~@_ Stop recording allowing it to be restarted later. Only applicable ~ if a bag has been opened.~@_ ~@_ CONTROL-SCOPE/isopen : void -> string or false~@_ ~@_ If a log file has been opened for recording, return its path as a ~ string. Otherwise return false.~@_ ~@_ CONTROL-SCOPE/open : string -> void~@_ ~@_ Open the specified file to record into it. Does not start ~ recording. Only applicable if not bag is currently open.~@_ ~@_ CONTROL-SCOPE/ensuredirectoryandopen : string -> void~@_ ~@_ Like open but create the directories on the path to the specified ~ file, if necessary.~@_ ~@_ CONTROL-SCOPE/close : void -> void~@_ ~@_ Close the current bag. Only applicable if a bag is open. ~@_ CONTROL-SCOPE/terminate : void -> void~@_ ~@_ Terminate the recording process and the program.")) (switch :long-name "introspection-survey" :default-value t :description (format nil "Perform an introspection survey at ~ the beginning of the recording to ~ ensure it contains a complete ~ snapshot of the system structure ~ from which incremental changes can ~ be tracked.")) (enum :long-name "progress-style" :short-name "p" :enum '(:none :entries :channels) :default-value :entries :argument-name "SPEC" :description (format nil "The style used to display ~ information about the recorded ~ data. \"none\" to disable."))) ;; Append RSB options. :item (make-options :show? (or (eq show t) (and (listp show) (member :rsb show)))) ;; Append IDL options. :item (make-idl-options) ;; Append examples. :item (defgroup (:header "Examples") (make-text :contents (make-examples-string :program-name program-name))))) (defun main (program-pathname args) "Entry point function of the bag-record program." (let ((program-name (concatenate 'string (namestring program-pathname) " record") )) (update-synopsis :program-name program-name) (setf *configuration* (options-from-default-sources)) (process-commandline-options :commandline (list* program-name args) :version (cl-rsbag-tools-record-system:version/list :commit? t) :more-versions (list :rsbag (cl-rsbag-system:version/list :commit? t) :rsbag-tidelog (cl-rsbag-system:version/list :commit? t)) :update-synopsis (curry #'update-synopsis :program-name program-name) :return (lambda () (return-from main)))) (unless (remainder) (error "~@<Specify at least one URI from which events should be ~ recorded.~@:>")) (let ((error-policy (maybe-relay-to-thread (process-error-handling-options))) (uris (remainder)) (filters (iter (for spec next (getopt :long-name "filter")) (while spec) (collect (apply #'rsb.filter:filter (parse-instantiation-spec spec))))) (output-file (getopt :long-name "output-file")) (force? (getopt :long-name "force")) (index-timestamp (make-keyword (getopt :long-name "index-timestamp"))) (channel-allocation (getopt :long-name "channel-allocation")) (flush-strategy (getopt :long-name "flush-strategy")) (control-uri (when-let ((string (getopt :long-name "control-uri"))) (puri:parse-uri string))) (introspection-survey? (getopt :long-name "introspection-survey")) (progress-style (getopt :long-name "progress-style"))) (rsb.formatting:with-print-limits (*standard-output*) (with-logged-warnings (with-error-policy (error-policy) ;; Load IDLs as specified on the commandline. (process-idl-options) (let ((command (apply #'rsb.tools.commands:make-command :record :service 'rsbag.tools.commands::command :uris uris :filters filters :output-file output-file :force? force? :index-timestamp index-timestamp :channel-allocation-spec channel-allocation :control-uri control-uri :introspection-survey? introspection-survey? :progress-style progress-style (when flush-strategy (list :flush-strategy-spec flush-strategy))))) (rsb.tools.commands:command-execute command :error-policy error-policy)))))))
9,507
Common Lisp
.lisp
207
33.975845
90
0.547127
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
c04104ae70315a34a8215429c6aa9cad36d3e0d8d85bd73c415e22b92d7946b6
37,598
[ -1 ]
37,599
help.lisp
open-rsx_rsbag-tools-cl/bag-record/help.lisp
;;;; help.lisp --- Help text generation for the bag-record program. ;;;; ;;;; Copyright (C) 2012-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.record) (defun make-help-string (&key (show :default)) "Return a help that explains the commandline option interface." (with-output-to-string (stream) (format stream "Capture events being exchanged on the scopes ~ designated by URIS and store them in the specified ~ output file. For each URI, one or more channels ~ may be created in the output file (depending on ~ the channel allocation strategy). These channels ~ store the events exchanged in the corresponding ~ RSB channels.~@ ~@ ") (with-abbreviation (stream :uri show) (format stream "Each URI has to be of the form~@ ~@ ") (print-uri-help stream :uri-var "each URI")))) (defun make-filter-help-string (&key (show :default)) "Return a help string that explains how to specify filters and lists the available filters. " (with-output-to-string (stream) (format stream "Specify a filter that received events have to ~ match in order to be processed rather than ~ discarded. This option can be supplied multiple ~ times in which case events have to match all ~ specified filters. Each SPEC has to be of the form~@ ~@ ~2@TKIND KEY1 VALUE1 KEY2 VALUE2 ...~@ ~@ where keys and values depend on KIND and may be ~ optional in some cases. Examples (note that the ~ single quotes have to be included only when used ~ within a shell):~@ ~@ ~2@T--filter 'origin ~ \"EAEE2B00-AF4B-11E0-8930-001AA0342D7D\"'~@ ~2@T--filter 'regex \".*foo[0-9]+\"'~@ ~2@T--filter 'regex :regex ~ \".*foo[0-9]+\"' (equivalent)~@ ~2@T-f 'xpath :xpath ~ \"node()/@foo\" :fallback-policy :do-not-match'~@ ~@ ") (with-abbreviation (stream :filters show) (format stream "The following filters are currently available:~@ ~@ ") (print-filter-help stream)))) (defun make-flush-strategy-help-string (&key (show :default)) "Return a help string that explains how to specify flush strategies and lists the available strategies." (with-output-to-string (stream) (format stream "Flush buffers to background storage according to ~ the strategy designated by SPEC which has to be of ~ the form~@ ~@ ~2@TKIND KEY1 VALUE1 KEY2 VALUE2 ...~@ ~@ where keys and values depend on KIND and are ~ optional in most cases. Examples (note that the ~ single quotes have to be included only when used ~ within a shell):~@ ~@ ~2@T--flush-strategy 'property-limit :property :length/bytes :limit ~ 33554432'~@ ~2@T--flush-strategy ~ 'property-limit :property :time-to-last-write :limit ~ 5'~@ ~2@T--flush-strategy ~ 'or (:property-limit :property :time-to-last-write :limit ~ 5) (:property-limit :property :length/bytes :limit ~ 33554432)'~@ ~@ ") (with-abbreviation (stream :flush-strategies show) (format stream "Currently, the following strategies are supported:~@ ~@ ") (print-classes-help-string (mapcar (lambda (provider) (list (service-provider:provider-name provider) (service-provider:provider-class provider))) (service-provider:service-providers 'rsbag.backend:flush-strategy)) stream)))) (defun make-examples-string (&key (program-name "bag record")) "Make and return a string containing usage examples of the program." (format nil "~2@T~A -o /tmp/everything.tide spread://azurit:4803/~@ ~@ Connect to the bus using the Spread transport assuming ~ the Spread daemon is listening on port 4803 on host ~ \"azurit\". Participate in the \"root\" ~ channel (designated by \"/\") and capture all events ~ into the log file \"/tmp/everything.tide\". Recording ~ continues until the program receives SIGINT or SIGTERM ~ each of which causes a clean shutdown.~@ ~@ ~2@T~:*~A -o /tmp/nao.tide -f 'xpath :xpath ~ \"node()/@width = ~ 100\" :fallback-policy :do-not-match' ~ 'spread:/nao/vision/top?name=4803'~@ ~@ Store events for the scope \"/nao/vision/top\" (and ~ sub-scopes) in the log file \"/tmp/nao.tide\", if the ~ event payload has a width field that has the value ~ 100. The bus connection uses the Spread transport with ~ the daemon name option.~@ ~@ ~2@T~:*~A -o /tmp/multichannel.tide ~ 'spread:/nao/vision/top' 'spread:/nao/audio/all'~@ ~@ Store events being exchanged on the channels designated ~ by \"/nao/vision/top\" and \"/nao/audio/all\" into the ~ log file \"/tmp/multichannel.tide\".~@ " program-name))
6,189
Common Lisp
.lisp
126
33.365079
89
0.515021
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
a432066791c1d2bbd2572dc022b0a7e887742b1ce01e697f70ce15c97227820f
37,599
[ -1 ]
37,600
package.lisp
open-rsx_rsbag-tools-cl/bag-cat/package.lisp
;;;; package.lisp --- Package definition for the bag-cat program. ;;;; ;;;; Copyright (C) 2011, 2012, 2013, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.tools.cat (:shadowing-import-from #:rsbag #:direction #:meta-data #:meta-data-count #:meta-data-keys #:meta-data-values #:meta-data-plist #:meta-data-alist) (:shadowing-import-from #:rsb.formatting #:create) (:use #:cl #:alexandria #:let-plus #:iterate #:net.didierverna.clon #:rsb #:rsb.tools.common #:rsb.formatting #:rsbag #:rsbag.view #:rsbag.rsb #:rsbag.tools.common) (:export #:main) (:documentation "Package definition for the bag-cat program."))
760
Common Lisp
.lisp
33
19.484848
65
0.663421
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
923605a47a01add77b976514b70abdc62d24e1bd38763d408bd6b6c9572ef24b
37,600
[ -1 ]
37,601
main.lisp
open-rsx_rsbag-tools-cl/bag-cat/main.lisp
;;;; main.lisp --- Main function of the bag-cat program. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.cat) ;;; Help and main functions (defun make-help-string () "Return a help that explains the commandline option interface." (rsbag.tools.commands::augment-documentation-with-backends "Outputs data from channels in the bag file(s) INPUT-FILE+ (or ~ standard input, if \"-\" is specified) on standard output.~@ ~@ The file format(s) of INPUT-FILE+ is/are guessed based on the ~ filename(s).")) (defun make-examples-string (&key (program-name "bag cat")) "Make and return a string containing usage examples of the program." (format nil "~2T~A /tmp/everything.tide~@ ~@ Output the data from all channels in the log file ~ \"/tmp/everything.tide\" ordered by timestamps.~@ ~@ ~2T~:*~A -c isr /tmp/nao.tide~@ ~@ Output the data from all channels of the log file ~ \"/tmp/nao.tide\" the names of which contain the string ~ \"isr\".~@ ~@ ~2T~:*~A --channel 'STRING$' --channel 'BYTES$' log.tide~@ ~@ Output the data from all channels of the log file ~ \"log.tide\" whose names end in either \"STRING\" or ~ \"BYTES\".~@ ~@ ~2T~:*~A --style 'payload :separator (#\\Newline (:rule ~ #\\-))' log.tide ~@ ~@ Print event payloads separating payloads of different ~ events by newlines and horizontal rules.~@ ~@ ~2T~:*~A --style 'programmable/template :template ~ #P\"my-template-file.template\"' log.tide~@ ~@ Format events in the log file \"log.tide\" by applying the ~ template in \"my-template-file.template\" to each ~ event. See output of --help-for styles for more ~ information." program-name)) (defun update-synopsis (&key (show :default) (program-name "bag cat")) "Create and return a commandline option tree." (make-synopsis ;; Basic usage and specific options. :postfix "INPUT-FILE+ or -" :item (make-text :contents (make-help-string)) :item (make-common-options :show show) :item (make-error-handling-options :show show) :item (make-replay-options :show show :replay-strategy-default "as-fast-as-possible" :action "processing") :item (defgroup (:header "Output Options") (stropt :long-name "style" :default-value "payload" :argument-name "SPEC" :description (make-style-help-string :show show)) (enum :long-name "target-stream" :enum '(:stdout :standard-output :stderr :error-output) :default-value :standard-output :argument-name "STREAM-NAME" :description "Stream to which produced output should be sent.")) ;; Append IDL options. :item (make-idl-options) ;; Append examples. :item (defgroup (:header "Examples") (make-text :contents (make-examples-string :program-name program-name))))) (defun make-channel-filter (specs) (when specs (apply #'disjoin (mapcar (lambda (spec) (lambda (channel) (cl-ppcre:scan spec (channel-name channel)))) specs)))) (defun main (program-pathname args) "Entry point function of the bag-cat program." (let ((program-name (concatenate 'string (namestring program-pathname) " cat")) (*readtable* (copy-readtable *readtable*))) ; TODO still necessary? (update-synopsis :program-name program-name) (local-time:enable-read-macros) (process-commandline-options :commandline (list* program-name args) :version (cl-rsbag-tools-cat-system:version/list :commit? t) :more-versions (list :rsbag (cl-rsbag-system:version/list :commit? t) :rsbag-tidelog (cl-rsbag-system:version/list :commit? t)) :update-synopsis (curry #'update-synopsis :program-name program-name) :return (lambda () (return-from main)))) (when (emptyp (remainder)) (error "~@<Specify at least one input file.~@:>")) (let+ ((error-policy (maybe-relay-to-thread (process-error-handling-options))) (input-files (remainder)) (channels (let ((specs (iter (for channel next (getopt :long-name "channel")) (while channel) (collect channel)))) (or (make-channel-filter specs) t))) ((&values start-time start-index end-time end-index) (process-bounds-options)) (loop (getopt :long-name "loop")) (filters (iter (for spec next (getopt :long-name "filter")) (while spec) (collect (apply #'rsb.filter:filter (parse-instantiation-spec spec))))) (replay-strategy (getopt :long-name "replay-strategy")) (style (getopt :long-name "style")) (target-stream (getopt :long-name "target-stream")) (progress-style (getopt :long-name "show-progress"))) (with-print-limits (*standard-output*) (with-logged-warnings (with-error-policy (error-policy) ;; Load IDLs as specified on the commandline. (process-idl-options) ;; Gather the following things from commandline options: ;; + input file(s) ;; + selected channels for replay ;; + temporal/index range for replay ;; + formatting style ;; Pass all of these to `bag->events' for and start the ;; resulting connection. (let ((command (rsb.tools.commands:make-command :cat :service 'rsbag.tools.commands::command :input-files input-files :channels channels :start-time start-time :start-index start-index :end-time end-time :end-index end-index :num-repetitions loop :filters filters :replay-strategy-spec replay-strategy :style-spec style :stream-spec target-stream :progress-style progress-style))) (with-interactive-interrupt-exit () (rsb.tools.commands:command-execute command :error-policy error-policy))))))))
7,278
Common Lisp
.lisp
154
34.707792
90
0.533886
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
b90abdaa30708fbd1d9ea0f4539aa8e112208f3121955e7e0eabdafde635d9a2
37,601
[ -1 ]
37,602
package.lisp
open-rsx_rsbag-tools-cl/bag-info/package.lisp
;;;; package.lisp --- Package definition for the bag-info program. ;;;; ;;;; Copyright (C) 2011, 2012, 2013, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.tools.info (:use #:cl #:alexandria #:let-plus #:iterate #:net.didierverna.clon #:rsbag #:rsb.tools.common #:rsb.formatting) (:shadowing-import-from #:rsb.formatting #:create) (:shadow #:make-style-help-string) (:export #:main) (:documentation "Package definition for the bag-info program."))
568
Common Lisp
.lisp
23
21.391304
66
0.674721
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
c8c8d382a920ed5665650c5c3c9a2573595d4cbf063ac0a9c807aa67a717b45e
37,602
[ -1 ]
37,603
main.lisp
open-rsx_rsbag-tools-cl/bag-info/main.lisp
;;;; main.lisp --- Main function of the bag-info program. ;;;; ;;;; Copyright (C) 2011-2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.info) (defun make-help-string () "Return a help that explains the commandline option interface." (rsbag.tools.commands::augment-documentation-with-backends "Display information about BAG-FILE.~@ ~@ The file format of BAG-FILE is guessed based on the filename.")) (defun make-style-help-string (&key (show :default)) (with-output-to-string (stream) (with-abbreviation (stream :styles show) (write-string (rsb.formatting::make-style-service-help-string :service 'rsbag.tools.commands::info-style :initarg-blacklist '(:builder :event-peek-function :payload-peek-function)) stream)))) (defun make-example-string (&key (program-name "bag info")) "Make and return a string containing usage examples of the program." (format nil "~2@T~A /tmp/everything.tide~@ " program-name)) (defun update-synopsis (&key (show :default) (program-name "rsbag info")) "Create and return a commandline option tree." (make-synopsis :postfix "BAG-FILE+" :item (make-text :contents (make-help-string)) :item (make-common-options :show show) :item (make-error-handling-options :show show) :item (defgroup (:header "Output Options") (stropt :long-name "style" :default-value "tree" :argument-name "SPEC" :description (make-style-help-string :show show)) (flag :long-name "compute-sizes" :short-name "s" :description "Compute the sizes of the content of the whole log file and individual channels. This may take some time for large files.") (enum :long-name "print-format" :short-name "f" :enum '(:no :short :full) :default-value :short :description "Print format information for each channel.")) :item (defgroup (:header "Examples") (make-text :contents (make-example-string :program-name program-name))))) (defun main (program-pathname args) "Entry point function of the bag-info program." (let ((program-name (concatenate 'string (namestring program-pathname) " info"))) (update-synopsis :program-name program-name) (process-commandline-options :commandline (list* program-name args) :version (cl-rsbag-tools-info-system:version/list :commit? t) :more-versions (list :rsbag (cl-rsbag-system:version/list :commit? t) :rsbag-tidelog (cl-rsbag-system:version/list :commit? t)) :update-synopsis (curry #'update-synopsis :program-name program-name) :return (lambda () (return-from main)))) (when (emptyp (remainder)) (error "~@<Specify exactly at least one input file.~@:>")) (let ((error-policy (maybe-relay-to-thread (process-error-handling-options))) (input-files (remainder)) (style (getopt :long-name "style")) (compute-sizes (getopt :long-name "compute-sizes")) (print-format (getopt :long-name "print-format"))) (with-print-limits (*standard-output*) (with-logged-warnings (with-error-policy (error-policy) (let ((command (rsb.tools.commands:make-command :info :service 'rsbag.tools.commands::command :input-files input-files :style-spec style :compute-sizes? compute-sizes :print-format (case print-format (:no) (t print-format))))) (rsb.tools.commands:command-execute command :error-policy error-policy)))))))
4,365
Common Lisp
.lisp
89
36.247191
146
0.554124
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
6abcfbc97864568d1cebeb6dc24670ef559eb9be3132d6176e47c83526e62a4b
37,603
[ -1 ]
37,605
sbcl.cmake.in
open-rsx_rsbag-tools-cl/sbcl.cmake.in
if(NOT WIN32) set(ENV{CC} "@CMAKE_C_COMPILER@") endif() set(ENV{SBCL_HOME} "@SBCL_HOME@") set(ENV{CL_SOURCE_REGISTRY} "@CL_SOURCE_REGISTRY@") set(ENV{ASDF_OUTPUT_TRANSLATIONS} "@ASDF_OUTPUT_TRANSLATIONS@") execute_process(COMMAND "@SBCL_EXECUTABLE@" --noinform @LISP_RUNTIME_OPTIONS@ --disable-debugger --no-sysinit --no-userinit @LISP_INIT@ --load "@CMAKE_CURRENT_SOURCE_DIR@/sbclrc" @DO@ WORKING_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@" @REDIRECTIONS@ RESULT_VARIABLE RESULT) if(NOT ${RESULT} EQUAL 0) message(FATAL_ERROR "Failed to execute lisp process @NAME@") endif()
899
Common Lisp
.cl
20
29.2
76
0.479499
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e550e621aa02d427a53ba4643979927e49e6b04976591494a366cbc471b64dc2
37,605
[ -1 ]
37,610
lift-rsbag-tools-commands.config
open-rsx_rsbag-tools-cl/lift-rsbag-tools-commands.config
;;; Configuration for LIFT tests ;; Settings (:print-length 10) (:print-level 5) (:print-test-case-names t) ;; Suites to run (rsbag.tools.commands.test:rsbag-tools-commands-root) ;; Report properties (:report-property :title "rsbag-tools-commands | Test Results") (:report-property :relative-to rsbag-tools-commands-test) (:report-property :format :html) (:report-property :full-pathname "test-report-rsbag-tools-commands.html/") (:report-property :if-exists :supersede) (:report-property :style-sheet "test-style.css") (:build-report) (:report-property :format :junit) (:report-property :full-pathname "test-results-rsbag-tools-commands.xml") (:report-property :if-exists :supersede) (:build-report) (:report-property :format :describe) (:report-property :full-pathname *standard-output*) (:build-report)
872
Common Lisp
.l
22
38.363636
74
0.716825
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
53cbd5f28160fbde3dd335432e8036a6814d0a0a87ca6d2c025cb2a6e09c27f9
37,610
[ -1 ]
37,612
simple.eaf
open-rsx_rsbag-tools-cl/test/data/elan/simple.eaf
<?xml version="1.0" encoding="UTF-8"?> <ANNOTATION_DOCUMENT AUTHOR="unspecified" DATE="2004-08-25T16:13:18+01:00" FORMAT="2.2" VERSION="2.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.mpi.nl/tools/elan/EAFv2.2.xsd"> <HEADER MEDIA_FILE="" TIME_UNITS="milliseconds"> </HEADER> <TIME_ORDER> <TIME_SLOT TIME_SLOT_ID="ts1" TIME_VALUE="500"/> <TIME_SLOT TIME_SLOT_ID="ts2" TIME_VALUE="500"/> <TIME_SLOT TIME_SLOT_ID="ts3" TIME_VALUE="3013"/> <TIME_SLOT TIME_SLOT_ID="ts4" TIME_VALUE="3013"/> <TIME_SLOT TIME_SLOT_ID="ts5" TIME_VALUE="3130"/> <TIME_SLOT TIME_SLOT_ID="ts6" TIME_VALUE="3130"/> <TIME_SLOT TIME_SLOT_ID="ts7" TIME_VALUE="7807"/> <TIME_SLOT TIME_SLOT_ID="ts8" TIME_VALUE="7807"/> <TIME_SLOT TIME_SLOT_ID="ts9" TIME_VALUE="8043"/> <TIME_SLOT TIME_SLOT_ID="ts10" TIME_VALUE="8043"/> <TIME_SLOT TIME_SLOT_ID="ts11" TIME_VALUE="10327"/> <TIME_SLOT TIME_SLOT_ID="ts12" TIME_VALUE="10327"/> <TIME_SLOT TIME_SLOT_ID="ts13" TIME_VALUE="11197"/> <TIME_SLOT TIME_SLOT_ID="ts14" TIME_VALUE="11197"/> <TIME_SLOT TIME_SLOT_ID="ts15" TIME_VALUE="22677"/> <TIME_SLOT TIME_SLOT_ID="ts16" TIME_VALUE="22677"/> <TIME_SLOT TIME_SLOT_ID="ts17" TIME_VALUE="23399"/> <TIME_SLOT TIME_SLOT_ID="ts18" TIME_VALUE="23399"/> <TIME_SLOT TIME_SLOT_ID="ts19" TIME_VALUE="26237"/> <TIME_SLOT TIME_SLOT_ID="ts20" TIME_VALUE="26237"/> <TIME_SLOT TIME_SLOT_ID="ts21" TIME_VALUE="27169"/> <TIME_SLOT TIME_SLOT_ID="ts22" TIME_VALUE="27169"/> <TIME_SLOT TIME_SLOT_ID="ts23" TIME_VALUE="27617"/> <TIME_SLOT TIME_SLOT_ID="ts24" TIME_VALUE="27617"/> <TIME_SLOT TIME_SLOT_ID="ts25" TIME_VALUE="27697"/> <TIME_SLOT TIME_SLOT_ID="ts26" TIME_VALUE="27697"/> <TIME_SLOT TIME_SLOT_ID="ts27" TIME_VALUE="28356"/> <TIME_SLOT TIME_SLOT_ID="ts28" TIME_VALUE="28356"/> <TIME_SLOT TIME_SLOT_ID="ts29" TIME_VALUE="29327"/> <TIME_SLOT TIME_SLOT_ID="ts30" TIME_VALUE="29327"/> <TIME_SLOT TIME_SLOT_ID="ts31" TIME_VALUE="31316"/> <TIME_SLOT TIME_SLOT_ID="ts32" TIME_VALUE="31316"/> <TIME_SLOT TIME_SLOT_ID="ts33" TIME_VALUE="32206"/> <TIME_SLOT TIME_SLOT_ID="ts34" TIME_VALUE="32206"/> <TIME_SLOT TIME_SLOT_ID="ts35" TIME_VALUE="33766"/> <TIME_SLOT TIME_SLOT_ID="ts36" TIME_VALUE="33766"/> <TIME_SLOT TIME_SLOT_ID="ts37" TIME_VALUE="34066"/> <TIME_SLOT TIME_SLOT_ID="ts38" TIME_VALUE="34066"/> <TIME_SLOT TIME_SLOT_ID="ts39" TIME_VALUE="34456"/> <TIME_SLOT TIME_SLOT_ID="ts40" TIME_VALUE="34456"/> <TIME_SLOT TIME_SLOT_ID="ts41" TIME_VALUE="34682"/> <TIME_SLOT TIME_SLOT_ID="ts42" TIME_VALUE="34682"/> <TIME_SLOT TIME_SLOT_ID="ts43" TIME_VALUE="41936"/> <TIME_SLOT TIME_SLOT_ID="ts44" TIME_VALUE="41936"/> <TIME_SLOT TIME_SLOT_ID="ts45" TIME_VALUE="42692"/> <TIME_SLOT TIME_SLOT_ID="ts46" TIME_VALUE="42692"/> <TIME_SLOT TIME_SLOT_ID="ts47" TIME_VALUE="50586"/> <TIME_SLOT TIME_SLOT_ID="ts48" TIME_VALUE="50586"/> <TIME_SLOT TIME_SLOT_ID="ts49" TIME_VALUE="51797"/> <TIME_SLOT TIME_SLOT_ID="ts50" TIME_VALUE="51797"/> <TIME_SLOT TIME_SLOT_ID="ts51" TIME_VALUE="53181"/> <TIME_SLOT TIME_SLOT_ID="ts52" TIME_VALUE="53181"/> <TIME_SLOT TIME_SLOT_ID="ts53" TIME_VALUE="55027"/> <TIME_SLOT TIME_SLOT_ID="ts54" TIME_VALUE="55027"/> <TIME_SLOT TIME_SLOT_ID="ts55" TIME_VALUE="55081"/> <TIME_SLOT TIME_SLOT_ID="ts56" TIME_VALUE="55081"/> <TIME_SLOT TIME_SLOT_ID="ts57" TIME_VALUE="55811"/> <TIME_SLOT TIME_SLOT_ID="ts58" TIME_VALUE="55811"/> <TIME_SLOT TIME_SLOT_ID="ts59" TIME_VALUE="65289"/> <TIME_SLOT TIME_SLOT_ID="ts60" TIME_VALUE="65289"/> <TIME_SLOT TIME_SLOT_ID="ts61" TIME_VALUE="65891"/> <TIME_SLOT TIME_SLOT_ID="ts62" TIME_VALUE="65891"/> <TIME_SLOT TIME_SLOT_ID="ts63" TIME_VALUE="82779"/> <TIME_SLOT TIME_SLOT_ID="ts64" TIME_VALUE="82779"/> <TIME_SLOT TIME_SLOT_ID="ts65" TIME_VALUE="82827"/> <TIME_SLOT TIME_SLOT_ID="ts66" TIME_VALUE="82827"/> <TIME_SLOT TIME_SLOT_ID="ts67" TIME_VALUE="84663"/> <TIME_SLOT TIME_SLOT_ID="ts68" TIME_VALUE="84663"/> <TIME_SLOT TIME_SLOT_ID="ts69" TIME_VALUE="86187"/> <TIME_SLOT TIME_SLOT_ID="ts70" TIME_VALUE="86187"/> <TIME_SLOT TIME_SLOT_ID="ts71" TIME_VALUE="86663"/> <TIME_SLOT TIME_SLOT_ID="ts72" TIME_VALUE="86663"/> <TIME_SLOT TIME_SLOT_ID="ts73" TIME_VALUE="87156"/> <TIME_SLOT TIME_SLOT_ID="ts74" TIME_VALUE="87156"/> <TIME_SLOT TIME_SLOT_ID="ts75" TIME_VALUE="91023"/> <TIME_SLOT TIME_SLOT_ID="ts76" TIME_VALUE="91023"/> <TIME_SLOT TIME_SLOT_ID="ts77" TIME_VALUE="91816"/> <TIME_SLOT TIME_SLOT_ID="ts78" TIME_VALUE="91816"/> <TIME_SLOT TIME_SLOT_ID="ts79" TIME_VALUE="99333"/> <TIME_SLOT TIME_SLOT_ID="ts80" TIME_VALUE="99333"/> <TIME_SLOT TIME_SLOT_ID="ts81" TIME_VALUE="100373"/> <TIME_SLOT TIME_SLOT_ID="ts82" TIME_VALUE="100373"/> <TIME_SLOT TIME_SLOT_ID="ts83" TIME_VALUE="102539"/> <TIME_SLOT TIME_SLOT_ID="ts84" TIME_VALUE="102539"/> <TIME_SLOT TIME_SLOT_ID="ts85" TIME_VALUE="103659"/> <TIME_SLOT TIME_SLOT_ID="ts86" TIME_VALUE="103659"/> <TIME_SLOT TIME_SLOT_ID="ts87" TIME_VALUE="103823"/> <TIME_SLOT TIME_SLOT_ID="ts88" TIME_VALUE="103823"/> <TIME_SLOT TIME_SLOT_ID="ts89" TIME_VALUE="104429"/> <TIME_SLOT TIME_SLOT_ID="ts90" TIME_VALUE="104429"/> <TIME_SLOT TIME_SLOT_ID="ts91" TIME_VALUE="120149"/> <TIME_SLOT TIME_SLOT_ID="ts92" TIME_VALUE="120149"/> <TIME_SLOT TIME_SLOT_ID="ts93" TIME_VALUE="120427"/> <TIME_SLOT TIME_SLOT_ID="ts94" TIME_VALUE="120427"/> <TIME_SLOT TIME_SLOT_ID="ts95" TIME_VALUE="125148"/> <TIME_SLOT TIME_SLOT_ID="ts96" TIME_VALUE="125148"/> <TIME_SLOT TIME_SLOT_ID="ts97" TIME_VALUE="125297"/> <TIME_SLOT TIME_SLOT_ID="ts98" TIME_VALUE="125297"/> <TIME_SLOT TIME_SLOT_ID="ts99" TIME_VALUE="139168"/> <TIME_SLOT TIME_SLOT_ID="ts100" TIME_VALUE="139168"/> <TIME_SLOT TIME_SLOT_ID="ts101" TIME_VALUE="139934"/> <TIME_SLOT TIME_SLOT_ID="ts102" TIME_VALUE="139934"/> <TIME_SLOT TIME_SLOT_ID="ts103" TIME_VALUE="153397"/> <TIME_SLOT TIME_SLOT_ID="ts104" TIME_VALUE="153397"/> <TIME_SLOT TIME_SLOT_ID="ts105" TIME_VALUE="153454"/> <TIME_SLOT TIME_SLOT_ID="ts106" TIME_VALUE="153454"/> <TIME_SLOT TIME_SLOT_ID="ts107" TIME_VALUE="156820"/> <TIME_SLOT TIME_SLOT_ID="ts108" TIME_VALUE="156820"/> <TIME_SLOT TIME_SLOT_ID="ts109" TIME_VALUE="157957"/> <TIME_SLOT TIME_SLOT_ID="ts110" TIME_VALUE="157957"/> <TIME_SLOT TIME_SLOT_ID="ts111" TIME_VALUE="172860"/> <TIME_SLOT TIME_SLOT_ID="ts112" TIME_VALUE="172860"/> <TIME_SLOT TIME_SLOT_ID="ts113" TIME_VALUE="172955"/> <TIME_SLOT TIME_SLOT_ID="ts114" TIME_VALUE="172955"/> <TIME_SLOT TIME_SLOT_ID="ts115" TIME_VALUE="185285"/> <TIME_SLOT TIME_SLOT_ID="ts116" TIME_VALUE="185285"/> <TIME_SLOT TIME_SLOT_ID="ts117" TIME_VALUE="185600"/> <TIME_SLOT TIME_SLOT_ID="ts118" TIME_VALUE="185600"/> <TIME_SLOT TIME_SLOT_ID="ts119" TIME_VALUE="186860"/> <TIME_SLOT TIME_SLOT_ID="ts120" TIME_VALUE="186860"/> <TIME_SLOT TIME_SLOT_ID="ts121" TIME_VALUE="187010"/> <TIME_SLOT TIME_SLOT_ID="ts122" TIME_VALUE="187010"/> <TIME_SLOT TIME_SLOT_ID="ts123" TIME_VALUE="187630"/> <TIME_SLOT TIME_SLOT_ID="ts124" TIME_VALUE="187630"/> </TIME_ORDER> <TIER DEFAULT_LOCALE="sv" LINGUISTIC_TYPE_REF="Default" PARTICIPANT="" TIER_ID="Translation English A"> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a1" TIME_SLOT_REF1="ts4" TIME_SLOT_REF2="ts10"> <ANNOTATION_VALUE>My name is Jenny Ingvarsson and this is my name sign. </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a2" TIME_SLOT_REF1="ts12" TIME_SLOT_REF2="ts16"> <ANNOTATION_VALUE>Well, first of all it indicates my curly hair, and when I was a small I always emphasized the “y” when I fingerspelled my name “j e n n y”, with real emphasis. My preschool teachers wanted to have a sign that only indicated my curly hair, but I wanted to add the “y” so that is the combination.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a3" TIME_SLOT_REF1="ts20" TIME_SLOT_REF2="ts24"> <ANNOTATION_VALUE>I was born in Stockholm.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a4" TIME_SLOT_REF1="ts28" TIME_SLOT_REF2="ts32"> <ANNOTATION_VALUE>Yes, I grew up in Stockholm and I still live in Stockholm.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a5" TIME_SLOT_REF1="ts36" TIME_SLOT_REF2="ts40"> <ANNOTATION_VALUE>Yes.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a6" TIME_SLOT_REF1="ts44" TIME_SLOT_REF2="ts48"> <ANNOTATION_VALUE>Well, my father is hard of hearing and my mother is deaf. I have two brothers, one who is eighteen who is deaf, and one who is fifteen who is hearing.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a7" TIME_SLOT_REF1="ts52" TIME_SLOT_REF2="ts58"> <ANNOTATION_VALUE>Sure, everybody is fluent in sign language.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a8" TIME_SLOT_REF1="ts60" TIME_SLOT_REF2="ts64"> <ANNOTATION_VALUE>Yes, I went to the Manilla school. First I lived very close to town, so I used to go every day to the Manilla School. And when I was thirteen, we moved into one of the suburbs and bought a house there. So we lived there and I went to the Manilla school for about ten years. And then four years in Örebro in the high school for the deaf there. And then I came back to Stockholm.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a9" TIME_SLOT_REF1="ts68" TIME_SLOT_REF2="ts72"> <ANNOTATION_VALUE>No, I still live with my parents. </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a10" TIME_SLOT_REF1="ts76" TIME_SLOT_REF2="ts80"> <ANNOTATION_VALUE>I work at the Manilla school for the deaf as a resource teacher. The semester is just finished, so this fall I am starting teacher’s training college.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a11" TIME_SLOT_REF1="ts84" TIME_SLOT_REF2="ts86"> <ANNOTATION_VALUE>Yes, I do. </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a12" TIME_SLOT_REF1="ts90" TIME_SLOT_REF2="ts92"> <ANNOTATION_VALUE>I stayed in Australia for a year and I worked as a teacher’s assistant there in a school for the deaf in a city called Melbourne. I was there for a year and then I came back and I worked at the Manilla school for a year. I feel that, yes, being a teacher is what I really want, so I am starting my studies this fall and that is really going to be interesting. </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a13" TIME_SLOT_REF1="ts96" TIME_SLOT_REF2="ts100"> <ANNOTATION_VALUE>Yes, of course, that was the best trip I ever did. A whole year! I learnt a lot. I made new experiences, I made new friends, I became more self-relying. I really learnt a lot. It was truly the best trip I have ever done, that one to Australia. </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a14" TIME_SLOT_REF1="ts102" TIME_SLOT_REF2="ts106"> <ANNOTATION_VALUE>And also I travelled around a lot and I stayed there so long. I worked there and then in the summer vacation, I went to New Zeeland. I went to New Zeeland and I stayed there for a while, then I came back to Australia and I travelled round Australia. It was really great. I will never forget that trip. </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a15" TIME_SLOT_REF1="ts108" TIME_SLOT_REF2="ts112"> <ANNOTATION_VALUE>Oh, I guess then that would have to be from when we were in New Zeeland. It was Christmas and New Year. And I was there in a skirt and only a tank top. And there we were. New Years Eve! It was summer and we were camping and we were lying on the beach, and at the same time it was New Years Eve! That was really a strange feeling, also because it was not like a holiday trip.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a16" TIME_SLOT_REF1="ts114" TIME_SLOT_REF2="ts116"> <ANNOTATION_VALUE>And it was not just a vacation. I lived in Australia for a year. That was like, OK, so this is what it is like to have New Year in the summer. I was used to all those things in Sweden with snow and everything, so that was really a strange experience.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a17" TIME_SLOT_REF1="ts120" TIME_SLOT_REF2="ts124"> <ANNOTATION_VALUE>Yes. </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> </TIER> <TIER DEFAULT_LOCALE="sv" LINGUISTIC_TYPE_REF="Default" PARTICIPANT="" TIER_ID="Translation Swedish A"> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a18" TIME_SLOT_REF1="ts3" TIME_SLOT_REF2="ts9"> <ANNOTATION_VALUE>Jag heter Jenny Ingvarsson och mitt persontecken ser ut så här.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a19" TIME_SLOT_REF1="ts11" TIME_SLOT_REF2="ts15"> <ANNOTATION_VALUE>Ja, dels har jag ju lockigt hår, och sen när jag var liten och skulle bokstavera mitt namn så överdrev jag alltid rörelsen i y:et på slutet. När mina förskollärare föreslog att mitt persontecken skulle se ut så här för att jag hade lockigt hår, så jag att nej, y:et ska vara med och därför blev det så.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a20" TIME_SLOT_REF1="ts19" TIME_SLOT_REF2="ts23"> <ANNOTATION_VALUE>Jag är född här i Stockholm.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a21" TIME_SLOT_REF1="ts27" TIME_SLOT_REF2="ts31"> <ANNOTATION_VALUE>Ja, uppvuxen här i Stockholm, bor fortfarande i Stockholm.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a22" TIME_SLOT_REF1="ts35" TIME_SLOT_REF2="ts39"> <ANNOTATION_VALUE>Ja, det kan man väl göra.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a23" TIME_SLOT_REF1="ts43" TIME_SLOT_REF2="ts47"> <ANNOTATION_VALUE>Ja, min pappa är hörselskadad, min mamma är döv och så har jag två bröder, en som är arton år och som är döv och en som är femton år och som är hörande.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a24" TIME_SLOT_REF1="ts51" TIME_SLOT_REF2="ts57"> <ANNOTATION_VALUE>Jadå, allihopa är fullt teckenspråkiga. Vi tecknar hela tiden. </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a25" TIME_SLOT_REF1="ts59" TIME_SLOT_REF2="ts63"> <ANNOTATION_VALUE>Ja, jag åkte fram och tillbaka varje dag. Vi bodde ganska nära stan först. Sedan när jag var tretton flyttade vi till en villa utanför Stockholm, men jag gick fortfarande i Manilla och åkte varje dag i tio år. Sen gick jag fyra år i Örebro på gymnasiet och sen flyttade jag tillbaka till Stockholm. </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a26" TIME_SLOT_REF1="ts67" TIME_SLOT_REF2="ts71"> <ANNOTATION_VALUE>Jag bor kvar hos mina föräldrar. </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a27" TIME_SLOT_REF1="ts75" TIME_SLOT_REF2="ts79"> <ANNOTATION_VALUE>Ja, just nu är jag på Manillaskolan som resurslärare. Skolan har ju precis slutat och till hösten ska jag börja utbilda mig till lärare. </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a28" TIME_SLOT_REF1="ts83" TIME_SLOT_REF2="ts85"> <ANNOTATION_VALUE>Ja, absolut. </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a29" TIME_SLOT_REF1="ts89" TIME_SLOT_REF2="ts91"> <ANNOTATION_VALUE>Jag har ju bott i Australien ett år också och jobbade som lärarassistent där i en dövskola i Melbourne. Jag jobbade med det ett år då. Sen kom jag hem och så har jag jobbat på Manilla ett år. Jo, jag känner att det är absolut rätt för mig. Jag vill bli lärare. Det ska bli jättespännande att börja utbildningen till hösten.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a30" TIME_SLOT_REF1="ts95" TIME_SLOT_REF2="ts99"> <ANNOTATION_VALUE>Ja absolut, den resan är den absolut bästa jag gjort någon gång. Ett helt år. Jag lärde mig massor, jag fick nya erfarenheter, jag fick nya vänner, jag fick lära mig att vara självständig, jag fick lära mig ta vara på mig själv. Jag har lärt mig massor. </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a31" TIME_SLOT_REF1="ts101" TIME_SLOT_REF2="ts105"> <ANNOTATION_VALUE>Jag tog ledigt, åkte till Nya Zeeland och var där ett tag, åkte tillbaka till Australien och reste runt där. Det var en fantastisk resa som jag aldrig glömmer.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a32" TIME_SLOT_REF1="ts107" TIME_SLOT_REF2="ts111"> <ANNOTATION_VALUE>Ja, en märklig grej som hände då var jag på nya Zeeland. Det var under jul och nyår. Och liksom, jul och jättevarmt och soligt och kort kjol och linne. På nyårsafton då var jag och ett gäng kompisar och kampade nere vid stranden och badade och så var det nyårsafton. Det var en jättekonstig känsla. </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a33" TIME_SLOT_REF1="ts113" TIME_SLOT_REF2="ts115"> <ANNOTATION_VALUE>Och det var ju inte semester. Jag bodde ju där ett helt år. Ja, nyår mitt i sommaren. Det kändes jättekonstig. Jag var ju van vid att det skulle vara snö och så. Så det minns jag jätteväl.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a34" TIME_SLOT_REF1="ts119" TIME_SLOT_REF2="ts123"> <ANNOTATION_VALUE>Ja verkligen. </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> </TIER> <TIER DEFAULT_LOCALE="sv" LINGUISTIC_TYPE_REF="Default" PARTICIPANT="" TIER_ID="Translation English B"> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a35" TIME_SLOT_REF1="ts2" TIME_SLOT_REF2="ts6"> <ANNOTATION_VALUE>So, what is your name?</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a36" TIME_SLOT_REF1="ts8" TIME_SLOT_REF2="ts14"> <ANNOTATION_VALUE>Oh, how come? Why that particular name sign? </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a37" TIME_SLOT_REF1="ts18" TIME_SLOT_REF2="ts22"> <ANNOTATION_VALUE>Oh, it looks nice. Where are you from? </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a38" TIME_SLOT_REF1="ts26" TIME_SLOT_REF2="ts30"> <ANNOTATION_VALUE>Did you grow up here?</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a39" TIME_SLOT_REF1="ts34" TIME_SLOT_REF2="ts38"> <ANNOTATION_VALUE>So you are a real Stockholmer then?</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a40" TIME_SLOT_REF1="ts42" TIME_SLOT_REF2="ts46"> <ANNOTATION_VALUE>Could you tell us a bit about your family and the time when you grew up?</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a41" TIME_SLOT_REF1="ts50" TIME_SLOT_REF2="ts54"> <ANNOTATION_VALUE>That means you were all signing at home? </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a42" TIME_SLOT_REF1="ts56" TIME_SLOT_REF2="ts62"> <ANNOTATION_VALUE>The whole family. A bit more about your background. You went to the Manilla school, right?</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a43" TIME_SLOT_REF1="ts66" TIME_SLOT_REF2="ts70"> <ANNOTATION_VALUE>Do you live alone or with your parents?</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a44" TIME_SLOT_REF1="ts74" TIME_SLOT_REF2="ts78"> <ANNOTATION_VALUE>So what do you work with now? </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a45" TIME_SLOT_REF1="ts82" TIME_SLOT_REF2="ts88"> <ANNOTATION_VALUE>Oh, that is good. So you want to be a teacher?</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a46" TIME_SLOT_REF1="ts94" TIME_SLOT_REF2="ts98"> <ANNOTATION_VALUE>That is good. May be you could tell us something about travels, maybe from that trip to Australia, right? </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a47" TIME_SLOT_REF1="ts104" TIME_SLOT_REF2="ts110"> <ANNOTATION_VALUE>Maybe there is something special, something short, that you would like to share with us? </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a48" TIME_SLOT_REF1="ts118" TIME_SLOT_REF2="ts122"> <ANNOTATION_VALUE>Well, it sounds like a nice experience. </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> </TIER> <TIER DEFAULT_LOCALE="sv" LINGUISTIC_TYPE_REF="Default" PARTICIPANT="" TIER_ID="Translation Swedish B"> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a49" TIME_SLOT_REF1="ts1" TIME_SLOT_REF2="ts5"> <ANNOTATION_VALUE>Ja, vad heter du då?</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a50" TIME_SLOT_REF1="ts7" TIME_SLOT_REF2="ts13"> <ANNOTATION_VALUE>Jaha, vad kommer det sig? Varför ser det ut så?</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a51" TIME_SLOT_REF1="ts17" TIME_SLOT_REF2="ts21"> <ANNOTATION_VALUE>Fint tecken! Var kommer du ifrån då?</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a52" TIME_SLOT_REF1="ts25" TIME_SLOT_REF2="ts29"> <ANNOTATION_VALUE>Uppvuxen här?</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a53" TIME_SLOT_REF1="ts33" TIME_SLOT_REF2="ts37"> <ANNOTATION_VALUE>En äkta stockholmare.</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a54" TIME_SLOT_REF1="ts41" TIME_SLOT_REF2="ts45"> <ANNOTATION_VALUE>Kan du berätta lite om din familj och din uppväxt?</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a55" TIME_SLOT_REF1="ts49" TIME_SLOT_REF2="ts53"> <ANNOTATION_VALUE>Ja, då använde ni teckenspråk hemma då?</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a56" TIME_SLOT_REF1="ts55" TIME_SLOT_REF2="ts61"> <ANNOTATION_VALUE>Hela familjen. Någonting annat om din hemmiljö, din bakgrund, din uppväxt? Du gick Manillaskolan eller?</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a57" TIME_SLOT_REF1="ts65" TIME_SLOT_REF2="ts69"> <ANNOTATION_VALUE>Bor du ensam eller bor du kvar hos dina föräldrar? </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a58" TIME_SLOT_REF1="ts73" TIME_SLOT_REF2="ts77"> <ANNOTATION_VALUE>Och vad jobbar du med nu?</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a59" TIME_SLOT_REF1="ts81" TIME_SLOT_REF2="ts87"> <ANNOTATION_VALUE>Jaha, vad kul. Är du intresserad av att bli lärare?</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a60" TIME_SLOT_REF1="ts93" TIME_SLOT_REF2="ts97"> <ANNOTATION_VALUE>Ja, kanske du kan berätta något reseminne. Det kanske blir från Australien då eller? </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a61" TIME_SLOT_REF1="ts103" TIME_SLOT_REF2="ts109"> <ANNOTATION_VALUE>Har du liten kort grej som du kan berätta, något litet minne?</ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> <ANNOTATION> <ALIGNABLE_ANNOTATION ANNOTATION_ID="a62" TIME_SLOT_REF1="ts117" TIME_SLOT_REF2="ts121"> <ANNOTATION_VALUE>Ja, en härlig upplevelse. </ANNOTATION_VALUE> </ALIGNABLE_ANNOTATION> </ANNOTATION> </TIER> <LINGUISTIC_TYPE GRAPHIC_REFERENCES="false" LINGUISTIC_TYPE_ID="Default" TIME_ALIGNABLE="true"/> <LOCALE COUNTRY_CODE="SE" LANGUAGE_CODE="sv"/> <CONSTRAINT DESCRIPTION="Time subdivision of parent annotation&apos;s time interval, no time gaps allowed within this interval" STEREOTYPE="Time_Subdivision"/> <CONSTRAINT DESCRIPTION="Symbolic subdivision of a parent annotation. Annotations refering to the same parent are ordered" STEREOTYPE="Symbolic_Subdivision"/> <CONSTRAINT DESCRIPTION="1-1 association with a parent annotation" STEREOTYPE="Symbolic_Association"/> </ANNOTATION_DOCUMENT>
30,000
Common Lisp
.l
454
54.726872
432
0.646606
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
caa27fd526b4bc466f0a2d931433ff67965f8d7889fdf0e7e79b85532d33959a
37,612
[ -1 ]
37,613
recoverable-missing-index.tide
open-rsx_rsbag-tools-cl/test/data/0.9/recoverable-missing-index.tide
TIDE CHAN«/:UINT32rsb-event-0.8:uint32$F916CE11-EDF3-41A1-B79E-02A35313AAA4*rsb:/#F916CE11-EDF3-41A1-B79E-02A35313AAA4H// Notification.proto package rsb.protocol; import "rsb/protocol/EventId.proto"; import "rsb/protocol/EventMetaData.proto"; option java_outer_classname = "NotificationType"; message Notification { required EventId event_id = 108; optional bytes scope = 6; optional bytes method = 14; optional bytes wire_schema = 7; optional bytes data = 9; repeated EventId causes = 13; optional EventMetaData meta_data = 15; } // EventId.proto package rsb.protocol; option java_outer_classname = "EventIdType"; message EventId { required bytes sender_id = 1; required uint32 sequence_number = 2; } // EventMetaData.proto package rsb.protocol; option java_outer_classname = "EventMetaDataType"; message UserTime { required bytes key = 1; required uint64 timestamp = 2; } message UserInfo { required bytes key = 1; required bytes value = 2; } message EventMetaData { required int64 create_time = 2; required int64 send_time = 3; optional int64 receive_time = 4; optional int64 deliver_time = 5; repeated UserTime user_times = 6; repeated UserInfo user_infos = 7; } CHNKs∞bc\0ии{мЅ0и∞bc\0иFв   ґнpH.ДҐfFђ|фх2/Jz$ОзСзивµхЖХзивµ і†Эзивµ(’’ЭзивµРo≈Щ0иFв OZт≥B ©¬сќROа¬2/Jz$Џ‘–зивµЕС”зивµ еЏ’зивµ(Аџ’зивµ–лМ‘0иFв XЁЛmO§Ј…Р?џc2/Jz$ВнМиивµБ©Пиивµ озСиивµ(тзСиивµ°Й0иFв ”≠1 КLMУc*)хҐ2/Jz$ †…иивµЦдЋиивµ Ѕфѕиивµ(∆фѕиивµРфPL0иFв ;Ч3ЭGЗ%9kЯ≥)Ѕ2/Jz$ъЊЗйивµтэЙйивµ ФњМйивµ(ШњМйивµpОмЖ0иFв -“”QЁ‘GмЉпЅ \L-г2/Jz$жј√йивµсы≈йивµ ю≤»йивµ(В≥»йивµи{мЅ0иFв фоГ[й@Kmґ\єуC eК2/Jz$Бц€йивµ…ЈВкивµ ќпДкивµ(“пДкивµCHNK«p≈ж€0ирш0иp≈ж€0иFв 8√э µGCИшрЩ*l)њ2/Jz$∆±њкивµТщЅкивµ а√ƒкивµ(е√ƒкивµйO?0иFв «щ”PF8ВЧіIЫW–Ў2/J z$х®АливµЙМГливµ ыаЕливµ(€аЕливµРuІ}0иFв цf¬ДiEР≤\RDСёШ2/J z$ЪФјливµЬЁ¬ливµ І§≈ливµ(Ђ§≈ливµ8ТЇ0иFв щюLиMOM€Ащsёжч÷2/J z$”ƒюливµЉИБмивµ МќГмивµ(РќГмивµрш0иFв О~Љ0УBфЈЄ"[„wЂK2/J z$цЇљмивµЃРјмивµ Бё¬мивµ(Иё¬мивµCHNK«P÷Г40и∞дй10иP÷Г40иFв #Й©—sGО≤ЪCmЧъ”2/J z$ТіымивµЛ€эмивµ …єАнивµ(ЌєАнивµрdcq0иFв X€WюsALЃy>&:©m2/Jz$цёєнивµпЯЉнивµ д”Њнивµ(м”ЊнивµH]ЏЃ0иFв Уц7ЛшЙDґqdРЊ™¶ш2/Jz$Э„шнивµЯѓынивµ ÷ьэнивµ(Џьэнивµ(∆Pф0иFв ≠—gIЬs@fЊy¬т≠Є]2/Jz$йзњоивµђ√¬оивµ р†≈оивµ(ч†≈оивµ∞дй10иFв <и_;Lµ≥Шу6mи%2/Jz$ќсюоиⵕЃБпивµ йнГпивµ(мнГпивµCHNK«Ш\t0и»x&0иШ\t0иFв J]∞н&РJйАд–7Є)÷2/Jz$ѕ“¬пивµМ±≈пивµ »К»пивµ(ЋК»пивµрЫkЄ0иFв ,ЛтCIMТ_ЯO°Mb2/Jz$÷ѕИривµібЛривµ ыАПривµ(€АПриⵆэ(э0иFв N>нEyбAйЗNQ»}ёґ2/Jz$ƒБѕриⵑг—ривµ ы—‘ривµ(€—‘ривµX“?0иFв э/ №п!J ∞ТЁ>?BЅ2/Jz$€ҐУсивµныХсивµ ф√Шсивµ(ш√Шсивµ»x&0иFв С$[JC≥Щ:e‘ж_{ 2/Jz$ЌП‘сивµН≥„сивµ –∆Џсивµ(џ∆ЏсивµCHNK«p{MЋ0и8еѕ0иp{MЋ0иFв #eй2h>LМЙа{Щлм2/Jz$ЖНҐтивµ’Ъ•тивµ ƒЉ®тивµ(«Љ®тивµИ“a0иFв „5НцFАОEпB]Юй»2/Jz$еънтивµЙ√стивµ фИхтивµ(шИхтивµ∞ђaY0иFв “†Ґ†¶JІН.№Ы-®ј2/Jz$ќЋ≥уивµЃДґуивµ ’ЄЄуивµ(ўЄЄуивµАоФ0иFв 9ig7DщBjПЗЃР≈Y\2/Jz$Р№пуивµШҐтуивµ Г÷фуивµ(З÷фуивµ8еѕ0иFв *iГЃzDrїЬКЈХV2/Jz$≥щђфивµќ≥ѓфивµ Яи±фивµ(Ґи±фивµCHNK«Ргм 0и(ЊC0иРгм 0иFв =Ш1Е Й@ЖЖєM)GEЅ2/Jz$Џµкфивµ£смфивµ §°пфивµ(®°пфивµЄЌћF0иFв &%ЅЪGсЖ1лто-2/Jz$√Џ¶хивµ∆Я©хивµ Ў÷Ђхивµ(№÷Ђхивµ∞вµВ0иFв ЉI’'њ1DрІЈ8÷Џбі:2/Jz$ОЗдхивµи жхивµ ±€ихивµ(і€ихивµ0pOћ0иFв §J—:Q≠JљЭcN§»≤2/Jz$юµѓцивµ
4,118
Common Lisp
.l
76
52.565789
177
0.57581
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
18025d7a25d5681011cc18a094872cdbfa241a498bbe2a6a147ea06971e49a40
37,613
[ -1 ]
37,640
export-proprioception-as-csv.template
open-rsx_rsbag-tools-cl/scripts/export-proprioception-as-csv.template
${(floor create-unix-nsec 1000)}${(let ((joints (rst.kinematics:proprioception-state-joints data))) (with-output-to-string (stream) (iter (for joint each joints) (format stream ",~A,~F" (sb-ext:octets-to-string (rst.kinematics:joint-state-name joint)) (rst.kinematics:joint-state-value joint)))))}
388
Common Lisp
.l
7
41.571429
99
0.572178
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
0c326296990cf60be4e0118b9abf7ec6d558a70acb745f20bf60dac49155d92b
37,640
[ -1 ]
37,665
package.lisp
open-rsx_rsbag-cl/test/package.lisp
;;;; package.lisp --- Package definition for unit tests of the rsbag system. ;;;; ;;;; Copyright (C) 2011-2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.test (:use #:cl #:alexandria #:let-plus #:iterate #:lift #:rsbag) (:export #:root) ;; Test utilities (:export #:mock-backend #:with-mock-backend #:with-mock-bag #:simple-bag) (:documentation "This package contains unit tests for the rsbag system")) (cl:in-package #:rsbag.test) (deftestsuite root () () (:documentation "Root unit test suite for the rsbag system."))
642
Common Lisp
.lisp
28
19.714286
76
0.671074
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e8404c29309a3d6e65be3a3a6e96ca8822649bf7e43c95ebb5936ec5f362b708
37,665
[ -1 ]
37,666
protocol.lisp
open-rsx_rsbag-cl/test/protocol.lisp
;;;; protocol.lisp --- Unit tests for the client-facing protocol. ;;;; ;;;; Copyright (C) 2011-2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.test) (deftestsuite protocol-root (root) () (:function (pathname/existing () (asdf:system-relative-pathname (asdf:find-system :rsbag/test) "test/data/minimal.mock"))) (:function (namestring/existing () (pathname/existing))) (:function (stream () (open (pathname/existing) :element-type '(unsigned-byte 8) :direction :input))) (:documentation "Unit test for the client-facing protocol.")) (addtest (protocol-root :documentation "Test case for the `open-bag' function.") open-bag/valid (ensure-cases (args) `((,(namestring/existing) :direction :input) (,(pathname/existing) :direction :input) (,(namestring/existing) :direction :input :backend :mock) (,(pathname/existing) :direction :input :backend :mock) (,(stream) :direction :input :backend :mock)) (close (apply #'open-bag args)))) (addtest (protocol-root :documentation "Test cases for which the `open-bag' function has to signal errors.") open-bag/invalid (ensure-cases (args) `(;; :backend, :direction missing (,(stream)) ;; :backend missing (,(stream) :direction :input) ;; :direction missing (,(stream) :backend :mock) ;; invalid direction (,(namestring/existing) :direction :invalid :backend :mock) (,(pathname/existing) :direction :invalid :backend :mock) (,(stream) :direction :invalid :backend :mock) ;; invalid backend (,#P"name-but-no-type" :direction :input) (,(namestring/existing) :direction :input :backend :no-such-backend) (,(pathname/existing) :direction :input :backend :no-such-backend) (,(stream) :direction :input :backend :no-such-backend) ;; file exists (,(namestring/existing) :direction :output :backend :mock) (,(pathname/existing) :direction :output :backend :mock) ;; cannot specify flush strategy for input direction (,(namestring/existing) :direction :input :flush-strategy :some-strategy) (,(pathname/existing) :direction :input :flush-strategy :some-strategy) (,(stream) :direction :input :backend :mock :flush-strategy :some-strategy) ;; invalid flush strategy (,(namestring/existing) :direction :io :flush-strategy :no-such-strategy) (,(pathname/existing) :direction :io :flush-strategy :no-such-strategy) (,(stream) :direction :io :backend :mock :flush-strategy :no-such-strategy)) (ensure-condition 'error (apply #'open-bag args))))
2,930
Common Lisp
.lisp
68
36.279412
97
0.618914
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5ba7f49392c00e5cbb63bb5c6e6827013f1cf9d4cf10f6e5d273b4d986a6b449
37,666
[ -1 ]
37,667
builder.lisp
open-rsx_rsbag-cl/test/builder.lisp
;;;; builder.lisp --- Unit tests for builder support. ;;;; ;;;; Copyright (C) 2015, 2016, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.builder.test (:use #:cl #:alexandria #:let-plus #:lift #:rsbag #:rsbag.test) (:import-from #:architecture.builder-protocol.test #:record-un-build-calls/peeking) (:export #:rsbag-builder-root) (:documentation "This package contains test for the builder module.")) (cl:in-package #:rsbag.builder.test) (deftestsuite rsbag-builder-root () () (:documentation "Unit tests for builder support.")) (defun replace-timestamps (tree replacements) (reduce (lambda+ (tree (new . old)) (subst-if new (conjoin (of-type 'local-time:timestamp) (curry #'local-time:timestamp= old)) tree)) replacements :initial-value tree)) (defun check-un-build-calls (builder atom-type timestamp-replacements cases) (mapc (lambda+ ((object expected-calls)) (let+ (((&values &ign calls) (architecture.builder-protocol:with-unbuilder (builder builder) (record-un-build-calls/peeking #'architecture.builder-protocol:walk-nodes builder atom-type object)))) (ensure-same (replace-timestamps calls timestamp-replacements) expected-calls :test #'equal))) cases)) (addtest (rsbag-builder-root :documentation "Smoke test for the `transport-options'.") bag/smoke (let* ((start (local-time:now)) (start/uint64 (rsbag.backend:timestamp->uint64 start)) (end (local-time:adjust-timestamp start (:offset :sec 1))) (end/uint64 (rsbag.backend:timestamp->uint64 end)) (content `(((,start/uint64 ,end/uint64) ("a" "b") 0 "foo" ())))) (with-mock-bag (bag-1 :direction :input) '() (with-mock-bag (bag-2 :direction :input) content (let ((channel (first (bag-channels bag-2)))) (check-un-build-calls t 'string `((,start/uint64 . ,start) (,end/uint64 . ,end)) `((,bag-1 ((:peek nil () ,bag-1) (:visit nil () ,bag-1 rsbag:bag ((:channel . (:map . :name))) (:location nil :event-count 0)))) (,bag-2 ((:peek nil () ,bag-2) (:visit nil () ,bag-2 rsbag:bag ((:channel . (:map . :name))) (:location nil :event-count 2 :start ,start/uint64 :end ,end/uint64 :duration 1 :rate 2)) (:peek :channel (:name "foo") ,channel) (:visit :channel (:name "foo") ,channel rsbag:channel () (:name "foo" :event-count 2 :start ,start/uint64 :end ,end/uint64 :duration 1 :rate 2)))))) (check-un-build-calls (make-instance 'rsbag.builder:unbuilder :compute-sizes? t) 'string `((,start/uint64 . ,start) (,end/uint64 . ,end)) `((,bag-1 ((:peek nil () ,bag-1) (:visit nil () ,bag-1 rsbag:bag ((:channel . (:map . :name))) (:location nil :data-size 0 :event-count 0)))) (,bag-2 ((:peek nil () ,bag-2) (:visit nil () ,bag-2 rsbag:bag ((:channel . (:map . :name))) (:location nil :data-size 2 :event-count 2 :start ,start/uint64 :end ,end/uint64 :duration 1 :rate 2)) (:peek :channel (:name "foo") ,channel) (:visit :channel (:name "foo") ,channel rsbag:channel () (:name "foo" :data-size 2 :event-count 2 :start ,start/uint64 :end ,end/uint64 :duration 1 :rate 2))))))))))) (addtest (rsbag-builder-root :documentation "Smoke test for the `transport-options'.") channel/smoke (let* ((start (local-time:now)) (start/uint64 (rsbag.backend:timestamp->uint64 start)) (end (local-time:adjust-timestamp start (:offset :sec 1))) (end/uint64 (rsbag.backend:timestamp->uint64 end)) (type '(:rsb-event-0.9 :foo)) (format "format") (content `(((,start/uint64 ,end/uint64) ("a" "b") 0 "foo" (:type ,type :format ,format))))) (with-mock-bag (bag :direction :input :transform '(nil)) content (let ((channel (first (bag-channels bag)))) (check-un-build-calls t '(or string cons) `((,start/uint64 . ,start) (,end/uint64 . ,end)) `((,channel ((:peek nil () ,channel) (:visit nil () ,channel rsbag:channel ((:type . 1)) (:name "foo" :event-count 2 :start ,start/uint64 :end ,end/uint64 :duration 1 :rate 2)) (:peek :type () ,type))))) (check-un-build-calls (make-instance 'rsbag.builder::unbuilder :format? t) '(or string cons) `((,start/uint64 . ,start) (,end/uint64 . ,end)) `((,channel ((:peek nil () ,channel) (:visit nil () ,channel rsbag:channel ((:type . 1) (:format . 1)) (:name "foo" :event-count 2 :start ,start/uint64 :end ,end/uint64 :duration 1 :rate 2)) (:peek :type () ,type) (:peek :format () ,format))))) (check-un-build-calls (make-instance 'rsbag.builder::unbuilder :compute-sizes? t) '(or string cons) `((,start/uint64 . ,start) (,end/uint64 . ,end)) `((,channel ((:peek nil () ,channel) (:visit nil () ,channel rsbag:channel ((:type . 1)) (:name "foo" :data-size 2 :event-count 2 :start ,start/uint64 :end ,end/uint64 :duration 1 :rate 2)) (:peek :type () ,type)))))))))
7,932
Common Lisp
.lisp
163
28.993865
83
0.3984
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
cf441593011e577b82278523026e66af6a8c9367e9b48530ed87b75f7bfb35d9
37,667
[ -1 ]
37,668
mock-backend.lisp
open-rsx_rsbag-cl/test/mock-backend.lisp
;;;; mock-backend.lisp --- Mock backend class for unit tests. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.test) (defclass mock-backend () ((channels :initarg :channels :type list :accessor backend-%channels :initform '() :documentation "List of mock-channel data of the form (TIMESTAMPS ENTRIES ID NAME META-DATA) where TIMESTAMPS is a list of `local-time:timestamp' objects, ENTRIES is a list of raw entries, ID is the integer id of the channel, NAME is a string naming the channel, and META-DATA is a plist containing the meta-data for the channel."))) (service-provider:register-provider/class 'rsbag.backend::backend :mock :class 'mock-backend) (defmethod shared-initialize :after ((instance mock-backend) (slot-names t) &key &allow-other-keys)) (defmethod close ((stream mock-backend) &key abort) (declare (ignore abort))) (defmethod rsbag.backend:backend-location ((backend mock-backend)) nil) (defmethod rsbag.backend:get-channels ((backend mock-backend)) (mapcar (curry #'nthcdr 2) (backend-%channels backend))) (defmethod rsbag.backend:make-channel-id ((backend mock-backend) (channel t)) (length (backend-%channels backend))) (defmethod rsbag.backend:put-channel ((backend mock-backend) (channel integer) (name string) (meta-data list)) (appendf (backend-%channels backend) (list (list nil nil channel name meta-data)))) (defmethod rsbag.backend:get-num-entries ((backend mock-backend) (channel integer)) (length (rsbag.backend:get-timestamps backend channel))) (defmethod rsbag.backend:get-timestamps ((backend mock-backend) (channel integer)) (first (nth channel (backend-%channels backend)))) (defmethod rsbag.backend:get-entry-at-index ((backend mock-backend) (channel integer) (index integer)) (let* ((channel (nth channel (backend-%channels backend))) (entry (nth index (second channel)))) (case entry (error (error "~@<Simulated entry retrieval error~@:>")) (t entry)))) (defmethod rsbag.backend:put-entry ((backend mock-backend) (channel integer) (timestamp integer) (entry t)) (let ((channel (nth channel (backend-%channels backend)))) (appendf (first channel) (list timestamp)) (appendf (second channel) (list entry)))) ;;; Convenience macros (defmacro with-mock-backend ((backend-var) content &body body) "Execute BODY with BACKEND-VAR bound to a `mock-backend' instance filled with CONTENT." `(let ((,backend-var (make-instance 'mock-backend :channels ,content))) ,@body)) (defmacro with-mock-bag ((bag-var &rest initargs) content &body body) "Execute BODY with BAG-VAR bound to a `bag' instance backed by a `mock-backend' instance filled with CONTENT. INITARGS are passed to the constructed `bag' instance." (with-gensyms (backend-var) `(with-mock-backend (,backend-var) ,content (let ((,bag-var (make-instance 'bag :backend ,backend-var ,@initargs))) ,@body)))) (defun simple-channels (&key (errors '())) (let+ (((&flet maybe-error (value) (if (member value errors) 'error value))) (now (local-time:now)) ((&flet now+ (amount) (rsbag.backend:timestamp->uint64 (local-time:adjust-timestamp now (:offset :nsec amount)))))) `(((,(now+ 0) ,(now+ 50000000)) ,(mapcar #'maybe-error '(1 2)) 0 "/foo" ()) ((,(now+ 50001000) ,(now+ 50002000) ,(now+ 100001000)) ,(mapcar #'maybe-error '(3 4 5)) 1 "/bar" ())))) (defun simple-bag (&key (errors '())) (with-mock-bag (bag :direction :input) (simple-channels :errors errors) bag))
4,526
Common Lisp
.lisp
98
34.367347
73
0.566886
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
b8a95b43e8f0823b85e521aa553e3bdbbbd7c233c3f5146bd889e15c94119639
37,668
[ -1 ]
37,669
bag.lisp
open-rsx_rsbag-cl/test/bag.lisp
;;;; bag.lisp --- Unit tests for the bag class. ;;;; ;;;; Copyright (C) 2011-2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.test) (deftestsuite bag-root (root) () (:documentation "Unit test suite for the `bag' class.")) (addtest (bag-root :documentation "Smoke test for the `bag' class.") smoke (with-mock-bag (bag :direction :input) (simple-channels) (ensure-same (bag-direction bag) :input) (ensure-same (mapcar #'channel-name (bag-channels bag)) '("/bar" "/foo") :test #'equal) ;; Check content of first channel. (let ((channel (first (bag-channels bag)))) (ensure-same (length (channel-timestamps channel)) 3) (ensure-same (coerce channel 'list) '(3 4 5) :test #'equalp)) ;; Check content of second channel. (let ((channel (second (bag-channels bag)))) (ensure-same (length (channel-timestamps channel)) 2) (ensure-same (coerce channel 'list) '(1 2) :test #'equalp)))) (addtest (bag-root :documentation "Smoke test for the `bag-channel' method on `bag' class.") bag-channel ;; Error signaling and replacement return value. (with-mock-bag (bag :direction :input) () (ensure-condition no-such-channel (bag-channel bag "no-such-channel")) (ensure-same (bag-channel bag "no-such-channel" :if-does-not-exist nil) nil)) ;; Creating the channel. (with-mock-bag (bag :direction :output) () (let ((channel (bag-channel bag "created" :if-does-not-exist (lambda (condition) (declare (ignore condition)) (invoke-restart 'create '()))))) (ensure-same channel (bag-channel bag "created") :test #'eq)))) (addtest (bag-root :documentation "Test printing a `bag' instance.") print (ensure-cases (direction channels expected) `((:input () "BAG N/A r- (0)") (:output () "BAG N/A -w (0)") (:io () "BAG N/A rw (0)") (:input ,(simple-channels) "BAG N/A r- (2)")) (with-mock-bag (bag :direction direction) channels (ensure-same expected (princ-to-string bag) :test #'search)))) (addtest (bag-root :documentation "Test errors signaled by attempts to modify read-only `bag' instances.") read-only (with-mock-bag (bag :direction :input) '() (ensure-condition direction-error (setf (bag-channel bag "foo") '())))) (addtest (bag-root :documentation "Smoke test for `start-timestamp' and `end-timestamp' methods on `bag' class.") start+end-timestamp (with-mock-bag (bag :direction :input) (simple-channels) (start-timestamp bag) (end-timestamp bag)))
2,893
Common Lisp
.lisp
70
33.871429
81
0.595153
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
490dddbb6dde93a4a1448eaef78c09d460115148d1d7152b58074c0204d3f0d0
37,669
[ -1 ]
37,670
channel.lisp
open-rsx_rsbag-cl/test/channel.lisp
;;;; channel.lisp --- Unit tests for the channel class. ;;;; ;;;; Copyright (C) 2014-2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.test) (deftestsuite channel-root (root) () (:documentation "Unit test suite for the `channel' class.")) (addtest (channel-root :documentation "Test printing a `channel' instance.") print (with-mock-bag (bag :direction :input) (simple-channels) (let+ (((first second) (bag-channels bag))) (ensure-same "CHANNEL \"/bar\" (3)" (princ-to-string first) :test #'search) (ensure-same "CHANNEL \"/foo\" (2)" (princ-to-string second) :test #'search)))) (addtest (channel-root :documentation "Test errors signaled by attempts to modify `channel' instances in read-only `bag's.") read-only (with-mock-bag (bag :direction :input) (simple-channels) (ensure-condition direction-error (setf (entry (first (bag-channels bag)) (local-time:now)) :does-not-matter)))) (addtest (channel-root :documentation "Smoke test for `start-timestamp' and `end-timestamp' methods on `channel' class.") start+end-timestamp (with-mock-bag (bag :direction :input) (simple-channels) (let ((channel (first (bag-channels bag)))) (start-timestamp channel) (end-timestamp channel))))
1,437
Common Lisp
.lisp
38
31.578947
66
0.637671
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5dce445ec88442453cbc2a1f843a65467f754f320c9a7a5f5e2779023c4c35c2
37,670
[ -1 ]
37,671
package.lisp
open-rsx_rsbag-cl/test/view/package.lisp
;;;; package.lisp --- Package definition for unit tests of the view module. ;;;; ;;;; Copyright (C) 2011, 2012, 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.view.test (:use #:cl #:alexandria #:iterate #:let-plus #:lift #:rsbag #:rsbag.view #:rsbag.test) (:export #:view-root) (:documentation "This package contains unit tests for the view module.")) (cl:in-package #:rsbag.view.test) (deftestsuite view-root (root) () (:documentation "Root unit test suite for the view module."))
593
Common Lisp
.lisp
24
21.625
75
0.676157
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
9d92d29789ab7c40b2a3b2b3e0106bee3edbfcb9ca86360548125ef69348f4f1
37,671
[ -1 ]
37,672
serialized.lisp
open-rsx_rsbag-cl/test/view/serialized.lisp
;;;; serialized.lisp --- Unit tests for the serialized view class. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.view.test) (deftestsuite serialized-root (view-root) ((one-sequence '(((0 :a) (1 :b) (2 :c)))) (two-sequences '(((0 :a) (2 :c)) ( (1 :b) (3 :d))))) (:documentation "Test suite for the `serialized' view class.")) (addtest (serialized-root :documentation "Smoke test for the `serialized' view class.") smoke (ensure-cases (sequences start end expected-length expected-items) `((nil 0 0 0 nil) (,one-sequence 0 0 3 ((0 :a) (1 :b) (2 :c))) (,one-sequence 1 0 3 ( (1 :b) (2 :c))) (,two-sequences 0 0 4 ((0 :a) (1 :b) (2 :c) (3 :d)))) (let ((sequence (make-instance 'serialized :sequences sequences :compare #'< :key (lambda (sequence iterator) (first (sequence:iterator-element sequence iterator)))))) (ensure-same (length sequence) expected-length) (iter (for (timestamp value) each sequence :from start) (for (e-timestamp e-value) each expected-items) (for i :from start) (for (timestamp* value*) next (elt sequence i)) (ensure-same timestamp e-timestamp :test #'=) (ensure-same timestamp* e-timestamp :test #'=) (ensure-same value e-value :test #'eq) (ensure-same value* e-value :test #'eq))))) (addtest (serialized-root :documentation "Test constructing `serialized' view instances using `make-serialized-view'.") construction (ensure-cases (sequences expected-length) `((nil 0) (,one-sequence 3) (,two-sequences 4)) (let ((sequence (make-serialized-view sequences))) (ensure-same (length sequence) expected-length)))) (addtest (serialized-root :documentation "Test forward and backward iteration on a serialized view on multiple random sequences.") iterator (let+ (((&flet make-random-sequence () (let ((raw (map-into (make-list (random 100)) (curry #'random 100)))) (sort (remove-duplicates raw) #'<)))) ((&flet make-random-sequences () (let ((count (random 10))) (map-into (make-list count) #'make-random-sequence))))) (ensure-cases (sequences) (map-into (make-list 100) #'make-random-sequences) (let+ ((flat (sort (copy-list (reduce #'append sequences)) #'<)) (view (make-serialized-view sequences :compare #'<)) ((&values iterator &ign from-end) (sequence:make-simple-sequence-iterator view)) ((&flet traverse (backward?) (iter (repeat (length view)) (unless (first-iteration-p) (setf iterator (sequence:iterator-step view iterator (xor backward? from-end)))) (collect (sequence:iterator-element view iterator))))) (forward (traverse nil)) (backward (traverse t))) (ensure-same forward flat :test #'equal :report "Forward iteration failed") (ensure-same (reverse backward) flat :test #'equal :report "Backward iteration failed")))))
3,698
Common Lisp
.lisp
79
35.189873
81
0.533685
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
25c0026d3dd2cc69daf2944072c835085ad0ef3e74f97a3d0d134305d164bc03
37,672
[ -1 ]
37,673
package.lisp
open-rsx_rsbag-cl/test/backend/package.lisp
;;;; package.lisp --- Package definition for unit tests of the backend module. ;;;; ;;;; Copyright (C) 2012, 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.backend.test (:use #:cl #:alexandria #:let-plus #:lift #:rsbag.backend #:rsbag.test) ;; Root test suite (:export #:backend-root) ;; Test utilities (:export #:octetify #:octet-streamify) (:documentation "This package contains unit tests for the backend module")) (cl:in-package #:rsbag.backend.test) (deftestsuite backend-root (root) () (:documentation "Root unit test suite for the backend module.")) ;;; Test utilities (defun octetify (&rest things) (labels ((one (thing) (etypecase thing (nibbles:octet (nibbles:octet-vector thing)) ((cons (eql :ub16le) (cons unsigned-byte null)) (let ((buffer (nibbles:make-octet-vector 2))) (setf (nibbles:ub16ref/le buffer 0) (second thing)) buffer)) ((cons (eql :ub32le) (cons unsigned-byte null)) (let ((buffer (nibbles:make-octet-vector 4))) (setf (nibbles:ub32ref/le buffer 0) (second thing)) buffer)) ((cons (eql :ub64le) (cons unsigned-byte null)) (let ((buffer (nibbles:make-octet-vector 8))) (setf (nibbles:ub64ref/le buffer 0) (second thing)) buffer)) (keyword (one (string thing))) (string (map 'nibbles:octet-vector #'char-code thing)) (sequence (coerce thing 'nibbles:octet-vector))))) (apply #'concatenate 'nibbles:octet-vector (mapcar #'one things)))) (defun octet-streamify (&rest things) (flexi-streams:make-in-memory-input-stream (apply #'octetify things)))
1,940
Common Lisp
.lisp
55
26.836364
78
0.585912
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
d2fc5a66a7c35c864b41054e0a9bbd5612019923974756b17f56209db809142b
37,673
[ -1 ]
37,674
flush-strategies.lisp
open-rsx_rsbag-cl/test/backend/flush-strategies.lisp
;;;; flush-strategies.lisp --- Unit tests for flush strategies. ;;;; ;;;; Copyright (C) 2012, 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.test) (defclass mock-buffer () ((length/entries :initarg :length/entries :accessor length/entries) (length/bytes :initarg :length/bytes :accessor length/bytes))) (defmethod buffer-property ((backend t) (buffer mock-buffer) (name (eql :length/entries))) (length/entries buffer)) (defmethod buffer-property ((backend t) (buffer mock-buffer) (name (eql :length/bytes))) (length/bytes buffer)) (defmethod buffer-property ((backend t) (buffer mock-buffer) (name (eql :time-to-last-write))) 5) (deftestsuite flush-strategies-root (backend-root) () (:function (make-strategy (spec args) (apply #'make-flush-strategy spec args))) (:documentation "Root test suite for tests of flush strategies.")) (defmacro define-basic-flush-strategy-suite ((spec) &body cases) (let ((suite-name (format-symbol *package* "~A-ROOT" spec))) `(progn (deftestsuite ,suite-name (flush-strategies-root) () (:documentation ,(format nil "Test suite for ~(~A~) flush strategy." spec))) (addtest (,suite-name :documentation ,(format nil "Test constructing ~(~A~) instances." spec)) construct (ensure-cases (strategy-args buffer-args expected) (list ,@cases) (if (eq expected :error) (ensure-condition 'error (make-strategy ,spec strategy-args)) (ensure-null (emptyp (princ-to-string (make-strategy ,spec strategy-args))))))) (addtest (,suite-name :documentation ,(format nil "Test constructing ~(~A~) instances." spec)) smoke (ensure-cases (strategy-args buffer-args expected) (remove :error (list ,@cases) :key #'third) (let ((strategy (make-strategy ,spec strategy-args)) (buffer (apply #'make-instance 'mock-buffer buffer-args))) (ensure-same (flush? strategy t buffer) expected))))))) (define-basic-flush-strategy-suite (:property-limit) ;; Missing required initargs. '(() () :error) ;; Missing :property initarg. '((:property :foo) () :error) ;; Missing :limit initarg. '((:limit 10) () :error) ;; Specified property does not exist. '((:property :foo :limit 10) () :error) ;; These are OK. '((:property :length/entries :limit 10) (:length/entries 10 :length/bytes 999999) nil) '((:property :length/entries :limit 10) (:length/entries 11 :length/bytes 1000001) t) '((:property :length/bytes :limit 1000000) (:length/entries 10 :length/bytes 999999) nil) '((:property :length/bytes :limit 1000000) (:length/entries 11 :length/bytes 1000001) t)) (define-basic-flush-strategy-suite (:or) ;; No such subordinate strategy. '(((:no-such-strategy)) () :error) ;; Invalid initargs for subordinate strategy. '(((:property-limit :property :foo :limit 10)) () :error) ;; These are OK '(() () nil) '(((:property-limit :property :length/entries :limit 10)) (:length/entries 9 :length/bytes 1000) nil) '(((:property-limit :property :length/entries :limit 10) (:property-limit :property :time-to-last-write :limit 2)) (:length/entries 10 :length/bytes 1000) t) '(((:property-limit :property :length/entries :limit 10) (:property-limit :property :time-to-last-write :limit 2)) (:length/entries 11 :length/bytes 1000) t)) (define-basic-flush-strategy-suite (:and) ;; No such subordinate strategy. '(((:no-such-strategy)) () :error) ;; Invalid initargs for subordinate strategy. '(((:property-limit :property :foo :limit 10)) () :error) ;; These are OK '(() () t) '(((:property-limit :property :length/entries :limit 10)) (:length/entries 9 :length/bytes 1000) nil) '(((:property-limit :property :length/entries :limit 10) (:property-limit :property :time-to-last-write :limit 2)) (:length/entries 10 :length/bytes 1000) nil) '(((:property-limit :property :length/entries :limit 10) (:property-limit :property :time-to-last-write :limit 2)) (:length/entries 11 :length/bytes 1000) t)) (define-basic-flush-strategy-suite (:not) ;; No such subordinate strategy. '(((:no-such-strategy)) () :error) ;; Invalid initargs for subordinate strategy. '(((:property-limit :property :foo :limit 10)) () :error) ;; These are OK '(() () t) '(((:property-limit :property :length/entries :limit 10)) (:length/entries 9 :length/bytes 1000) t) '(((:property-limit :property :length/entries :limit 10) (:property-limit :property :time-to-last-write :limit 2)) (:length/entries 10 :length/bytes 1000) nil) '(((:property-limit :property :length/entries :limit 10) (:property-limit :property :time-to-last-write :limit 2)) (:length/entries 11 :length/bytes 1000) nil))
5,816
Common Lisp
.lisp
128
37.914063
77
0.564673
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
92e035d549ce1c917e8825b040a3d5bbb2e0d669ee6f8af7eab9d389dcd25396
37,674
[ -1 ]
37,675
mixins.lisp
open-rsx_rsbag-cl/test/backend/mixins.lisp
;;;; mixins.lisp --- Unit tests for backend mixin classes. ;;;; ;;;; Copyright (C) 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.test) ;;; `mock-buffering-backend' class (define-condition mock-write-back-error (error) ()) (defclass mock-buffering-backend () ((written :initarg :written :type list :accessor backend-written :initform nil))) (defmethod buffer-property ((backend mock-buffering-backend) (buffer t) (name t)) 0) (defmethod make-buffer ((backend mock-buffering-backend) (buffer t)) (list (if buffer (first buffer) (gensym)) nil)) (defmethod write-buffer ((backend mock-buffering-backend) (buffer t)) ;; Sleep a little while to simulate slow write-back. This is helpful ;; for tests which try to detect failure to write-back data. (sleep .001) (case (second buffer) (error (error 'mock-write-back-error)) (t (appendf (backend-written backend) (list buffer)))) (values)) (defmethod close ((backend mock-buffering-backend) &key abort) (declare (ignore abort))) ;;; (defclass async-double-buffered-writer-mock-backend (mock-buffering-backend async-double-buffered-writer-mixin) ()) (deftestsuite rsbag.backend.async-double-buffered-writer (backend-root) () (:documentation "Unit tests for the `async-double-buffered-writer' class.")) (addtest (rsbag.backend.async-double-buffered-writer :documentation "Make sure that that the async write-back of `async-double-buffered-writer' write everything and in the correct order.") write-back/smoke (ensure-cases (data) `(() (1) ,(iota 10) ,(iota 100)) (let+ ((backend (make-instance 'async-double-buffered-writer-mock-backend)) (expected '()) (current-buffer nil) ((&flet do-one (data) (setf current-buffer (make-buffer backend current-buffer)) (setf (second current-buffer) data) (appendf expected (list current-buffer)) (write-buffer backend current-buffer)))) (mapcar #'do-one data) (close backend) (ensure-same (backend-written backend) expected :test #'equal)))) (addtest (rsbag.backend.async-double-buffered-writer :documentation "Make sure that the next operation after a failed async write-back of `async-double-buffered-writer' operation signals the error.") write-back/conditions (macrolet ((with-write-back-error (&body body) `(let* ((backend (make-instance 'async-double-buffered-writer-mock-backend)) (buffer (make-buffer backend nil))) (setf (second buffer) 'error) ; signals an error on write-back (write-buffer backend buffer) ; does not signal immediately ;; We expect the next operation, BODY, to receive the ;; error. (ensure-condition 'mock-write-back-error ,@body)))) ;; Catch the async error in the next write operation. (with-write-back-error (setf buffer (make-buffer backend buffer) (second buffer) 1) (write-buffer backend buffer)) ;; Catch the async error when closing the backend. (with-write-back-error (close backend))))
3,549
Common Lisp
.lisp
86
32.825581
88
0.622713
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
289d3dc7753ad5ba5efad7e05337410a05e930e81015c7e38ee0393e02ae3037
37,675
[ -1 ]
37,676
package.lisp
open-rsx_rsbag-cl/test/backend/tidelog/package.lisp
;;;; package.lisp --- Package definition for unit tests of the tidelog backend. ;;;; ;;;; Copyright (C) 2013, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.backend.tidelog.test (:use #:cl #:alexandria #:let-plus #:iterate #:lift #:rsbag.backend.tidelog #:rsbag.backend.test) (:import-from #:rsbag.backend.tidelog #:byte-pattern->block-class #:reconstruct-indices #:find-next-block #:+format-version-major+ #:+format-version-minor+ #:indx-channel-id #:indx-count #:index-add-entries) (:export #:backend-tidelog-root) (:documentation "This package contains unit tests for the backend module")) (cl:in-package #:rsbag.backend.tidelog.test) (deftestsuite backend-tidelog-root (backend-root) () (:documentation "Root unit test suite for the tidelog backend.")) ;;; Utilities (defun tide-block (&key (version-major +format-version-major+) (version-minor +format-version-minor+)) `(:tide (:ub64le 0) ,version-major ,version-minor (:ub32le 0) (:ub32le 0))) (defun valid-chnk-block (&key (id 0) (count 0) (content '())) (let ((content-size (length (apply #'octetify content)))) `(:chnk (:ub64le ,(+ 25 content-size)) (:ub32le ,id) (:ub32le ,count) (:ub64le 0) (:ub64le 0) 0 ,@content))) (defun chunk-entry () `((:ub32le 0) (:ub64le 0) (:ub32le 1) 0)) (defparameter +invalid-chnk-block+ `(:chnk (:ub64le ,(ash 1 63)) (:ub32le 0))) (defun call-with-writable-log (function &key (close t)) (let* ((stream (flexi-streams:make-in-memory-output-stream)) (backend (rsbag.backend:make-backend :tide :stream stream :direction :output))) (multiple-value-call #'values (funcall function backend) (progn (when close (close backend)) (flexi-streams:get-output-stream-sequence stream)) backend))) (defmacro with-writable-log ((backend-var &key (close nil close-supplied?)) &body body) `(call-with-writable-log (lambda (,backend-var) ,@body) ,@(when close-supplied? `(:close ,close)))) (defun call-with-readable-log (function data) (let* ((stream (flexi-streams:make-in-memory-input-stream data)) (backend (rsbag.backend:make-backend :tide :stream stream :direction :input))) (multiple-value-call #'values (funcall function backend) backend))) (defmacro with-readable-log ((backend-var data) &body body) `(call-with-readable-log (lambda (,backend-var) ,@body) ,data))
2,763
Common Lisp
.lisp
68
33.102941
79
0.617284
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
1433d20354e3fb9646585e5d0b35d4b440d14671696a46d7801e36982cbe8dd3
37,676
[ -1 ]
37,677
io.lisp
open-rsx_rsbag-cl/test/backend/tidelog/io.lisp
;;;; io.lisp --- Unit tests for the block io functions of the tidelog backend. ;;;; ;;;; Copyright (C) 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.tidelog.test) (addtest (backend-tidelog-root :documentation "Smoke test for the `scan' method specialized on the TIDE block.") scan/tide/smoke (ensure-cases (input expected) `(;; Wrong block. (,(valid-chnk-block) error) ;; Wrong major version. (,(tide-block :version-major (1+ +format-version-major+)) error) ;; Valid case. (,(tide-block) (() () () t)) (,(tide-block :version-minor (1+ +format-version-minor+)) (() () () t)) (,(append (tide-block) (valid-chnk-block)) (() () ((0 . 22)) t))) (let+ ((stream (apply #'octet-streamify input)) ((&flet do-it () (scan stream :tide)))) (case expected (error (ensure-condition 'error (do-it))) (t (ensure-same (do-it) (values-list expected))))))) (addtest (backend-tidelog-root :documentation "Test restarts established by the `scan' method specialized on the TIDE for dealing with corrupt files.") scan/tide/restarts (ensure-cases (input restarts expected) `(;; Skip once. ((,@(tide-block) ,@(valid-chnk-block) ,@+invalid-chnk-block+ ,@(valid-chnk-block)) (continue) (() () ((0 . 22) (0 . 75)) nil)) ;; Skip once with garbage at end. ((,@(tide-block) ,@(valid-chnk-block) ,@+invalid-chnk-block+ ,@(valid-chnk-block) :chnk (:ub64le 0)) (continue continue) (() () ((0 . 22) (0 . 75)) nil)) ;; Skip twice. ((,@(tide-block) ,@(valid-chnk-block) ,@+invalid-chnk-block+ ,@(valid-chnk-block) ,@+invalid-chnk-block+ ,@(valid-chnk-block)) (continue continue) (() () ((0 . 22) (0 . 75) (0 . 128)) nil))) (let+ ((stream (apply #'octet-streamify input)) ((&flet do-it () (multiple-value-prog1 (handler-bind ((error (lambda (condition) (invoke-restart (or (pop restarts) (error "~@<No more restarts~@:>")) condition)))) (scan stream :tide)) (unless (null restarts) (error "~@<Leftover restarts: ~S~@:>" restarts)))))) (ensure-same (do-it) (values-list expected))))) (addtest (backend-tidelog-root :documentation "Smoke test for the `byte-pattern->block-class' function.") byte-pattern->block-class/smoke ;; Try to lookup a non-existing block class. (ensure-condition no-such-block-class-error (byte-pattern->block-class (octetify "NONO"))) ;; Lookup an existing block class. (ensure-same (find-class 'rsbag.backend.tidelog::tide) (byte-pattern->block-class (octetify "TIDE"))))
3,132
Common Lisp
.lisp
69
35.608696
86
0.533901
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
18c18774c88752f0405d543a401774fe12f6008c454eddbd4e66a4ebc4d0d4c3
37,677
[ -1 ]
37,678
repair.lisp
open-rsx_rsbag-cl/test/backend/tidelog/repair.lisp
;;;; repair.lisp --- Unit tests for the repair functions of the tidelog backend. ;;;; ;;;; Copyright (C) 2013, 2015 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.tidelog.test) (defclass mock-index () ((channel-id :initarg :channel-id :accessor mock-index-channel-id) (entries :accessor mock-index-entries :initform '()))) (defmethod index-add-entries ((index mock-index) (entries sequence) (chunks vector)) (push (cons entries chunks) (mock-index-entries index))) (addtest (backend-tidelog-root :documentation "Smoke test for the `reconstruct-indices' function.") reconstruct-indices/smoke (ensure-cases (input chunks expected) `(;; Minimal input ((,@(tide-block) ,@(valid-chnk-block :count 1 :content `(,@(chunk-entry)))) ,#((0 . 22)) ((0 ((#() . ,#((0 . 22)))))))) (let+ ((stream (apply #'octet-streamify input)) (indices (make-hash-table)) ((&flet ensure-index (channel-id) (ensure-gethash channel-id indices (make-instance 'mock-index :channel-id channel-id))))) (reconstruct-indices stream chunks #'ensure-index) (ensure-same (mapcar (lambda (index) (list (mock-index-channel-id index) (mock-index-entries index))) (hash-table-values indices)) expected :test #'equalp)))) (addtest (backend-tidelog-root :documentation "Smoke test for the `find-next-block' function.") find-next-block/smoke (ensure-cases (input expected) (let ((chnk 'rsbag.backend.tidelog::chnk)) (append ;; Some inputs which are too short to contain a block ;; tag. Covers length 4 without tag: 00 00 00 00. (iter (for length :to 4) (collect `((,(nibbles:make-octet-vector length)) ()))) ;; For inputs of length 4 or more, place the block tag in all ;; possible positions. Covers length 4 with tag: CHNK. (iter outer (for length :from 4 :to 9) (iter (for position :from 0 :to (- length 4)) (let ((input (list (nibbles:make-octet-vector position) :chnk (nibbles:make-octet-vector (- length 4 position))))) (in outer (collect `(,input ((,position ,chnk)))))))) ;; Some specific cases of multiple block tags. `(((:chnk :chnk) ((0 ,chnk) (4 ,chnk))) ((:chnk 0 :chnk) ((0 ,chnk) (5 ,chnk))) ((0 :chnk :chnk) ((1 ,chnk) (5 ,chnk))) ((0 :chnk 0 :chnk) ((1 ,chnk) (6 ,chnk)))))) (let* ((stream (apply #'octet-streamify input)) (result (iter (for offset-and-block next (multiple-value-list (find-next-block stream))) (while offset-and-block) (collect offset-and-block) (file-position stream (+ (file-position stream) 4))))) (ensure-same result expected :test #'equalp))))
3,417
Common Lisp
.lisp
71
34.422535
92
0.520228
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
d68851514309db4468b6d77d7717978635c75f428d3bccac8969e12decd78bfd
37,678
[ -1 ]
37,679
file.lisp
open-rsx_rsbag-cl/test/backend/tidelog/file.lisp
;;;; file.lisp --- High-level tests for the tidelog backend. ;;;; ;;;; Copyright (C) 2013, 2015, 2016, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.tidelog.test) (addtest (backend-tidelog-root :documentation "Test retained entry order in case of identical timestamps within a single channel.") repeated-timestamp (let+ ((channel-name "foo") (timestamp (rsbag.backend:timestamp->uint64 (local-time:now))) (entry-1 (nibbles:octet-vector 1 2 3 4)) (entry-2 (nibbles:octet-vector 5 6 7 8)) ((&flet write-bag () (with-writable-log (backend) (let ((channel (rsbag.backend:make-channel-id backend channel-name))) (rsbag.backend:put-channel backend channel channel-name '()) (rsbag.backend:put-entry backend channel timestamp entry-1) (rsbag.backend:put-entry backend channel timestamp entry-2) channel)))) ((&flet read-bag (data channel) (with-readable-log (backend data) (values (rsbag.backend:get-entry-at-index backend channel 0) (rsbag.backend:get-entry-at-index backend channel 1))))) ((&values channel data) (write-bag)) ((&values entry-1* entry-2*) (read-bag data channel))) (ensure-same entry-1* entry-1 :test #'equalp) (ensure-same entry-2* entry-2 :test #'equalp)))
1,500
Common Lisp
.lisp
30
40.766667
83
0.617587
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
72f17dad4c2cd2239033183b670152a4da72d5332c7d9f4e781d63a59593a4a3
37,679
[ -1 ]
37,680
package.lisp
open-rsx_rsbag-cl/test/backend/elan/package.lisp
;;;; package.lisp --- Package definition for unit tests of the ELAN backend. ;;;; ;;;; Copyright (C) 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.backend.elan.test (:use #:cl #:lift #:rsbag.backend.elan #:rsbag.backend.test) (:export #:backend-elan-root) (:documentation "This package contains unit tests for the ELAN backend module.")) (cl:in-package #:rsbag.backend.elan.test) (deftestsuite backend-elan-root (backend-root) () (:documentation "Root unit test suite for the ELAN backend."))
593
Common Lisp
.lisp
20
26.75
76
0.708481
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
0f6f2132b6a926264539cb150fbcf5c221790f498a9cfa448e4d9efc8cc35802
37,680
[ -1 ]
37,681
package.lisp
open-rsx_rsbag-cl/test/rsb/package.lisp
;;;; package.lisp --- Package definition for unit tests of the rsb module. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.rsb.test (:use #:cl #:alexandria #:let-plus #:iterate #:more-conditions #:lift #:nibbles #:rsbag #:rsbag.rsb) (:export #:rsb-root) ;; Utilities (:export #:collecting-events) (:documentation "This package contains unit tests for the rsb module.")) (cl:in-package #:rsbag.rsb.test) (defparameter *test-configuration* '(((:transport :inprocess :enabled) . t) ((:introspection :enabled) . nil))) (deftestsuite rsb-root (rsbag.test:root) () (:dynamic-variables (rsb:*configuration* *test-configuration*)) (:documentation "Root unit test suite for the rsb module.")) ;;; Utilities (defmacro collecting-events ((name &key (errors ''())) &body body) "Execute BODY with a collector function named NAME in scope." (with-gensyms (collected) (once-only (errors) `(let+ ((,collected '()) ((&flet ,name (&optional datum) (cond ((not datum) (reverse ,collected)) ((not (member datum ,errors)) (push datum ,collected)) (t (error "~@<Simulated processing error~@:>")))))) ,@body))))
1,431
Common Lisp
.lisp
48
23.6875
74
0.595481
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8fc3739eec575aa5a57d7f2d7c2c7e88ee0414eb88bf01f86a2dad96e816a6a4
37,681
[ -1 ]
37,682
protocol.lisp
open-rsx_rsbag-cl/test/rsb/protocol.lisp
;;;; protocol.lisp --- Unit tests for the protocol of the rsb module. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.test) (deftestsuite events->bag-root (rsb-root) () (:documentation "Test suite for the `events->bag' function.")) (addtest (events->bag-root :documentation "Test the `events->bag' function with a participant source.") participant-source (ensure-cases (args events expected) `(;; Invalid channel strategy => error ((:channel-strategy :no-such-strategy) nil service-provider:missing-provider-error) ;; These are valid. ((:channel-strategy :scope-and-type) (1 2 3) (,(octet-vector 1 0 0 0) ,(octet-vector 2 0 0 0) ,(octet-vector 3 0 0 0))) ((:introspection-survey? t) (1 2 3) (,(octet-vector 1 0 0 0) ,(octet-vector 2 0 0 0) ,(octet-vector 3 0 0 0))) ((:introspection-survey? nil) (1 2 3) (,(octet-vector 1 0 0 0) ,(octet-vector 2 0 0 0) ,(octet-vector 3 0 0 0)))) (let+ (((&flet do-it () (rsbag.test:with-mock-bag (bag :direction :output) () (with-open-connection (connection (apply #'events->bag '("inprocess:") bag args)) (rsb:with-participant (informer :informer "inprocess:") (mapc (lambda (datum) (let ((buffer (make-octet-vector 4))) (setf (ub32ref/le buffer 0) datum) (rsb:send informer buffer :rsb.transport.wire-schema :uint32))) events)) (map 'list #'rsb:event-data (first (bag-channels bag)))))))) (case expected (service-provider:missing-provider-error (ensure-condition 'service-provider:missing-provider-error (do-it))) (t (ensure-same (do-it) expected :test #'equalp)))))) (addtest (events->bag-root :documentation "Test the `events->bag' function without a source.") no-source (ensure-cases (args timestamps-and-events expected) `(;; Invalid channel strategy => error ((:channel-strategy :no-such-strategy) () service-provider:missing-provider-error) ;; These are valid. (() ((,(local-time:now) ("/foo" #1=,(octet-vector 1 2 3 4) "int32"))) (#1#)) ((:timestamp :receive) ((,(local-time:now) ("/foo" #2=,(octet-vector 1 2 3 4) "int32"))) (#2#)) ((:channel-stratetgy :scope-and-type) ((,(local-time:now) ("/foo" #3=,(octet-vector 1 2 3 4) "int32"))) (#3#)) (() ((nil ("/foo" #4=,(octet-vector 1 2 3 4) "int32" :send ,(local-time:now)))) (#4#)) ((:timestamp :receive) ((nil ("/foo" #5=,(octet-vector 1 2 3 4) "int32" :receive ,(local-time:now)))) (#5#))) (let+ (((&flet make-event (scope payload wire-schema &rest timestamps) (let ((event (rsb:make-event scope payload :rsb.transport.wire-schema wire-schema))) (setf (rsb:event-origin event) (uuid:make-null-uuid) (rsb:event-sequence-number event) 0 (rsb:event-timestamps event) timestamps) event))) ((&flet do-it () (rsbag.test:with-mock-bag (bag :direction :output) () (with-open-connection (connection (apply #'events->bag nil bag args)) (mapc (lambda+ ((timestamp (scope payload wire-schema &rest timestamps))) (let ((event (apply #'make-event scope payload wire-schema timestamps))) (rsbag.rsb.recording:process-event connection timestamp event))) timestamps-and-events)) (map 'list #'rsb:event-data (first (bag-channels bag))))))) (case expected (service-provider:missing-provider-error (ensure-condition 'service-provider:missing-provider-error (do-it))) (t (ensure-same (do-it) expected :test #'equalp)))))) (deftestsuite bag->events-root (rsb-root) () (:documentation "Test suite for the `bag->events' function.")) (addtest (bag->events-root :documentation "Smoke test for the `bag->events' function.") smoke (ensure-cases (source args &optional expected) `(;; Invalid channel strategy => error (,(rsbag.test:simple-bag) (:replay-strategy :no-such-strategy) service-provider:missing-provider-error) ;; Cannot supply and arguments which would have applied to ;; opening the bag => error (,(rsbag.test:simple-bag) (:backend :does-not-matter) incompatible-arguments) (,(rsbag.test:simple-bag) (:transform :does-not-matter) incompatible-arguments) (,(rsbag.test:simple-bag) (:bag-class :does-not-matter) incompatible-arguments) ;; These are valid. (,(rsbag.test:simple-bag) (:replay-strategy :as-fast-as-possible)) ((,(rsbag.test:simple-bag)) (:replay-strategy :as-fast-as-possible)) (#(,(rsbag.test:simple-bag)) (:replay-strategy :as-fast-as-possible)) ;; Multiple sources ((,(rsbag.test:simple-bag) ,(rsbag.test:simple-bag)) (:replay-strategy :as-fast-as-possible)) (#(,(rsbag.test:simple-bag) ,(rsbag.test:simple-bag)) (:replay-strategy :as-fast-as-possible))) (let+ (((&flet do-it () (collecting-events (record) (with-open-connection (connection (apply #'bag->events source (lambda (timestamp event) (declare (ignore timestamp)) (record event)) args)) (rsbag.rsb.replay:replay connection (rsbag.rsb.replay:connection-strategy connection))) (record))))) (case expected (service-provider:missing-provider-error (ensure-condition 'service-provider:missing-provider-error (do-it))) (incompatible-arguments (ensure-condition 'incompatible-arguments (do-it))) (t (ensure-same (length (do-it)) (reduce #'+ (mappend #'bag-channels (if (typep source 'sequence) (coerce source 'list) (list source))) :key #'length))))))) (addtest (bag->events-root :documentation "Ensure that events replayed via RSB by `bag->events' get the configured prefix scope.") prefix-scope (ensure-cases (prefix) '("/" "/prefix") (rsb:with-participant (reader :reader "inprocess:") ;; Send the events stored in the mock bag. (with-open-connection (connection (bag->events (rsbag.test:simple-bag) (format nil "inprocess:~A" prefix) :replay-strategy :as-fast-as-possible)) (rsbag.rsb.replay:replay connection (rsbag.rsb.replay:connection-strategy connection))) ;; Receive the events. (iter (repeat (reduce #'+ (bag-channels (rsbag.test:simple-bag)) :key #'length)) (let ((scope (rsb:event-scope (rsb:receive reader)))) (ensure (not (rsb:scope= scope prefix))) (ensure (rsb:sub-scope? scope prefix)))))))
8,173
Common Lisp
.lisp
190
29.947368
81
0.51997
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e335e8b86572e191a59b576a7b5668f21b5bd81a1dc7091d73e87bf028f2b675
37,682
[ -1 ]
37,683
package.lisp
open-rsx_rsbag-cl/test/rsb/replay/package.lisp
;;;; package.lisp --- Package definition for unit tests of the rsb.replay module. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.rsb.replay.test (:use #:cl #:alexandria #:let-plus #:iterate #:more-conditions #:lift #:rsbag #:rsbag.rsb #:rsbag.rsb.replay) (:documentation "This package contains unit tests for the rsb.replay module.")) (cl:in-package #:rsbag.rsb.replay.test) (deftestsuite rsb-replay-root (rsbag.rsb.test:rsb-root) () (:documentation "Root unit test suite for the rsb.replay module.")) ;;; Utilities (defmacro define-replay-strategy-construction-test ((class &key (suite-name (symbolicate class '#:-root))) &body cases) "Define a test case for class CLASS in test suite `SUITE-NAME' with CASES. Each element of CASES has to be of the form (INITARGS EXPECTED) where EXPECTED is either the symbol `error' or the symbol `t'." `(addtest (,suite-name :documentation ,(format nil "Test construction of `~(~A~)' instances." class)) construction (ensure-cases (initargs expected) (list ,@cases) (let+ (((&flet do-it () (apply #'make-instance ',class initargs)))) (case expected (missing-required-initarg (ensure-condition 'missing-required-initarg (do-it))) (incompatible-initargs (ensure-condition 'incompatible-initargs (do-it))) (type-error (ensure-condition 'type-error (do-it))) (error (ensure-condition 'error (do-it))) (t (do-it))))))) (defun select-channel (name) (compose (curry #'string= name) #'channel-name)) (defun call-as-replay-strategy-test-case (bag processing-errors strategy-class strategy-initargs replay-function assessment-function) (let+ (((&flet do-it () (rsbag.rsb.test:collecting-events (collect :errors processing-errors) (with-open-connection (connection (apply #'bag->events bag (lambda (timestamp event) (declare (ignore timestamp)) (collect event)) :replay-strategy strategy-class strategy-initargs)) (funcall replay-function connection (connection-strategy connection))) (collect))))) (etypecase assessment-function ((eql error) (ensure-condition 'error (do-it))) ((eql replay-error) (ensure-condition 'replay-error (do-it))) ((eql entry-retrieval-error) (ensure-condition 'entry-retrieval-error (do-it))) ((eql entry-processing-error) (ensure-condition 'entry-processing-error (do-it))) (function (funcall assessment-function (do-it)))))) (defmacro define-replay-strategy-smoke-test ((class &key (suite-name (symbolicate class '#:-root)) (bag-var (gensym "BAG")) (initargs-var (gensym "INITARGS")) (expected-var (gensym "EXPECTED")) (required-initargs '())) &body cases) "Define a smoke test case for class CLASS in test suite `SUITE-NAME' with CASES. Each element of CASES has to be of the form (INITARGS &key BAG PROCESSING-ERRORS EXPECTED) where EXPECTED is the list of entries the strategy should produce when applied to BAG." `(addtest (,suite-name :documentation ,(format nil "Smoke test for the `~(~A~)' replay strategy class." class)) replay/smoke (let ((,bag-var (rsbag.test:simple-bag))) (ensure-cases (initargs bag processing-errors expected) (list ,@(map-product (lambda+ ((initargs &key bag processing-errors expected) (initargs1 expected1)) `(let ((,initargs-var (list ,@initargs1)) (,expected-var (list ,@expected1))) (list (append ,initargs ,initargs-var) ,@(if bag `(,bag) `(,bag-var)) ,processing-errors ,@(if expected `(,expected) `(,expected-var))))) cases `((() (1 2 3 4 5)) ((:end-index 5) (1 2 3 4 5)) ((:start-index 1) (2 3 4 5)) ((:end-index 3) (1 2 3)) ((:start-index -4) (2 3 4 5)) ((:end-index -2) (1 2 3)) ((:start-index 1 :end-index 3) (2 3)) ((:start-time 0.04) (2 3 4 5)) ((:start-time -0.06) (2 3 4 5)) ((:end-time 0.09) (1 2 3 4)) ((:end-time -0.02) (1 2 3 4)) ((:channels (select-channel "/foo")) (1 2)))) ;; Some invalid start and end indices. `((:start-index -10 ,,@required-initargs) ,,bag-var () replay-error) `((:start-index 10 ,,@required-initargs) ,,bag-var () replay-error) `((:start-index -10 :error-policy ,#'continue ,,@required-initargs) ,,bag-var () ()) `((:start-index 10 :error-policy ,#'continue ,,@required-initargs) ,,bag-var () ()) `((:end-index -10 ,,@required-initargs) ,,bag-var () replay-error) `((:end-index 10 ,,@required-initargs) ,,bag-var () replay-error) `((:end-index -10 :error-policy ,#'continue ,,@required-initargs) ,,bag-var () ()) `((:end-index 10 :error-policy ,#'continue ,,@required-initargs) ,,bag-var () ())) (call-as-replay-strategy-test-case bag processing-errors ',class initargs (lambda (connection strategy) (replay connection strategy)) (case expected ((error replay-error entry-retrieval-error entry-processing-error) expected) (t (lambda (events) (ensure-same events expected :test #'equal)))))))))
6,568
Common Lisp
.lisp
152
31.796053
88
0.519462
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5b6e277f4f5d681737378912148c7f8fc17293f55f9f063286ae8749d518fc4d
37,683
[ -1 ]
37,684
fixed-rate.lisp
open-rsx_rsbag-cl/test/rsb/replay/fixed-rate.lisp
;;;; fixed-rate.lisp --- Unit tests for the fixed-rate class. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.replay.test) (deftestsuite fixed-rate-root (rsb-replay-root) () (:documentation "Test suite for the `fixed-rate' replay strategy class.")) (define-replay-strategy-construction-test (fixed-rate) ;; Some invalid cases. '(() missing-required-initarg) '((:delay 1 :rate 1) incompatible-initargs) '((:delay 0) type-error) '((:rate 0) type-error) ;; Some valid cases. '((:delay 1) t) `((:delay 1 :error-policy ,#'continue) t) '((:rate 1) t) `((:rate 1 :error-policy ,#'continue) t)) (define-replay-strategy-smoke-test (fixed-rate :expected-var expected :required-initargs (:rate 1000)) ;; Some simple cases. ('(:rate 1000)) (`(:rate 1000 :error-policy ,#'continue)) ('(:delay 1/1000)) (`(:delay 1/1000 :error-policy ,#'continue)) ;; Without an error policy, the first failing event causes an error ;; to be signaled. ('(:rate 1000 :error-policy nil) :bag (rsbag.test:simple-bag :errors '(2)) :expected 'entry-retrieval-error) ('(:rate 1000 :error-policy nil) :processing-errors '(2) :expected 'entry-processing-error) ;; The `continue' restart skips to the next entry. Therefore, the ;; observed output continues after the failing entry. (`(:rate 1000 :error-policy ,#'continue) :bag (rsbag.test:simple-bag :errors '(4)) :expected (remove 4 expected)) (`(:rate 1000 :error-policy ,#'continue) :processing-errors '(4) :expected (remove 4 expected)))
1,896
Common Lisp
.lisp
45
37.666667
69
0.584056
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
ef83369cc4b348a1785dab60dd3ffe867cc385bc939786150f9c81856d556310
37,684
[ -1 ]
37,685
strategy-mixins.lisp
open-rsx_rsbag-cl/test/rsb/replay/strategy-mixins.lisp
;;;; strategy-mixins.lisp --- Unit tests for replay strategy mixin classes. ;;;; ;;;; Copyright (C) 2013, 2016, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.replay.test) ;;; `bounds-mixin' (deftestsuite bounds-mixin-root (rsb-replay-root) () (:documentation "Test suite for the `bounds-mixin' replay strategy mixin class.")) (define-replay-strategy-construction-test (bounds-mixin) ;; Some invalid cases. '((:start-index 1.5) type-error) '((:end-index 1/2) type-error) '((:start-index 2 :end-index 1) incompatible-initargs) '((:start-index -1 :end-index -2) incompatible-initargs) ;; These are OK. '((:start-index 0) t) '((:start-index -10) t) '((:end-index 1) t) '((:end-index -1) t) '((:start-index 1 :end-index 2) t)) ;;; `time-bounds-mixin' (deftestsuite time-bounds-mixin-root (rsb-replay-root) () (:documentation "Test suite for the `time-bounds-mixin' replay strategy mixin class.")) (define-replay-strategy-construction-test (time-bounds-mixin) ;; Some invalid cases. ;; TODO check types? '((:start-time 1.0 :start-index 2) incompatible-initargs) '((:end-time -1.0 :end-index 2) incompatible-initargs) ;; These are OK. '((:start-time 1.5) t) '((:end-time -1) t) '((:start-time 1/2 :end-time 1) t) `((:start-time ,(local-time:now)) t) `((:end-time ,(local-time:now)) t) (let* ((now (local-time:now)) (later (local-time:adjust-timestamp now (:offset :sec 1)))) `((:start-time ,now :end-time ,later) t)) '((:start-time 1 :end-index 5) t) `((:end-time ,(local-time:now) :start-index 5) t)) ;;; `filtering-mixin' (deftestsuite filtering-mixin-root (rsb-replay-root) () (:documentation "Test suite for the `filtering-mixin' replay strategy mixin class.")) (define-replay-strategy-construction-test (filtering-mixin) ;; Valid cases. '(() t) `((:filters ,(list (rsb.filter:make-filter :scope :scope "/"))) t)) ;;; `event-id-mixin' (deftestsuite event-id-mixin-root (rsb-replay-root) () (:documentation "Test suite for the `event-id-mixin' replay strategy mixin class.")) (define-replay-strategy-construction-test (event-id-mixin) ;; Invalid case '((:event-id 5) type-error) ;; Valid cases '((:event-id :keep) t) '((:event-id :replace) t)) ;;; `Timestamp-adjustment-mixin' (deftestsuite timestamp-adjustment-mixin-root (rsb-replay-root) () (:documentation "Test suite for the `timestamp-adjustment-mixin' replay strategy mixin class.")) (define-replay-strategy-construction-test (timestamp-adjustment-mixin) ;; Some invalid cases. '((:adjustments :foo) type-error) '((:adjustments (:foo)) type-error) '((:adjustments ((:foo))) type-error) '((:adjustments ((:create (:copy)))) type-error) ;; These are OK. '(() t) '((:adjustments ()) t) '((:adjustments ((:create :now))) t) `((:adjustments ((:create ,(local-time:now)))) t) `((:adjustments ((:create ,(local-time:now)) (:send :now))) t) '((:adjustments ((:send (:copy :create)))) t))
3,794
Common Lisp
.lisp
86
41.127907
86
0.534833
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
95efb47bce7b53753f7316004935a3d802c041a929c5bd280a092a7462cea322
37,685
[ -1 ]
37,686
recorded-timing.lisp
open-rsx_rsbag-cl/test/rsb/replay/recorded-timing.lisp
;;;; recorded-timing.lisp --- Unit tests for the recorded-timing strategy class. ;;;; ;;;; Copyright (C) 2013, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.replay.test) (deftestsuite recorded-timing-root (rsb-replay-root) () (:documentation "Test suite for the `recorded-timing' replay strategy class.")) (define-replay-strategy-construction-test (recorded-timing) ;; Some invalid cases. '((:speed 0) type-error) '((:speed -1) type-error) '((:max-delay -1) type-error) ;; Some valid cases. '(() t) '((:speed 1) t) `((:speed 0.5 :error-policy ,#'continue) t) `((:speed 3/2 :error-policy nil) t) '((:max-delay 0) t) `((:max-delay 1 :error-policy ,#'continue) t) `((:max-delay 1/2 :error-policy nil) t)) (define-replay-strategy-smoke-test (recorded-timing :expected-var expected) ;; Some simple cases. ('()) (`(:error-policy ,#'continue)) ('(:speed 2.5)) (`(:speed 1/2 :error-policy ,#'continue)) ('(:max-delay 1)) (`(:max-delay 1d-9 :error-policy ,#'continue)) ;; Without an error policy, the first failing event causes an error ;; to be signaled. ('(:error-policy nil) :bag (rsbag.test:simple-bag :errors '(2)) :expected 'entry-retrieval-error) ('(:error-policy nil) :processing-errors '(2) :expected 'entry-processing-error) ;; The `continue' restart skips to the next entry. Therefore, the ;; observed output continues after the failing entry. (`(:error-policy ,#'continue) :bag (rsbag.test:simple-bag :errors '(4)) :expected (remove 4 expected)) (`(:error-policy ,#'continue) :processing-errors '(4) :expected (remove 4 expected)))
1,953
Common Lisp
.lisp
48
37.020833
80
0.579031
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f4a42846fa16fd9b683dbdc26682bdfb46ad7722f3e7ed1637a07c98df0c2da4
37,686
[ -1 ]
37,687
as-fast-as-possible.lisp
open-rsx_rsbag-cl/test/rsb/replay/as-fast-as-possible.lisp
;;;; as-fast-as-possible.lisp --- Unit tests for the as-fast-as-possible strategy class. ;;;; ;;;; Copyright (C) 2013, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb.replay.test) (deftestsuite as-fast-as-possible-root (rsb-replay-root) () (:documentation "Test suite for the `as-fast-as-possible' replay strategy class.")) (define-replay-strategy-construction-test (as-fast-as-possible) ;; There are few interesting cases here. '(() t) `((:error-policy ,#'continue) t) '((:error-policy nil) t)) (define-replay-strategy-smoke-test (as-fast-as-possible :expected-var expected) ;; Some simple cases. ('()) (`(:error-policy ,#'continue)) ;; Without an error policy, the first failing event causes an error ;; to be signaled. ('(:error-policy nil) :bag (rsbag.test:simple-bag :errors '(2)) :expected 'entry-retrieval-error) ('(:error-policy nil) :processing-errors '(2) :expected 'entry-processing-error) ;; The `continue' restart skips to the next entry. Therefore, the ;; observed output continues after the failing entry. (`(:error-policy ,#'continue) :bag (rsbag.test:simple-bag :errors '(4)) :expected (remove 4 expected)) (`(:error-policy ,#'continue) :processing-errors '(4) :expected (remove 4 expected)))
1,438
Common Lisp
.lisp
36
36.083333
88
0.649713
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5820113d899a25bd4fd5a5f0434ade2691ae1193241a1f35cfc64944471671cd
37,687
[ -1 ]
37,688
package.lisp
open-rsx_rsbag-cl/src/package.lisp
;;;; package.lisp --- Package definition for the rsbag system. ;;;; ;;;; Copyright (C) 2011-2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag (:use #:cl #:alexandria #:iterate #:let-plus #:more-conditions) ;; Symbols (:export #:&from-source) ;; Types (:export #:direction #:if-does-not-exist-policy #:if-exists-policy #:transform-spec/default #:transform-spec/augment #:transform-spec/full #:transform-spec) ;; Conditions (:export #:rsbag-condition #:rsbag-problem-condition #:rsbag-error #:open-error #:open-error-source #:bag-condition #:bag-condition-bag #:no-such-channel #:no-such-channel-name #:direction-error #:direction-error-expected-direction #:channel-condition #:channel-condition-channel #:channel-open-error #:channel-exists #:no-such-entry #:no-such-entry-key) ;; meta-data protocol (:export #:meta-data #:meta-data-count #:meta-data-keys #:meta-data-values #:meta-data-plist #:meta-data-alist) ;; `bag' class and file protocol (:export #:bag #:bag-location #:bag-direction #:bag-transform #:bag-channels #:bag-channel #:create ; restart #:open-bag) ;; `synchronized-channel' class (:export #:synchronized-channel) ;; `synchronized-bag' class (:export #:synchronized-bag) ;; `channel' class and channel protocol (:export #:channel #:channel-bag #:channel-name #:channel-meta-data #:channel-transform #:channel-%id #:channel-%backend #:channel-timestamps #:channel-entries #:channel-items #:entry) ;; Time range protocol (:export #:start-timestamp #:end-timestamp) ;; Convenience macros (:export #:call-with-open-bag #:with-open-bag #:with-bag) ;; Package management macros (:export #:make-versioned-name #:with-renamed-package #:with-renamed-packages #:with-versioned-packages) ;; Threadpool (:export #:start-threadpool #:stop-threadpool #:enable-restart-threadpool #:with-threadpool) ;; Error handling utilities (:export #:function-calling-restart-bind) ;; Print utilities (:export #:print-direction #:print-location) (:documentation "This package contains the Common Lisp implementation of RSBag. The client interface primarily consists of the `bag' and `channel' classes. Conceptually, bags consists of multiple named channels which in turn contain sequences of timestamped data items."))
2,596
Common Lisp
.lisp
113
19.053097
70
0.686555
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
097bab9a4a9c2d3169ad7f1f2850e5bee3c45e3ce191c081bf06cbb1e02454aa
37,688
[ -1 ]
37,689
util.lisp
open-rsx_rsbag-cl/src/util.lisp
;;;; util.lisp --- Utilities used in the rsbag system. ;;;; ;;;; Copyright (C) 2011-2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag) (defmacro define-plist-data-mixin (name &key (slot-name name)) "Define a class `plist-NAME-mixin' which manages a plist in a slot. Define the following accessors along with the class: + `NAME-count' :: Return number of items. + `NAME-keys' :: Return item keys. + `NAME-values' :: Return item values. + `NAME-plist' :: Return items as plist. + `NAME-alist' :: Return items as alist." (let+ ((class-name (symbolicate "PLIST-" name "-MIXIN")) (initarg (make-keyword slot-name)) ((count-name keys-name values-name plist-name alist-name) (map 'list (curry #'symbolicate name) '("-COUNT" "-KEYS" "-VALUES" "-PLIST" "-ALIST")))) `(progn (defclass ,class-name () ((,slot-name :initarg ,initarg :type list :initform nil :documentation ,(format nil "Stores the ~(~A~) items associated ~ to the instance." name))) (:documentation "This mixin adds storage for a plist of items and associated accessors. See `define-plist-data-mixin' for a description.")) (defgeneric ,count-name (object) (:method ((object ,class-name)) (ash (length (slot-value object ',slot-name)) -1)) (:documentation ,(format nil "Return the number of ~(~A~) items stored in OBJECT." name))) (defgeneric ,keys-name (object) (:method ((object ,class-name)) (iter (for (key) on (slot-value object ',slot-name) :by #'cddr) (collect key))) (:documentation ,(format nil "Return a list of the keys of ~(~A~) items ~ stored in OBJECT." name))) (defgeneric ,values-name (object) (:method ((object ,class-name)) (iter (for (key value) on (slot-value object ',slot-name) :by #'cddr) (collect value))) (:documentation ,(format nil "Return a list of the values of ~(~A~) items ~ stored in OBJECT." name))) (defgeneric ,plist-name (object) (:method ((object ,class-name)) (slot-value object ',slot-name)) (:documentation ,(format nil "Return a plist of the ~(~A~) items stored in ~ OBJECT." name))) (defgeneric ,alist-name (object) (:method ((object ,class-name)) (plist-alist (slot-value object ',slot-name))) (:documentation ,(format nil "Return an alist of the ~(~A~) items stored ~ in OBJECT." name))) (defgeneric ,name (object key) (:method ((object ,class-name) (key t)) (getf (slot-value object ',slot-name) key)) (:documentation ,(format nil "Return the ~(~A~) item of OBJECT identified ~ by KEY." name))) (defgeneric (setf ,name) (new-value object key) (:method ((new-value t) (object ,class-name) (key t)) (setf (getf (slot-value object ',slot-name) key) new-value)) (:documentation ,(format nil "Associate NEW-VALUE to OBJECT as the ~(~A~) item identified by KEY." name)))))) (define-plist-data-mixin meta-data) ;;; Error handling utilities (defmacro function-calling-restart-bind (clauses &body body) "Execute BODY with established restarts according to CLAUSES. Each element of clauses is of the form ((NAME LAMBDA-LIST &rest VARIABLES) &key REPORT) where NAME is the name of the restart that should be established VARIABLES is a list of variables names which are initially bound to nil but can be set to functions of one parameter - a condition instance - in BODY which implement the behavior of the restart. The keyword parameter REPORT works like :report-function in `cl:restart-case'. Restarts are only active if one of their VARIABLES in non-nil. When such a restart is invoked, the first non-nil variable among its VARIABLES is called as function with the condition as its sole argument to implement the behavior of the restart. Example: (control-transferring-restart-bind (((continue skip) :report (lambda (stream) (format stream \"Skip the element\")))) (iter (when (first-iteration-p) (setf skip (lambda () (next-iteration)))) DO-SOMETHING)) " (let+ ((all-variables '()) ((&flet+ process-clause (((name &ign &rest variables) &key report)) (mapc (lambda (var) (pushnew var all-variables)) variables) `(,name (lambda (&rest args) (apply (or ,@variables) args)) :test-function (lambda (condition) (declare (ignore condition)) (or ,@variables)) ,@(when report `(:report-function ,report))))) (clauses (mapcar #'process-clause clauses))) `(let ,all-variables (restart-bind ,clauses ,@body)))) ;;; Printing utilities (defun print-direction (stream direction &optional colon? at?) (declare (ignore colon? at?)) (format stream "~:[-~;r~]~:[-~;w~]" (member direction '(:input :io)) (member direction '(:output :io)))) (defun print-location (stream location &optional colon? at?) (declare (ignore colon? at?)) (format stream "~:[N/A~;~:*~S~]" (typecase location (pathname (format nil "~A.~A" (pathname-name location) (pathname-type location))) (t location))))
6,266
Common Lisp
.lisp
138
33.23913
76
0.54696
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5e92dfaaad4445f783257ff50cac97a77ea82012a05ac1ebbf7f5bc5e21ba8ed
37,689
[ -1 ]
37,690
protocol.lisp
open-rsx_rsbag-cl/src/protocol.lisp
;;;; protocol.lisp --- Protocol used by the rsbag system. ;;;; ;;;; Copyright (C) 2011-2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag) ;;; Bag opening protocol (defgeneric open-bag (source &rest args &key direction if-exists backend flush-strategy bag-class transform &allow-other-keys) (:documentation "Open the data source SOURCE and return a bag object. BACKEND designates the backend that should be used and ARGS (except the keyword arguments :backend, :bag-class and :transform) are passed to the backend. DIRECTION can be any of :input, :output and :io. IF-EXISTS specifies the behavior when DIRECTION is :output or :io and SOURCE already exists. Valid values are :error and :overwrite. See `cl:open' for more information. BACKEND has to be a keyword naming a backend class. Available backends can be inspected using the service designated by `rsbag.backend:backend'. When supplied, BAG-CLASS specifies the class of which the returned bag object should be an instance. When supplied, TRANSFORM specifies a transformation that should be applied to all entries read from or written to the returned bag object. See type `transform-spec'. Example: RSBAG> (open-bag #p\"/tmp/mylog.tide\" :direction :input) #<BAG \"mylog.tide\" r- (1) {100A2ECDF3}>")) ;; Default behavior (defmethod open-bag :around ((source t) &rest args &key) (with-condition-translation (((error open-error) :source source)) (iter (restart-case (return (apply #'call-next-method source args)) (retry () :report (lambda (stream) (format stream "~@<Retry opening the bag ~ stored in ~S.~@:>" source))) (use-source (new-value) :report (lambda (stream) (format stream "~@<Use a different source ~ instead of ~S.~@:>" source)) :interactive (lambda () (format *query-io* "~@<Specify ~ source (not ~ evaluated): ~@:>") (force-output *query-io*) (list (read *query-io*))) (setf source new-value)))))) (defmethod open-bag ((source stream) &rest args &key location (direction (missing-required-argument :direction)) (backend (missing-required-argument :backend)) (flush-strategy nil) (bag-class 'bag) transform) (check-type direction direction "either :input, :output or :io") (check-type transform transform-spec "a transformation specification") (when (and flush-strategy (eq direction :input)) (incompatible-arguments :direction direction :flush-strategy flush-strategy)) (let ((backend (apply #'rsbag.backend:make-backend backend :stream source :location location :direction direction (append (when flush-strategy (list :flush-strategy (apply #'rsbag.backend:make-flush-strategy (ensure-list flush-strategy)))) (remove-from-plist args :direction :backend :flush-strategy :bag-class :transform))))) (make-instance bag-class :backend backend :direction direction :transform transform))) (defmethod open-bag ((source pathname) &rest args &key (location source) (direction :io) (if-exists :error) (backend nil backend-supplied?)) (let* ((backend (cond (backend-supplied? backend) ((not (stringp (pathname-type source))) (error "~@<Cannot guess file format because ~A is ~ missing a type component.~@:>" source)) (t (make-keyword (string-upcase (pathname-type source)))))) (stream (open source :element-type '(unsigned-byte 8) :direction direction :if-exists if-exists :if-does-not-exist (case direction (:input :error) ((:output :io) :create))))) (apply #'open-bag stream :location location :direction direction :backend backend (remove-from-plist args :location :direction :if-exists :backend)))) (defmethod open-bag ((source string) &rest args &key &allow-other-keys) (apply #'open-bag (parse-namestring source) args)) ;;; Bag protocol (defgeneric bag-location (bag) (:documentation "Return an object representing the location of BAG. Possible values include (but are not limited to) NIL and `cl:pathname' objects.")) (defgeneric bag-direction (bag) (:documentation "Return the direction of BAG. One of :input, :output, :io.")) (defgeneric bag-transform (bag) (:documentation "Return the transform specification associated to BAG. The specification is used to make concrete transformations for all channels of BAG.")) (defgeneric bag-channels (bag) (:documentation "Return a list of the `channel's stored in BAG.")) (defgeneric bag-channel (bag name &key if-does-not-exist) (:documentation "Return the `channel' named NAME in BAG. IF-DOES-NOT-EXIST controls the behavior in case the requested channel does not exist. If a function designator (like the default 'error) is supplied, the function is called with an instance of the `no-such-channel' condition class. Values of other types are returned instead of the missing channel. In case IF-DOES-NOT-EXIST is a function designator, a `create' restart with lambda list (meta-data &key transform) is established for the duration of the call to IF-DOES-NOT-EXIST.")) (defgeneric (setf bag-channel) (spec bag name &key if-exists transform) (:documentation "Add or update and return the channel named NAME in BAG. SPEC is a plist which specifies properties of the created or updated channel. IF-EXISTS controls the behavior in case a channel named NAME already exists in BAG. Valid values are :error, which causes an error to be signaled, and :supersede, which causes the existing channel to be updated. TRANSFORM can be used to specify a transformation that should be applied to all value read from/written to the channel. Valid values are nil or an object implementing the transform protocol specified in rsbag.transform.")) (defgeneric bag-channel-class (bag) (:documentation "Return the channel class used by BAG.")) ;;; Bag behind-the-scenes protocol ;) (defgeneric %make-channel (bag name meta-data transform &rest args &key id &allow-other-keys) (:documentation "Create and return a new channel named NAME with id ID and associated meta-data META-DATA and TRANSFORM for BAG. The returned object implements the channel protocol. TRANSFORM can be nil in which case raw data from the underlying source is used. ARGS are passed to the constructed channel.")) (defgeneric %make-channel-transform (bag name meta-data &key id spec) (:documentation "Make and return a suitable transformation for the channel in BAG described by NAME, META-DATA, ID and SPEC. SPEC can be used to specify additional parameters for the constructed transformation or to specify an entirely different transformation. See the type `transform-spec'.")) ;;; Channel protocol (defgeneric channel-bag (channel) (:documentation "Return the bag containing CHANNEL.")) (defgeneric channel-name (channel) (:documentation "Return the name of CHANNEL.")) (defgeneric channel-transform (channel) (:documentation "Return the transformation applied to each datum retrieved from CHANNEL.")) (defgeneric channel-meta-data (channel) (:documentation "Return the meta-data associated to CHANNEL as plist.")) (defgeneric channel-timestamps (channel) (:documentation "Return a sequence of `local-time:timestamp' objects representing the points in time for which CHANNEL contains entries.")) (defgeneric channel-timestamps/raw (channel) (:documentation "Return a sequence of integers representing the points in time for which CHANNEL contains entries. The timestamps correspond to elapsed time since UNIX epoch in nanoseconds.")) (defgeneric channel-entries (channel) (:documentation "Return a sequence of the entries of CHANNEL.")) (defgeneric channel-items (channel) (:documentation "Return a sequence of elements of the form (TIMESTAMP ENTRY) for the timestamps and associated entries of CHANNEL.")) (defgeneric entry (channel index &key if-does-not-exist transform) (:documentation "Return the entry at position or time INDEX in CHANNEL. If INDEX is an integer, the INDEX-th entry is returned. If INDEX is a `local-time:timestamp' instances, the entry stored for the point in time represented by INDEX is returned. IF-DOES-NOT-EXIST controls the behavior in case there is no entry for INDEX. Valid values are nil, which causes nil to be returned and :error, which causes an error to be signaled. TRANSFORM controls the transformation applied to the retrieved entry before returning it. It defaults to CHANNEL's transform.")) (defgeneric (setf entry) (new-value channel index &key if-exists transform) (:documentation "Store NEW-VALUE as the value of the entry at position or time INDEX in CHANNEL. If INDEX is an integer, NEW-VALUE is stored as the INDEX-th entry. If INDEX is a `local-time:timestamp' instances, the NEW-VALUE is stored for the point in time represented by INDEX. IF-EXISTS controls the behavior in case an entry is already stored at INDEX. Valid values are :error, which causes an error to be signaled, and :supersede, which causes the stored value to be replaced. TRANSFORM controls the transformation applied to NEW-VALUE before storing it. It defaults to CHANNEL's transform.")) ;; When available, channels additionally implement the sequence ;; protocol such that the channel appears as a sequence of its ;; entries. ;;; Time range protocol ;;; ;;; Applicable to at least channels and whole bags. (defgeneric start-timestamp (bag-or-channel) (:documentation "Return the earliest timestamp for which an entry exists in BAG-OR-CHANNEL.")) (defgeneric end-timestamp (bag-or-channel) (:documentation "Return the earliest timestamp for which an entry exists in BAG-OR-CHANNEL."))
12,296
Common Lisp
.lisp
274
33.313869
77
0.600502
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
ee62ba8d7f6a2ac0d83e792aa74fbfecce36b8b4cb73502abc9078704cafdcae
37,690
[ -1 ]
37,691
synchronized-bag.lisp
open-rsx_rsbag-cl/src/synchronized-bag.lisp
;;;; synchronized-bag.lisp --- A bag that synchronizes accesses. ;;;; ;;;; Copyright (C) 2011-2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag) (defclass synchronized-bag (bag) ((lock :reader bag-%lock :initform (bt:make-lock "Bag lock") :documentation "The lock that is used to synchronized accesses to the bag.")) (:documentation "Instances of this bag class can be safely used from multiple threads. Callers have to be prepared to encounter increased latencies in comparison to the single-threaded case.")) (macrolet ((define-synchronized-method (name args) `(defmethod ,name :around ,args (bt:with-lock-held ((bag-%lock bag)) (call-next-method))))) (define-synchronized-method close ((bag synchronized-bag) &key &allow-other-keys)) (define-synchronized-method bag-channels ((bag synchronized-bag))) (define-synchronized-method bag-channel ((bag synchronized-bag) (name t) &key &allow-other-keys)) (define-synchronized-method (setf bag-channel) ((new-value t) (bag synchronized-bag) (name t) &key &allow-other-keys))) (defmethod bag-channel-class ((bag synchronized-bag)) (load-time-value (find-class 'synchronized-channel) t)) (defmethod %make-channel ((bag synchronized-bag) (name string) (meta-data list) (transform t) &rest args &key) (apply #'call-next-method bag name meta-data transform (append (list :lock (bag-%lock bag)) args)))
1,717
Common Lisp
.lisp
45
30.688889
64
0.623049
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
a3820066b44b5037b870ebe9767906a409aa0758afc466588af00c17194f857b
37,691
[ -1 ]
37,692
types.lisp
open-rsx_rsbag-cl/src/types.lisp
;;;; types.lisp --- Types used in the rsbag system. ;;;; ;;;; Copyright (C) 2011-2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag) ;;; Bag opening and entry reading/writing options (deftype direction () "Values of this type are used to indicate whether a bag should be opened for reading, writing or both." '(member :input :output :io)) (deftype if-does-not-exist-policy () "Possible actions to execute if a requested object does not exist." '(member nil :error)) (deftype if-exists-policy () "Possible actions to execute if an object should be stored in location that is already occupied." '(member :error :supersede)) ;;; Transformation specifications (deftype transform-spec/default () "This transform specification causes the default transformation to be applied." 'null) (deftype transform-spec/augment () "This transform specification causes supplied arguments to be appended when the default transformation is constructed." '(cons (eql &from-source) list)) (deftype transform-spec/full () "This transform specification cases the a specific transform to be constructed with supplied arguments without automatic derivation." '(cons (and symbol (not (eql &from-source))) list)) (deftype transform-spec () "All forms of transform specifications." '(or transform-spec/default transform-spec/augment transform-spec/full))
1,450
Common Lisp
.lisp
36
37.388889
69
0.750712
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
177d78258574a6afce28e670dd4e167f74e509bb900f2f8cb914a635e3407336
37,692
[ -1 ]
37,693
reloading.lisp
open-rsx_rsbag-cl/src/reloading.lisp
;;;; reloading.lisp --- Support for image dumping and reloading. ;;;; ;;;; Copyright (C) 2013, 2015 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag) ;; Make sure that the rsbag threadpool is shutdown when dumping an ;; image and restarted when restoring an image. (uiop:register-image-dump-hook 'stop-threadpool nil) (uiop:register-image-restore-hook 'start-threadpool nil)
432
Common Lisp
.lisp
10
41.9
66
0.754177
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
6e2761858d4ac9a5ae61c8b533e37e27ec65d4d6e66a9edfd0bf1040a813c38c
37,693
[ -1 ]
37,694
builder.lisp
open-rsx_rsbag-cl/src/builder.lisp
;;;; builder.lisp --- (un-)build protocol for bags and channels. ;;;; ;;;; Copyright (C) 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.builder (:use #:cl #:alexandria #:let-plus #:architecture.builder-protocol #:rsbag) (:export #:unbuilder) (:documentation "Support of the (un-)build protocol for rsbag objects.")) (cl:in-package #:rsbag.builder) ;;; Customizable unbuilder (defclass unbuilder (print-items:print-items-mixin) ((initarg-if-missing :initarg :initarg-if-missing :reader unbuilder-initarg-if-missing :initform :omit :documentation "A value that should be used in place of missing initarg values or the symbol :omit to omit the initargs entirely.") (compute-sizes? :initarg :compute-sizes? :reader unbuilder-compute-sizes? :initform nil :documentation "Should the size in octets of the data contained in each channel be computed?") (format? :initarg :format? :reader unbuilder-format? :initform nil :documentation "Should the format information associated to channels be traversed?")) (:documentation "Specialized builder for providing information about `bag' and `channel' instances.")) (defmethod print-items:print-items append ((object unbuilder)) (let+ (((&structure-r/o unbuilder- initarg-if-missing compute-sizes? format?) object)) `((:initarg-if-missing ,initarg-if-missing "~S") (:compute-sizes? ,compute-sizes? "~@[ sizes~]" ((:after :initarg-if-missing))) (:format? ,format? "~@[ format ~S~]" ((:after :compute-sizes?)))))) (defmethod wrap ((builder unbuilder) (thunk t)) (call-with-channel-data-size-cache (lambda () (call-next-method)))) ;;; Bag (defmethod node-kind ((builder unbuilder) (node bag)) 'rsbag:bag) (defmethod node-initargs ((builder unbuilder) (node bag)) (let+ (((&structure-r/o unbuilder- initarg-if-missing compute-sizes?) builder) ((&structure-r/o bag- location channels) node) (count (reduce #'+ channels :key #'length))) (list* :location location (append (when compute-sizes? (list :data-size (reduce #'+ (bag-channels node) :key #'channel-data-size))) (count-and-timing-initargs node count :if-missing initarg-if-missing))))) (defmethod node-relations ((builder unbuilder) (node bag)) '((:channel . (:map . :name)))) (defmethod node-relation ((builder unbuilder) (relation (eql :channel)) (node bag)) (let ((channels (bag-channels node))) (values channels (mapcar (lambda (channel) (list :name (channel-name channel))) channels)))) ;;; Channel (defmethod node-kind ((builder unbuilder) (node channel)) 'rsbag:channel) (defmethod node-initargs ((builder unbuilder) (node channel)) (let+ (((&structure-r/o unbuilder- initarg-if-missing compute-sizes?) builder)) (list* :name (channel-name node) (append (when compute-sizes? (list :data-size (channel-data-size node))) (count-and-timing-initargs node (length node) :if-missing initarg-if-missing))))) (defmethod node-relations ((builder unbuilder) (node channel)) (let+ (((&structure-r/o unbuilder- format?) builder) (meta-data (channel-meta-data node))) `(,@(when (getf meta-data :type) '((:type . 1))) ,@(when (and format? (getf meta-data :format)) '((:format . 1)))))) (defmethod node-relation ((builder unbuilder) (relation (eql :type)) (node channel)) (getf (channel-meta-data node) :type)) (defmethod node-relation ((builder unbuilder) (relation (eql :format)) (node channel)) (getf (channel-meta-data node) :format)) ;;; Default methods (defvar *default-unbuilder* (make-instance 'unbuilder)) (macrolet ((define-delegating-methods (class) `(progn (defmethod node-kind ((builder t) (node ,class)) (node-kind *default-unbuilder* node)) (defmethod node-initargs ((builder t) (node ,class)) (node-initargs *default-unbuilder* node)) (defmethod node-relations ((builder t) (node ,class)) (node-relations *default-unbuilder* node)) (defmethod node-relation ((builder t) (relation t) (node ,class)) (node-relation *default-unbuilder* relation node))))) (define-delegating-methods bag) (define-delegating-methods channel)) ;;; Utilities (defun count-and-timing-initargs (thing count &key if-missing) (let+ (((&accessors-r/o (start start-timestamp) (end end-timestamp)) thing) (emit-missing? (not (eq if-missing :omit))) (duration (when (and start end) (local-time:timestamp-difference end start))) (rate (when (and duration (plusp duration)) (/ count duration)))) (append (list :event-count count) (when (or start emit-missing?) (list :start (or start if-missing))) (when (or end emit-missing?) (list :end (or end if-missing))) (when (or duration emit-missing?) (list :duration (or duration if-missing))) (when (or rate emit-missing?) (list :rate (or rate if-missing)))))) (defvar *channel-data-size-cache* nil) (defun call-with-channel-data-size-cache (function) (let ((*channel-data-size-cache* (make-hash-table :test #'eq))) (funcall function))) (defun channel-data-size (channel) (values (ensure-gethash channel *channel-data-size-cache* (reduce #'+ channel :key #'length))))
6,504
Common Lisp
.lisp
144
33.916667
77
0.563685
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
876d5ef1ab64eeb0bace95549ad968f2e19901e68b1e490e03f5e15c88308833
37,694
[ -1 ]
37,695
synchronized-channel.lisp
open-rsx_rsbag-cl/src/synchronized-channel.lisp
;;;; synchronized-channel.lisp --- A channel that synchronizes accesses. ;;;; ;;;; Copyright (C) 2011, 2012, 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag) (defclass synchronized-channel (channel) ((lock :initarg :lock :accessor channel-%lock :documentation "The lock that is used to synchronize accesses to the channel. Usually points to a lock owned by the containing bag.")) (:default-initargs :lock (missing-required-initarg 'synchronized-channel :lock)) (:documentation "Instances of this channel class can be safely used from multiple threads. Callers have to be prepared to encounter increased latencies in comparison to the single-threaded case.")) (macrolet ((define-synchronized-method (name args) `(defmethod ,name :around ,args (bt:with-lock-held ((channel-%lock channel)) (call-next-method))))) (define-synchronized-method channel-timestamps ((channel synchronized-channel))) (define-synchronized-method entry ((channel synchronized-channel) (index t) &key &allow-other-keys)) (define-synchronized-method (setf entry) ((new-value t) (channel synchronized-channel) (index t) &key &allow-other-keys)))
1,415
Common Lisp
.lisp
35
32.828571
72
0.649237
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
3407cd14b114aec4564a465879d01441566e52a6c90c0308fc6340415b98256e
37,695
[ -1 ]
37,696
conditions.lisp
open-rsx_rsbag-cl/src/conditions.lisp
;;;; conditions.lisp --- Conditions used in the rsbag system. ;;;; ;;;; Copyright (C) 2011-2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag) (define-condition rsbag-condition (condition) () (:documentation "This condition class is intended to be mixed into all rsbag-related condition classes.")) (define-condition rsbag-problem-condition (rsbag-condition) () (:documentation "This condition class is intended to be mixed into all rsbag-related problem (e.g. warning and error) condition classes.")) (define-condition rsbag-error (error rsbag-problem-condition) () (:documentation "This condition class is intended to be mixed into all rsbag-related error condition classes.")) (define-condition open-error (rsbag-error chainable-condition) ((source :initarg :source :reader open-error-source :documentation "Stores the source from which the bag could not be opened.")) (:report (lambda (condition stream) (format stream "~@<Failed to open bag in source ~ ~A.~/more-conditions:maybe-print-cause/~@:>" (open-error-source condition) condition))) (:default-initargs :source (missing-required-initarg 'open-error :source)) (:documentation "This error is signaled if a bag, stored in a specific source, cannot be opened.")) (define-condition bag-condition (rsbag-condition) ((bag :initarg :bag :reader bag-condition-bag :documentation "The bag instance in the context of which the error occurred.")) (:default-initargs :bag (missing-required-initarg 'bag-condition :bag)) (:documentation "Subclasses of this class are signaled when an error can be associated to a specific bag.")) (define-condition no-such-channel (rsbag-error bag-condition) ((name :initarg :name :type string :reader no-such-channel-name :documentation "Stores the name of the channel that has been requested.")) (:report (lambda (condition stream) (format stream "~@<There is no channel named ~S in the bag ~ ~A~@:>" (no-such-channel-name condition) (bag-condition-bag condition)))) (:default-initargs :name (missing-required-initarg 'no-such-channel :name)) (:documentation "This error is signaled when a requested channel does not exist within a bag an cannot or may not be created.")) (define-condition direction-error (rsbag-error bag-condition) ((expected-direction :initarg :expected-direction :type (or direction cons) :reader direction-error-expected-direction :documentation "Stores the expected direction or directions.")) (:report (lambda (condition stream) (let+ (((&accessors-r/o (bag bag-condition-bag) (expected-direction direction-error-expected-direction)) condition) (actual-direction (bag-direction bag))) (format stream "~@<The bag ~A has not been opened with ~ direction ~A (but ~A).~@:>" bag expected-direction actual-direction)))) (:default-initargs :expected-direction (missing-required-initarg 'direction-error :expected-direction)) (:documentation "This error is signaled when an attempt is made to access a bag with a direction for which it has not been opened.")) (define-condition channel-condition (bag-condition) ((channel :initarg :channel :reader channel-condition-channel :documentation "Stores the channel in the context of which the error occurred.")) (:default-initargs :channel (missing-required-initarg 'channel-condition :channel)) (:documentation "Subclasses of this class are signaled when an error can be associated to a specific channel within a bag.")) (define-condition channel-open-error (rsbag-error channel-condition chainable-condition) () (:report (lambda (condition stream) (format stream "~@<Could not open channel ~S in bag ~ ~A~/more-conditions:maybe-print-cause/~@:>" (channel-condition-channel condition) (bag-condition-bag condition) condition))) (:documentation "This error is signaled when an existing channel cannot be opened.")) (define-condition channel-exists (rsbag-error channel-condition) () (:report (lambda (condition stream) (format stream "~@<The channel ~A already exists in bag ~A.~@:>" (channel-condition-channel condition) (bag-condition-bag condition)))) (:documentation "This error is signaled when a channel cannot be created because it already exists.")) (define-condition no-such-entry (rsbag-error channel-condition) ((key :initarg :key :reader no-such-entry-key :documentation "Stores the key for which no entry could be found in the channel and bag in question.")) (:report (lambda (condition stream) (format stream "~@<No entry could be found for key ~S in the ~ channel ~A of bag ~A~@:>" (bag-condition-bag condition) (channel-condition-channel condition) (no-such-entry-key condition)))) (:default-initargs :key (missing-required-initarg 'no-such-entry :key)) (:documentation "This error is signaled if a specified entry cannot be found in a channel."))
6,015
Common Lisp
.lisp
149
31.483221
70
0.621285
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
bd645da2b39ce7611f107d7408e75a8fae4245964aa5852fc7c2402ee139d926
37,696
[ -1 ]
37,697
threadpool.lisp
open-rsx_rsbag-cl/src/threadpool.lisp
;;;; threadpool.lisp --- A threadpool for async rsbag operations. ;;;; ;;;; Copyright (C) 2013, 2015 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag) (defvar *threadpool* nil "When non-nil, holds the threadpool used by the rsbag system.") (defun start-threadpool () "Create and initialize a threadpool for use by the rsbag system." (when *threadpool* (warn "~@<Threadpool already initialized to ~A.~@:>" *threadpool*)) (setf *threadpool* (lparallel:make-kernel 2 :name "rsbag"))) (defun stop-threadpool () "Stop all threads of the threadpool used by the rsbag system." (let ((lparallel:*kernel* *threadpool*)) (mapc #'bt:join-thread (lparallel:end-kernel :wait t))) (setf *threadpool* nil)) (defmacro with-threadpool (&body body) "Execute BODY such that created tasks use the rsbag threadpool and errors are transferred." `(let ((lparallel:*kernel* *threadpool*)) (lparallel:task-handler-bind ((error #'lparallel:invoke-transfer-error)) ,@body))) ;; Start the threadpool when loading or executing this. It may have to ;; be stopped and restarted when saving an image. See reloading.lisp. (unless *threadpool* (start-threadpool))
1,243
Common Lisp
.lisp
29
39.827586
77
0.716887
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
9e522fdc8a188de153316d9185faa14c360b3ca4d24aa894e954136070cc9ac9
37,697
[ -1 ]
37,698
macros.lisp
open-rsx_rsbag-cl/src/macros.lisp
;;;; macros.lisp --- Convenience macros provided by the rsbag system. ;;;; ;;;; Copyright (C) 2011-2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag) (defun call-with-open-bag (bag thunk) "Call THUNK with BAG as the sole argument. Close BAG when THUNK returns or a control transfer occurs." (unwind-protect (funcall thunk bag) (close bag))) (defmacro with-open-bag ((var bag) &body body) "Execute BODY with VAR bound to BAG. The bag is closed when BODY finishes or a control transfer occurs." (check-type var symbol "a symbol") `(flet ((with-open-bag-thunk (,var) ,@body)) (declare (dynamic-extent #'with-open-bag-thunk)) (call-with-open-bag ,bag #'with-open-bag-thunk))) (defmacro with-bag ((var source &rest args &key &allow-other-keys) &body body) "Execute BODY with VAR bound to a bag object for the data source SOURCE. ARGS are passed to `open-bag'." (check-type var symbol "a symbol") `(with-open-bag (,var (open-bag ,source ,@args)) ,@body))
1,079
Common Lisp
.lisp
25
39.28
69
0.687023
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
229714d1d73d81408081f70c0bef5e729ff73c69a73936320166047776625cea
37,698
[ -1 ]
37,699
bag.lisp
open-rsx_rsbag-cl/src/bag.lisp
;;;; bag.lisp --- The bag class represent data channels stored in a file. ;;;; ;;;; Copyright (C) 2011-2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag) (defclass bag (print-items:print-items-mixin) ((direction :initarg :direction :type direction :reader bag-direction :documentation "Stores the direction of the bag.") (backend :initarg :backend :reader bag-%backend :documentation "Stores an object which is responsible for accessing the stream associated to this bag.") (transform :initarg :transform :type transform-spec :reader bag-transform :accessor bag-%transform :initform '(&from-source) :documentation "Stores a specification for transformations that should be associated with channels of the bag. See type `transform-spec'.") (channels :type hash-table :reader bag-%channels :initform (make-hash-table :test #'equal) :documentation "Stores a mapping of channel names to `channel' instances.")) (:default-initargs :direction (missing-required-initarg 'bag :direction) :backend (missing-required-initarg 'bag :backend)) (:documentation "Instances of this class represent a log file. A log file consists of named channels which can be retrieved using the `bag-channels' and `bag-channel' methods and modified using the `(setf bag-channel)' method.")) (defmethod shared-initialize :after ((instance bag) (slot-names t) &key) (let+ (((&structure-r/o bag- (backend %backend) (transform %transform) (channels %channels)) instance) ((&flet make-transform (name meta-data id) (%make-channel-transform instance name meta-data :id id :spec transform)))) (iter (for (id name meta-data) in (rsbag.backend:get-channels backend)) (setf (gethash name channels) (%make-channel instance name meta-data (make-transform name meta-data id) :id id))))) (defmethod print-items:print-items append ((object bag)) (let+ (((&structure-r/o bag- location direction (channels %channels)) object) (channel-count (hash-table-count channels))) `((:location ,location "~/rsbag:print-location/") (:direction ,direction " ~/rsbag:print-direction/" ((:after :location))) (:channel-count ,channel-count " (~:D)" ((:after :direction)))))) (defmethod close ((bag bag) &key &allow-other-keys) (close (bag-%backend bag))) (defmethod bag-location ((bag bag)) (rsbag.backend:backend-location (bag-%backend bag))) (defmethod bag-channels ((bag bag)) (hash-table-values (bag-%channels bag))) (flet ((add-channel (bag name meta-data transform transform-supplied?) ;; If META-DATA does not have a type, but TRANSFORM is ;; non-nil, augment the meta-data with TRANSFORM's type. Make ;; a channel instance and store it. (let+ (((&structure-r/o bag- (channels %channels) (backend %backend)) bag) (transform (if transform-supplied? transform (%make-channel-transform bag name meta-data :spec (bag-transform bag)))) (meta-data (if (and transform (not (getf meta-data :type))) (let ((name (rsbag.transform:transform-name transform))) (list* :type name meta-data)) meta-data)) (channel (%make-channel bag name meta-data transform))) (rsbag.backend:put-channel backend (channel-%id channel) name meta-data) (setf (gethash name channels) channel)))) (defmethod bag-channel ((bag bag) (name string) &key (if-does-not-exist #'error)) (or (gethash name (bag-%channels bag)) (error-behavior-restart-case (if-does-not-exist (no-such-channel :bag bag :name name)) (create (meta-data &key (transform nil transform-supplied?)) (add-channel bag name meta-data transform transform-supplied?))))) (defmethod (setf bag-channel) ((new-value list) (bag bag) (name string) &key (if-exists :error) (transform nil transform-supplied?)) ;; If a channel named NAME already exists, apply IF-EXISTS policy. (when-let ((channel (gethash name (bag-%channels bag)))) (ecase if-exists (:error (error 'channel-exists :bag bag :channel channel)) (:supersede (error "Superseding not implemented")))) ; TODO(jmoringe): implement (add-channel bag name new-value transform transform-supplied?))) (defmethod (setf bag-channel) :before ((new-value t) (bag t) (name t) &key &allow-other-keys) (unless (member (bag-direction bag) '(member :output :io)) (error 'direction-error :bag bag :expected-direction '(member :output :io)))) ;;; Time range protocol (macrolet ((define-bound-method (name comparator) `(defmethod ,name ((bag bag)) (flet ((safe-compare (left right) (cond ((not left) right) ((not right) left) ((,comparator left right) left) (t right)))) (reduce #'safe-compare (bag-channels bag) :key (function ,name) :initial-value nil))))) (define-bound-method start-timestamp local-time:timestamp<) (define-bound-method end-timestamp local-time:timestamp>)) ;;; (defmethod bag-channel-class ((bag bag)) (find-class 'channel)) (defmethod %make-channel ((bag bag) (name string) (meta-data list) (transform t) &rest args &key id) (let+ (((&structure-r/o bag- (backend %backend) channel-class) bag)) (with-condition-translation (((error channel-open-error) :bag bag :channel name)) (apply #'make-instance channel-class :bag bag :name name :transform transform :id (or id (rsbag.backend:make-channel-id backend name)) :meta-data meta-data :backend backend (remove-from-plist args :id))))) (defmethod %make-channel-transform ((bag bag) (name string) (meta-data list) &key id spec) "Use SPEC and, optionally the :type entry of META-DATA to determine the appropriate transform for the channel designated by NAME. SPEC can be of the following types: `transform-spec/default' Use the :type entry of META-DATA to determine the appropriate transform. `transform-spec/augment' Append to the :type entry of META-DATA the remainder of SPEC. This will instantiate the transform class specified by the :type entry, but append initargs given in SPEC. `transform-spec/full' Use the contents of SPEC as class name and initargs to instantiate the transform class. Ignore :type entry of META-DATA." (declare (ignore id)) (with-condition-translation (((error channel-open-error) :bag bag :channel name)) (restart-case (let+ (((&plist-r/o (type :type)) meta-data) ((&flet parse-type () (typecase type (null (list nil)) (list type) (t (ensure-list type))))) ((class-name &rest args) (etypecase spec ;; No spec - derive everything from TYPE. (transform-spec/default (parse-type)) ;; Spec with &FROM-SOURCE - append rest of SPEC to ;; information derived from TYPE. (transform-spec/augment (append (parse-type) (rest spec))) ;; Spec without &FROM-SOURCE - ignore TYPE and use ;; supplied SPEC unmodified. (transform-spec/full spec) ;; A function - call it. (function (funcall spec bag name meta-data))))) (when class-name (apply #'rsbag.transform:make-transform class-name args))) (continue (&optional condition) :report (lambda (stream) (format stream "~@<Do not transform events in ~ channel ~A.~@:>" name)) (declare (ignore condition))) (use-value (transform) :report (lambda (stream) (format stream "~@<Use the supplied transform for ~ events in channel ~S.~@:>" name)) transform))))
10,246
Common Lisp
.lisp
218
31.940367
90
0.511102
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
1e43696bb88136c5e6a12bc99dc036c2a89e5f8aad213a42368e7e2c55e67497
37,699
[ -1 ]
37,700
channel.lisp
open-rsx_rsbag-cl/src/channel.lisp
;;;; channel.lisp --- The channel class represents a time-series of homogeneous data. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag) (defclass channel (plist-meta-data-mixin #+sbcl sequence print-items:print-items-mixin) ((bag :initarg :bag :reader channel-bag :documentation "Stores the bag instance in which this channel is contained.") (name :initarg :name :type string :reader channel-name :documentation "Stores the name of the channel.") (meta-data :reader channel-meta-data) (transform :initarg :transform :reader channel-transform :initform nil :documentation "Stores a transformation that should be applied to entries when they are retrieved or stored.") (id :initarg :id :reader channel-%id :documentation "Stores the id of the channel.") (backend :initarg :backend :reader channel-%backend :documentation "Stores a reference to the backend object which implements access to the bag to which this channel belongs.")) (:default-initargs :bag (missing-required-initarg 'channel :bag) :name (missing-required-initarg 'channel :name) :id (missing-required-initarg 'channel :id) :backend (missing-required-initarg 'channel :backend)) (:documentation "Instances of this class represent time-series of homogeneous data items.")) (defmethod print-items:print-items append ((object channel)) (let+ (((&structure-r/o channel- name transform) object) (length (length object)) (transform (when transform (rsbag.transform:transform-name transform)))) `((:name ,name "~S") (:length ,length " (~:D)" ((:after :name))) (:transform ,transform "~@[ ~A~]" ((:after :length)))))) (defmethod channel-timestamps/raw ((channel channel)) (let+ (((&structure-r/o channel- (id %id) (backend %backend)) channel)) (rsbag.backend:get-timestamps backend id))) (defmethod channel-timestamps ((channel channel)) (make-instance 'channel-timestamps :timestamps (channel-timestamps/raw channel))) #+sbcl (defmethod channel-entries ((channel channel)) ;; Since CHANNEL is a sequence of its entries, nothing has to be ;; done. channel) #+sbcl (defmethod channel-items ((channel channel)) ;; Return an instance of `channel-items' which presents pairs of ;; timestamps and entries. (make-instance 'channel-items :channel channel)) (defmethod entry :around ((channel channel) (index t) &key (if-does-not-exist nil) (transform (channel-transform channel))) (check-type if-does-not-exist if-does-not-exist-policy) (call-next-method channel index :if-does-not-exist if-does-not-exist :transform transform)) (flet ((return-entry (channel index entry if-does-not-exist transform) (let ((raw (or entry (ecase if-does-not-exist (:error (error 'no-such-entry :bag (channel-bag channel) :channel channel :key index)) ((nil) nil))))) (if transform (rsbag.transform:decode transform raw) raw)))) (declare (inline return-entry)) (defmethod entry ((channel channel) (index integer) &key if-does-not-exist transform) (let+ (((&structure-r/o channel- (id %id) (backend %backend)) channel) (raw (rsbag.backend:get-entry-at-index backend id index))) (return-entry channel index raw if-does-not-exist transform))) (defmethod entry ((channel channel) (index local-time:timestamp) &key if-does-not-exist transform) (let+ (((&structure-r/o channel- (id %id) (backend %backend)) channel) (timestamp (rsbag.backend:timestamp->uint64 index)) (raw (rsbag.backend:get-entry-at-time backend id timestamp))) (return-entry channel index raw if-does-not-exist transform)))) (defmethod (setf entry) :around ((new-value t) (channel channel) (index t) &key (if-exists :error) (transform (channel-transform channel))) (check-type if-exists if-exists-policy) (when (eq if-exists :supersede) (error "Superseding entries is not supported yet")) (unless (member (bag-direction (channel-bag channel)) '(:output :io)) (error 'direction-error :bag (channel-bag channel) :expected-direction '(member :output :io))) (call-next-method new-value channel index :if-exists if-exists :transform transform)) (defmethod (setf entry) ((new-value t) (channel channel) (index local-time:timestamp) &key if-exists transform) (declare (ignore if-exists)) (let+ (((&structure-r/o channel- (id %id) (backend %backend)) channel) (timestamp (rsbag.backend:timestamp->uint64 index)) (raw (if transform (rsbag.transform:encode transform new-value) new-value))) (rsbag.backend:put-entry backend id timestamp raw) new-value)) ;;; Time range protocol (defmethod start-timestamp ((channel channel)) (unless (emptyp channel) (elt (channel-timestamps channel) 0))) (defmethod end-timestamp ((channel channel)) (unless (emptyp channel) (elt (channel-timestamps channel) (1- (length channel))))) ;;; Sequence protocol #+sbcl (defmethod sequence:length ((sequence channel)) (let+ (((&structure-r/o channel- (id %id) (backend %backend)) sequence)) (rsbag.backend:get-num-entries backend id))) #+sbcl (defmethod sequence:make-sequence-like ((sequence channel) (length integer) &rest args &key initial-element initial-contents) (declare (ignore initial-element initial-contents)) (apply #'make-array length args)) #+sbcl (defmethod sequence:elt ((sequence channel) (index integer)) (entry sequence index)) ;;; `channel-timestamps' sequence class #+sbcl (defclass channel-timestamps (standard-object sequence) ((timestamps :initarg :timestamps :accessor %timestamps :documentation "Stores the sequence of associated timestamps for the entries of the channel.")) (:default-initargs :timestamps (missing-required-initarg 'channel-timestamps :timestamps)) (:documentation "A sequence of timestamps for the entries of a channel.")) #+sbcl (defmethod sequence:length ((sequence channel-timestamps)) (length (%timestamps sequence))) #+sbcl (defmethod sequence:elt ((sequence channel-timestamps) (index integer)) (rsbag.backend:uint64->timestamp (elt (%timestamps sequence) index))) ;;; `channel-items' sequence class #+sbcl (defclass channel-items (standard-object sequence) ((channel :initarg :channel :reader %channel :documentation "Stores the channel the items of which are used.") (timestamps :accessor %timestamps :documentation "Stores the sequence of associated timestamps for the entries of the channel.")) (:default-initargs :channel (missing-required-initarg 'channel-items :channel)) (:documentation "Instances of this class can be used to access the timestamps and associated entries of a channel.")) #+sbcl (defmethod shared-initialize :after ((instance channel-items) (slot-names t) &key channel) (setf (%timestamps instance) (channel-timestamps/raw channel))) #+sbcl (defmethod sequence:length ((sequence channel-items)) (length (%channel sequence))) #+sbcl (defmethod sequence:elt ((sequence channel-items) (index integer)) (let+ (((&accessors-r/o (channel %channel) (timestamps %timestamps)) sequence)) (list (rsbag.backend:uint64->timestamp (elt timestamps index)) (elt channel index))))
9,133
Common Lisp
.lisp
207
33.028986
85
0.582434
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
7a8160cd95d5b8657e6665d56aea2f16ba422db06b092ce74d5b5f4fa9f54e00
37,700
[ -1 ]
37,701
versioned-packages.lisp
open-rsx_rsbag-cl/src/versioned-packages.lisp
;;;; versioned-packages.lisp --- Management of multiple versions of packages. ;;;; ;;;; Copyright (C) 2012, 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag) (defun make-versioned-name (name version) "Return a keyword consisting of NAME and VERSION." (format-symbol :keyword "~A-~A" name version)) (defmacro with-renamed-package ((old-name new-name &optional (temp-name (format nil "~A-TEMP" old-name))) &body body) "Execute BODY with the package designated by OLD-NAME moved out of the way, then rename the package designated by OLD-NAME to NEW-NAME. This allows BODY to seemingly load stuff into OLD-NAME which will end up in NEW-NAME without disturbing the contents of OLD-NAME." (with-unique-names (package) `(let ((,package (find-package ,old-name))) (%maybe-delete-package ,new-name) (%maybe-delete-package ,temp-name) (when ,package (rename-package ,package ,temp-name)) (unwind-protect (prog1 ,@body (rename-package (find-package ,old-name) ,new-name)) (%maybe-delete-package ,old-name) (when ,package (rename-package ,package ,old-name)))))) (defmacro with-renamed-packages ((&rest renames) &body body) "Execute BODY with multiple renamings in the sense of `with-renamed-package'. RENAMES is a list of items of the form (OLD-NAME NEW-NAME) ." (labels ((wrap (renames body) (if renames `(with-renamed-package ,(first renames) ,(wrap (rest renames) body)) `(progn ,@body)))) (wrap renames body))) (defmacro with-versioned-packages ((version &rest packages) &body body) "Execute body with certain package renamings in the sense of `with-renamed-packages'. PACKAGES are renamed to names suffixed with VERSION." (check-type version string) (flet ((without-and-with-version (name) (list name (make-versioned-name name version)))) `(with-renamed-packages ,(mapcar #'without-and-with-version packages) ,@body))) ;;; Utility functions (defun %maybe-delete-package (designator) "If DESIGNATOR designates a package, delete it." (when (find-package designator) (delete-package designator)))
2,415
Common Lisp
.lisp
56
35.553571
77
0.647084
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
4af4dc0f306e487e0e348035de274124e6c67aec3b2e721ae274d34ca2c6362c
37,701
[ -1 ]
37,702
package.lisp
open-rsx_rsbag-cl/src/view/package.lisp
;;;; package.lisp --- Package definition for view module. ;;;; ;;;; Copyright (C) 2011, 2012, 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.view (:use #:cl #:alexandria #:iterate #:let-plus #:more-conditions #:rsbag) ;; `multi-sequence-view-mixin' (:export #:view-sequences) ;; `serialized' view class and construction function (:export #:serialized #:make-serialized-view #:%make-key-function) (:documentation "This module contains functions and classes that implement views (as subclasses of `cl:sequence') on data stored in bags. Currently, the following views are available: serialized aggregate the data of multiple channels, serializing items using their timestamps."))
816
Common Lisp
.lisp
28
25.357143
70
0.70475
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
1965453f173c76157f2f2233b5683fb69ab734689534069b5d43807cd604c245
37,702
[ -1 ]
37,703
protocol.lisp
open-rsx_rsbag-cl/src/view/protocol.lisp
;;;; protocol.lisp --- Protocol for the view module. ;;;; ;;;; Copyright (C) 2011, 2012, 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.view) ;;; View construction functions (defgeneric make-serialized-view (sequences &key selector compare) (:documentation "Make and return a sequence that consists of a serialization of the elements of SEQUENCES. The serialization is performed by comparing timestamps of elements arranging elements in the order of increasing timestamps. SELECTOR is a function that is applied to each element of SEQUENCES before the view is constructed. When SEQUENCES is a sequence of `channel's or a `bag', functions such as `channel-timestamps', `channel-entries' and `channel-items' can be supplied as SELECTOR to select the elements of the returned sequence. COMPARE is a ordering predicate.")) ;;; Extensible support functions (defgeneric %make-key-function (sequence) (:documentation "Return a function that takes four arguments, a sequence, an iterator, a limit and a from-end-value, and returns a serialization key (for example a `local-time:timestamp') for the corresponding element. The returned function has to be applicable to sequences of the type of SEQUENCE and associated iterators."))
1,458
Common Lisp
.lisp
31
40.387097
70
0.705634
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
db1ce5aed85c65815321540b72ae9563b7754b14bf4abc3ec6d2bb16b7d8428d
37,703
[ -1 ]
37,704
serialized.lisp
open-rsx_rsbag-cl/src/view/serialized.lisp
;;;; serialized.lisp --- Serialized view on data from multiple channels. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.view) ;;; In-parallel steppable iterator states (defstruct (%iterator (:constructor make-%iterator (key sequence iterator limit from-end)) (:predicate nil)) ;; The comparison key for the sequence element at which the iterator ;; is currently positioned. (key nil) ;; Iterator state parts: sequence through which the iterator ;; iterates, iterator state, iteration limit and from-end flag. (sequence nil :read-only t) (iterator nil) (limit nil :read-only t) (from-end nil :read-only t)) (declaim (inline %iterator-step) (ftype (function (%iterator function boolean) (values %iterator &optional)) %iterator-step)) (defun %iterator-step (state key from-end) ;; Destructively perform a step with iterator STATE and update its ;; sorting key using KEY. Return the modified STATE. (let+ (((&structure %iterator- (key* key) sequence iterator limit (from-end* from-end)) state)) (setf iterator (sequence:iterator-step sequence iterator (xor from-end from-end*)) key* (unless (sequence:iterator-endp sequence iterator limit (xor from-end from-end*)) (funcall key sequence iterator)))) state) (declaim (inline %iterator<) (ftype (function (%iterator %iterator function) (values boolean &optional)) %iterator<)) (defun %iterator< (left right compare) (cond ((null (%iterator-key left)) nil) ((null (%iterator-key right)) t) ((funcall compare (%iterator-key left) (%iterator-key right)) t) (t nil))) (declaim (ftype (function (list function function) (values (or null %iterator) &optional)) %iterator-for-backward-step)) (defun %iterator-for-backward-step (iterators key compare) ;; Return the iterator in ITERATORS that should be used to retrieve ;; the previous element of the serialized sequence of nil. (let+ (((&flet cannot-step-back? (iterator) (let+ (((&structure-r/o %iterator- sequence iterator) iterator)) (when-let ((index (sequence:iterator-index sequence iterator))) (zerop index))))) ((&flet back (iterator) (cons (%iterator-step (copy-%iterator iterator) key t) iterator)))) (cdr (reduce (lambda (left right) (if (%iterator< (car left) (car right) compare) right left)) (mapcar #'back (remove-if #'cannot-step-back? iterators)))))) ;;; Construction methods (defmethod make-serialized-view ((sequences bag) &key (selector #'identity) (compare #'<)) ;; Create a serialized view for the channels of a bag. (make-serialized-view (bag-channels sequences) :selector selector :compare compare)) (defmethod make-serialized-view ((sequences sequence) &key (selector #'identity) (compare #'<)) (let* ((transformed (map 'list selector sequences)) (key (if transformed (%make-key-function (first transformed)) #'identity))) (make-instance 'serialized :sequences transformed :key key :compare compare))) ;;; Key creation methods (defmethod %make-key-function ((sequence sequence)) ;; When SEQUENCE is just a `sequence', we assume it consists of ;; timestamps. (lambda (sequence iterator) (sequence:iterator-element sequence iterator))) (defmethod %make-key-function ((sequence channel)) ;; When SEQUENCE is a `channel', we can use timestamps as keys by ;; using the index of the iterator and looking up the corresponding ;; timestamp in `channel-timestamps'. (lambda (sequence iterator) (let ((timestamps (rsbag::channel-timestamps/raw sequence))) (elt timestamps (sequence:iterator-index sequence iterator))))) (defmethod %make-key-function ((sequence rsbag::channel-timestamps)) ;; When SEQUENCE is a `channel-timestamps' instance, we can use ;; timestamps as keys by using the index of the iterator and looking ;; up the corresponding timestamp in `channel-timestamps'. (lambda (sequence iterator) (let ((timestamps (rsbag::%timestamps sequence))) (elt timestamps (sequence:iterator-index sequence iterator))))) (defmethod %make-key-function ((sequence channel-items)) ;; When SEQUENCE is of type `channel-items', we can use the index of ;; the iterator and look up the corresponding timestamp in the ;; timestamp sequence. (lambda (sequence iterator) (let ((timestamps (rsbag::%timestamps sequence))) (elt timestamps (sequence:iterator-index sequence iterator))))) ;;; `serialized' class (defclass serialized (multi-sequence-view-mixin elt-via-iterator-mixin sequence) ((compare :initarg :compare :type function :accessor view-compare :initform #'< :documentation "Stores a function that is used to compare keys extracted from iterator states in order to decide which iterator has to be stepped.") (key :initarg :key :type function :accessor view-key :documentation "Stores a function that extracts keys from iterator states which are used to decide which iterator has to be stepped.")) (:default-initargs :key (missing-required-initarg 'serialized :key)) (:documentation "Instances of this class provide the data of multiple channels as a single sequence in which items from different channels are serialized according to their timestamps.")) (defmethod sequence:length ((view serialized)) ;; The number of events is the sums of the numbers of events of ;; individual channels. (reduce #'+ (view-sequences view) :key #'length)) (defmethod sequence:make-simple-sequence-iterator ((view serialized) &key from-end (start 0) end) (let+ (((&structure-r/o view- sequences compare key) view) ((&flet make-iterator (sequence) (let+ (((&values iterator limit from-end) (sequence:make-simple-sequence-iterator sequence :from-end from-end)) (key (unless (sequence:iterator-endp sequence iterator limit from-end) (funcall key sequence iterator)))) (make-%iterator key sequence iterator limit from-end)))) ;; Build the iterator, omitting empty sequences for ;; simplicity and efficiency. (iterator (make-instance 'serialized-iterator :iterators (map 'list #'make-iterator (remove-if #'emptyp sequences)) :compare compare))) (iter (repeat start) (setf iterator (sequence:iterator-step view iterator from-end))) (values iterator (or end (length view)) from-end))) ;;; `serialized-iterator' class (defclass serialized-iterator (multi-sequence-iterator-mixin) ((sorted :type pileup:heap :accessor iterator-%sorted :documentation "Stores the set of iterators sorted with respect to the comparison function and their respective key.") (current :accessor iterator-%current :documentation "Stores the iterator that holds the current element and has to be stepped in order to step in the serialized view.")) (:documentation "Instances of this class perform iterations through sequences that are serialized views on multiple sequences.")) (defmethod shared-initialize :after ((instance serialized-iterator) (slot-names t) &key iterators compare) (declare (type function compare)) (let+ (((&structure iterator-% sorted current) instance) ((&flet predicate (left right) (%iterator< left right compare)))) (setf sorted (pileup:make-heap #'predicate)) (map nil (rcurry #'pileup:heap-insert sorted) iterators) (setf current (pileup:heap-top sorted)))) (defmethod sequence:iterator-endp ((sequence serialized) (iterator serialized-iterator) (limit t) (from-end t)) (or (when-let ((current (iterator-%current iterator))) (null (%iterator-key current))) (call-next-method))) (defmethod sequence:iterator-step ((sequence serialized) (iterator serialized-iterator) (from-end t)) (let+ (((&structure-r/o view- compare key) sequence) ((&structure iterator-% iterators sorted current) iterator) (to-be-stepped (if from-end (%iterator-for-backward-step iterators key compare) (pileup:heap-pop sorted)))) (declare (type function compare key)) ;; Step the appropriate sub-iterator (depending on forward ;; vs. backward step), then find and store the next sub-iterator. (%iterator-step to-be-stepped key from-end) (if from-end (progn (setf sorted (pileup:make-heap (pileup:heap-predicate sorted))) (map nil (rcurry #'pileup:heap-insert sorted) iterators)) (pileup:heap-insert to-be-stepped sorted)) (setf current (pileup:heap-top sorted))) iterator) (defmethod sequence:iterator-element ((sequence serialized) (iterator serialized-iterator)) (let+ (((&structure-r/o %iterator- sequence iterator) (iterator-%current iterator))) (sequence:iterator-element sequence iterator)))
10,606
Common Lisp
.lisp
227
35.54185
79
0.601449
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
9e021d82977b19bf9e82caea356800aebaa73ff745ed76d5c2215838f9931651
37,704
[ -1 ]
37,705
mixins.lisp
open-rsx_rsbag-cl/src/view/mixins.lisp
;;;; elt-via-iterator-mixin.lisp --- Mixin class for non-random-access sequences ;;;; ;;;; Copyright (C) 2011, 2012, 2013, 2015 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.view) ;;; `elt-via-iterator-mixin' class (defclass elt-via-iterator-mixin () () (:documentation "This class is intended to be mixed into sequence classes that cannot provide `sequence:elt' directly but can provide iterators. Subclasses inherit a method on `sequence:elt' that positions an iterator on the requested index and retrieves the element from it.")) (defmethod sequence:elt ((view elt-via-iterator-mixin) (index integer)) ;; Create an iterator and advance it to INDEX. (let+ (((&values iterator &ign from-end) (sequence:make-simple-sequence-iterator view))) (iter (repeat index) (sequence:iterator-step view iterator from-end)) (sequence:iterator-element view iterator))) ;;; `multi-sequence-view-mixin' class (defclass multi-sequence-view-mixin () ((sequences :initarg :sequences :type list :reader view-sequences :documentation "Stores the list of sequences from the view aggregates data.")) (:default-initargs :sequences (missing-required-initarg 'multi-sequence-view-mixin :sequences)) (:documentation "This class is intended to be mixed into view classes that aggregate data from multiple sequences.")) (defmethod print-object ((object multi-sequence-view-mixin) stream) (print-unreadable-object (object stream :type t :identity t) (format stream "(~D)" (length (view-sequences object))))) ;;; `multi-sequence-iterator-mixin' class (defclass multi-sequence-iterator-mixin () ((iterators :initarg :iterators :type list :reader iterator-%iterators :documentation "Stores iterators that represent sequence-specific iteration states.") (index :initarg :index :type non-negative-integer :accessor iterator-%index :initform 0 :documentation "Stores the current index of the iteration.")) (:default-initargs :iterators (missing-required-initarg 'multi-sequence-iterator-mixin :iterators)) (:documentation "This class is intended to be mixed into iterator classes that represent the state of iterations which span multiple sequences.")) (defmethod sequence:iterator-step :after ((sequence sequence) (iterator multi-sequence-iterator-mixin) (from-end t)) (incf (iterator-%index iterator) (if from-end -1 1))) (defmethod sequence:iterator-endp ((sequence sequence) (iterator multi-sequence-iterator-mixin) (limit t) (from-end t)) (= (iterator-%index iterator) limit)) (defmethod sequence:iterator-index ((sequence sequence) (iterator multi-sequence-iterator-mixin)) (iterator-%index iterator)) (defmethod print-object ((object multi-sequence-iterator-mixin) stream) (print-unreadable-object (object stream :type t :identity t) (format stream "~D" (iterator-%index object))))
3,414
Common Lisp
.lisp
73
37.863014
83
0.648738
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
c6265c0aa3eb353b88abeb2d1f651720b04f4b946eebb0527046484bd89f74c2
37,705
[ -1 ]
37,706
package.lisp
open-rsx_rsbag-cl/src/transform/package.lisp
;;;; package.lisp --- Package definition for the transform module. ;;;; ;;;; Copyright (C) 2011-2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.transform (:use #:cl #:alexandria #:let-plus #:iterate #:more-conditions #:nibbles) (:import-from #:rsbag #:rsbag-condition #:rsbag-error #:make-versioned-name #:with-versioned-packages) ;; Variables (:export #:+rsb-schema-name+) ;; Conditions (:export #:transform-condition #:transform-condition-transform #:encoding-error #:transform-error-domain-object #:decoding-error #:transform-error-encoded) ;; Transform protocol (:export #:transform-name #:transform-format #:decode #:encode) ;; Transform service and creation protocol (:export #:transform #:make-transform) (:documentation "This package contains the transformation protocol and infrastructure used in rsbag."))
987
Common Lisp
.lisp
42
19.857143
66
0.697425
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
2a178e37d3c1826636edf2da5d42a7a8689385bd314dca0d3a2dcd5e33391567
37,706
[ -1 ]
37,707
protocol.lisp
open-rsx_rsbag-cl/src/transform/protocol.lisp
;;;; protocol.lisp --- Protocol functions of the transform module. ;;;; ;;;; Copyright (C) 2011-2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.transform) ;;; Transform protocol (defgeneric transform-name (transform) (:documentation "Return an object identifying TRANSFORM.")) (defgeneric transform-format (transform) (:documentation "Return an object describing the encoding performed by TRANSFORM.")) (defgeneric encode (transform domain-object) (:documentation "Encode DOMAIN-OBJECT using TRANSFORM and return the result.")) (defgeneric decode (transform data) (:documentation "Decode DATA using TRANSFORM and return the decoded domain-object.")) ;;; Default behavior (defmethod transform-name ((transform standard-object)) "Default behavior is to use the class name of TRANSFORM to identify TRANSFORM." (nth-value 0 (make-keyword (class-name (class-of transform))))) (defmethod encode :around ((transform t) (domain-object t)) "Establish a use-value restart and wrap arbitrary conditions in an `encoding-error' instance." (with-condition-translation (((error encoding-error) :transform transform :domain-object domain-object)) (restart-case (call-next-method) (use-value (value) :report (lambda (stream) (format stream "~@<Specify a value to use ~ instead of the result of the ~ failed encoding.~@:>")) :interactive (lambda () (format *query-io* "~@<Enter replacement ~ value (unevaluated): ~@:>") (force-output *query-io*) (list (read *query-io*))) value)))) (defmethod decode :around ((transform t) (data t)) "Establish a use-value restart and wrap arbitrary conditions in a `decoding-error' instance." (with-condition-translation (((error decoding-error) :transform transform :encoded data)) (restart-case (call-next-method) (use-value (value) :report (lambda (stream) (format stream "~@<Specify a value to use ~ instead of the result of the ~ failed decoding.~@:>")) :interactive (lambda () (format *query-io* "~@<Enter replacement ~ value (unevaluated): ~@:>") (force-output *query-io*) (list (read *query-io*))) value)))) ;;; Findable transform class family (service-provider:define-service transform (:documentation "Providers are transformations that are applied to entries prior to serializing/after deserializing them to/from bag channels.")) (defgeneric make-transform (spec &rest args) (:documentation "Make and return an instance of the transform class designated by SPEC passing ARGS to the constructed instance.")) (defmethod make-transform ((spec symbol) &rest args) (apply #'service-provider:make-provider 'transform spec args)) (defmethod make-transform ((spec (eql :utf-8-string)) &rest args) ;; Return nil for SPEC :utf-8-string since no transform is necessary ;; in this case. (declare (ignore args)) nil)
3,518
Common Lisp
.lisp
84
32.535714
70
0.611469
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
6b13104e8014991562dd36164525b64cbd232d1ed4f1a107ed79a765a97d2192
37,707
[ -1 ]
37,708
conditions.lisp
open-rsx_rsbag-cl/src/transform/conditions.lisp
;;;; conditions.lisp --- Conditions used in the transform module. ;;;; ;;;; Copyright (C) 2011-2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.transform) (define-condition transform-condition (rsbag-condition) ((transform :initarg :transform :reader transform-condition-transform :documentation "Stores the transform instance that was used in the failed transform operation.")) (:default-initargs :transform (missing-required-initarg 'transform-condition :transform)) (:documentation "This condition class can be mixed into condition classes which have an associated transform.")) (define-condition encoding-error (rsbag-error transform-condition chainable-condition) ((domain-object :initarg :domain-object :reader transform-error-domain-object :documentation "Stores the domain object the encoding of which failed.")) (:default-initargs :domain-object (missing-required-initarg 'encoding-error :domain-object)) (:report (lambda (condition stream) (let ((*print-length* (or *print-length* 16))) (format stream "~@<The domain object ~S could not be encoded by ~ the transform ~ ~A.~/more-conditions:maybe-print-cause/~@:>" (transform-error-domain-object condition) (transform-condition-transform condition) condition)))) (:documentation "This error is signaled when the encoding of a domain object for storage in bag fails.")) (define-condition decoding-error (rsbag-error transform-condition chainable-condition) ((encoded :initarg :encoded :reader transform-error-encoded :documentation "Stores the encoded data, the decoding of which failed.")) (:default-initargs :encoded (missing-required-initarg 'decoding-error :encoded)) (:report (lambda (condition stream) (let+ (((&accessors-r/o (encoded transform-error-encoded) (transform transform-condition-transform)) condition) (octet-sequence? (and (typep encoded 'sequence) (every (of-type 'octet) encoded)))) ;; colon -> print offset ;; at -> print header (format stream "~@<The encoded value ~:@_~:@_~ ~<| ~@;~ ~:[~ ~S~ ~;~ ~,,,16:@/utilities.binary-dump:print-binary-dump/~ ~]~ ~:>~:@_~:@_~ could not be decoded by the transform ~:_~ ~A.~/more-conditions:maybe-print-cause/~:>" (list octet-sequence? encoded) transform condition)))) (:documentation "This error is signaled when the decoding of data, usually retrieved from a bag, fails."))
3,172
Common Lisp
.lisp
70
32.828571
82
0.570045
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5299bae3509cbf44f63bc35707d60533317237162058b4a10d136f82fd925262
37,708
[ -1 ]
37,709
rsb-event-payload-conversion.lisp
open-rsx_rsbag-cl/src/transform/rsb-event-payload-conversion.lisp
;;;; rsb-event-payload-conversion.lisp --- (De)serialization of RSB events. ;;;; ;;;; Copyright (C) 2011, 2012, 2013, 2015 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.transform) (defclass rsb-event/payload-conversion (rsb-event) ((converter :initarg :converter :accessor transform-converter :documentation "Stores the converter that should be used to (de)serialize payloads when (de)serializing events.")) (:default-initargs :converter (missing-required-initarg 'rsb-event/payload-conversion :converter)) (:documentation "Instances of this transform class (de)serialize RSB events from/to octet vectors like `rsb-event' but additionally (de)serialize contained payloads using a specified converter.")) (defmethod encode ((transform rsb-event/payload-conversion) (domain-object rsb:event)) ;; Encode the payload in-place. (let+ (((&structure-r/o transform- converter) transform)) (setf (rsb:event-data domain-object) (rsb.converter:domain->wire converter (rsb:event-data domain-object)))) ;; Forward the modified event to the next method. (call-next-method transform domain-object)) (defmethod decode ((transform rsb-event/payload-conversion) (data simple-array)) ;; Retrieve event (with encoded payload) from next method and decode ;; payload in-place. (let+ (((&structure-r/o transform- wire-schema converter) transform) (event (call-next-method))) (setf (rsb:event-data event) (rsb.converter:wire->domain converter (rsb:event-data event) wire-schema)) event))
1,757
Common Lisp
.lisp
39
38.25641
75
0.676779
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
88edd5a5f4c756acf89addc6c1daadf3096ccb81c1b72987d1957511f4c9ba75
37,709
[ -1 ]
37,710
backend-mixins.lisp
open-rsx_rsbag-cl/src/backend/backend-mixins.lisp
;;;; backend-mixins.lisp --- Mixin classes for backend classes ;;;; ;;;; Copyright (C) 2012, 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend) ;;; `direction-mixin' mixin class (defclass direction-mixin () ((direction :initarg :direction :type rsbag:direction :reader backend-direction :documentation "Stores the direction with which the backend has been opened.")) (:default-initargs :direction (missing-required-initarg 'direction-mixin :direction)) (:documentation "This class is intended to be mixed into backend classes that have to keep track of the direction for which the data source has been opened.")) (defmethod flush :around ((backend direction-mixin) (buffer t)) (when (member (backend-direction backend) '(:output :io)) (call-next-method))) ;;; `stream-mixin' mixin class (defclass stream-mixin (location-mixin) ((stream :initarg :stream :reader backend-stream :type stream :documentation "Stores the stream which contains the data read and written by the backend.") (lock :reader backend-lock :initform (bt:make-lock "Stream lock") :documentation "Stores a lock protecting the stream against concurrent access.")) (:default-initargs :stream (missing-required-initarg 'stream-mixin :stream)) (:documentation "This class is intended to be mixed into backend classes which read/write data from/to a stream.")) (defmethod close ((backend stream-mixin) &key &allow-other-keys) "Make sure the stream is closed." (when (next-method-p) (call-next-method)) (close (backend-stream backend))) ;;; `location-mixin' mixin class (defclass location-mixin () ((location :initarg :location :accessor backend-location :initform nil :documentation "Stores the location to which the backend object is connected. Can be NIL is such a location is not known.")) (:documentation "This mixin allows remembering the location to which a (e.g. stream-based) backend object is connected.")) ;;; `buffering-writer-mixin' mixin class (defclass buffering-writer-mixin () ((buffer :accessor backend-buffer :initform nil :documentation "Stores a buffer which is flushed when `flush?' is non-nil.") (flush-strategy :initarg :flush-strategy :accessor backend-flush-strategy :documentation "Stores a strategy that is used to determine whether the current buffer should be flushed.")) (:default-initargs :flush-strategy (missing-required-initarg 'buffering-writer-mixin :flush-strategy)) (:documentation "This class is intended to be mixed into backend classes that buffer added entries before writing them to disk.")) (defmethod shared-initialize :after ((instance buffering-writer-mixin) (slot-names t) &key) (setf (backend-buffer instance) (make-buffer instance nil))) (defmethod close ((backend buffering-writer-mixin) &key abort) "Flush the buffer if necessary, then proceed." (let+ (((&accessors-r/o (buffer backend-buffer)) backend)) (when (and buffer (not abort)) (flush backend buffer)) (when (next-method-p) (call-next-method)))) (defmethod put-entry :after ((backend buffering-writer-mixin) (channel t) (index t) (entry t)) "After adding an entry, check whether the buffer has to be flushed and potentially do it." (let+ (((&accessors-r/o (buffer backend-buffer) (strategy backend-flush-strategy)) backend)) (when (flush? strategy backend buffer) (flush backend buffer)))) (defmethod flush ((backend buffering-writer-mixin) (buffer t)) (write-buffer backend buffer)) (defmethod flush :after ((backend buffering-writer-mixin) (buffer t)) "Reset the buffer of BACKEND after flushing." (setf (backend-buffer backend) (make-buffer backend buffer))) (defmethod write-buffer :before ((backend t) (buffer t)) (log:info "~@<~A is writing ~A (~@[~:D entr~:@P~]~@[, ~:D ~ byte~:P~]~@[, ~,2F sec~:P~])~@:>" backend buffer (buffer-property backend buffer :length/entries) (buffer-property backend buffer :length/bytes) (buffer-property backend buffer :time-to-last-write))) ;;; `async-double-buffered-writer-mixin' mixin class (declaim (special *async?*)) (defvar *async?* t "Indicates whether an async operation should be performed and especially to disallow async operations under certain conditions.") (defclass async-double-buffered-writer-mixin () ((back-buffer :accessor back-buffer :initform nil :documentation "Stores a buffer which can be used by the backend while an associated buffer is being written back. The value changes when the buffers swap roles.") (writer :accessor %writer :initform nil :documentation "When non-nil, stores a future object which eventually return the result of async write-back operation.")) (:documentation "This class transparently adds to buffer-based backend classes the ability to write buffers asynchronously to other operations performed by the backend.")) (defmethod shared-initialize :after ((instance async-double-buffered-writer-mixin) (slot-names t) &key) ;; Ask the backend to provide an additional buffer for async ;; operations. (setf (back-buffer instance) (make-buffer instance nil))) (defmethod close :around ((backend async-double-buffered-writer-mixin) &key abort) (declare (ignore abort)) (with-threadpool ;; Force any unfinished write operation to finish. (when (%writer backend) (lparallel:force (%writer backend))) ;; Continue with the default closing behavior but disallow async ;; operation. (let ((*async?* nil)) (call-next-method)))) (defmethod write-buffer :around ((backend async-double-buffered-writer-mixin) (buffer t)) (with-threadpool ;; When async operation is disallowed, just call the next method. (unless *async?* (return-from write-buffer (call-next-method))) ;; Force any unfinished write operation to finish and retrieve the ;; buffer it used. (when (%writer backend) (setf (back-buffer backend) (lparallel:force (%writer backend)))) ;; Start a new async write operation on BUFFER. The result will be ;; collected by the next write or close operation. (setf (%writer backend) (lparallel:future (let ((*async?* nil)) (log:info "~@<~A is starting to flush buffer ~A~@:>" backend buffer) (write-buffer backend buffer) (log:info "~@<~A has finished flushing buffer ~A~@:>" backend buffer) buffer))))) (defmethod make-buffer :around ((backend async-double-buffered-writer-mixin) (buffer t)) ;; Ask for more buffers until we have a "front" and a "back" buffer. (if (or (null buffer) (null (back-buffer backend))) (call-next-method) (call-next-method backend (back-buffer backend)))) ;;; `last-write-time-mixin' mixin class (defclass last-write-time-mixin () ((last-write-time :initarg :last-write-time :type (or null local-time:timestamp) :accessor last-write-time :initform nil :documentation "Stores the most recent time at which the associated buffer has been flushed.")) (:documentation "This class can be mixed into backend class which should expose the most recent times at which their associated buffers have been flushed.")) (defmethod buffer-property ((backend last-write-time-mixin) (buffer t) (name (eql :last-write-time))) (or (last-write-time backend) (setf (last-write-time backend) (local-time:now)))) (defmethod buffer-property ((backend last-write-time-mixin) (buffer t) (name (eql :time-to-last-write))) (when-let ((last-write-time (buffer-property backend buffer :last-write-time))) (local-time:timestamp-difference (local-time:now) last-write-time))) (defmethod flush :after ((backend last-write-time-mixin) (buffer t)) (setf (last-write-time backend) (local-time:now)))
9,348
Common Lisp
.lisp
207
35.101449
84
0.613594
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
ab69683003bad54346adc2bdd7d8654f54328583ff67f5d012b85af065a322b3
37,710
[ -1 ]
37,711
package.lisp
open-rsx_rsbag-cl/src/backend/package.lisp
;;;; package.lisp --- Package definition for backend module. ;;;; ;;;; Copyright (C) 2011-2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.backend (:use #:cl #:alexandria #:let-plus #:more-conditions #:rsbag) (:import-from #:closer-mop #:generic-function-methods #:method-specializers #:eql-specializer #:eql-specializer-object) ;; Conditions (:export #:log-file-error #:log-file-error-source #:invalid-file-structure) ;; backend protocol (:export #:backend-location #:backend-direction #:get-channels #:make-channel-id #:put-channel #:get-num-entries #:get-timestamps #:get-entry-at-index #:get-entry-at-time #:put-entry) ;; Backend service and backend creation protocol (:export #:backend #:make-backend) ;; `stream-mixin' class (:export #:stream-mixin #:backend-stream) ;; `direction-mixin' class (:export #:direction-mixin) ;; `location-mixin' class (:export #:location-mixin) ;; `buffering-writer-mixin' class and protocol (:export #:buffering-writer-mixin #:buffer-property #:backend-buffer #:make-buffer #:write-buffer #:flush #:backend-flush-strategy) ;; `async-double-buffered-writer-mixin' (:export #:async-double-buffered-writer-mixin) ;; `last-write-time-mixin' (:export #:last-write-time-mixin) ;; Flush strategy protocol (:export #:flush?) ;; Flush strategy service (:export #:flush-strategy ; service #:make-flush-strategy) ;; Utilities (:export #:print-offset #:uint64->timestamp #:timestamp->uint64) (:documentation "This package contains protocol and implementation aids for file format backends for rsbag."))
1,801
Common Lisp
.lisp
77
19.61039
67
0.684738
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
b28ba28b6cc49019866def21ee6cbd898108fea80be0e47f0719bbce1a6096c0
37,711
[ -1 ]
37,712
util.lisp
open-rsx_rsbag-cl/src/backend/util.lisp
;;;; util.lisp --- Utilities used in the backed module. ;;;; ;;;; Copyright (C) 2012-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend) (defun print-offset (stream offset &optional colon? at?) "Write OFFSET onto STREAM in hexadecimal and decimal forms." (declare (ignore at? colon?)) (format stream "0x~X (~:*~:D)" offset)) ;;; Time-related utility functions (declaim (inline uint64->timestamp timestamp->uint64)) (defun uint64->timestamp (value) (let+ (((&values secs nsecs) (truncate value 1000000000))) (local-time:unix-to-timestamp secs :nsec nsecs))) (defun timestamp->uint64 (value) (let+ (((&accessors-r/o (secs local-time:timestamp-to-unix) (nsecs local-time:nsec-of)) value)) (declare (type non-negative-integer secs) (type (integer 0 (1000000000)) nsecs)) (+ (* (expt 10 9) secs) nsecs)))
947
Common Lisp
.lisp
22
38.545455
62
0.664853
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
3525e4492cb2230151814c4b5910178d2d8926fbfa22a38c97fc3135c3a1577f
37,712
[ -1 ]
37,713
protocol.lisp
open-rsx_rsbag-cl/src/backend/protocol.lisp
;;;; protocol.lisp --- Backend protocol of the rsbag system. ;;;; ;;;; Copyright (C) 2011-2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend) ;;; Backend protocol (defgeneric backend-location (backend) (:documentation "Return an object representing the location in which the contents of BACKEND is stored. Return NIL if this information is not available.")) (defgeneric backend-direction (backend) (:documentation "Return the direction for which BACKEND is configured. See type `rsbag:direction'.")) (defgeneric get-channels (backend) (:documentation "Return the list of channels that are stored in the data source represented by BACKEND. Elements of the list are of the form (ID NAME META-DATA).")) (defgeneric make-channel-id (backend name) (:documentation "Return an object suitable for uniquely identifying a channel within BACKEND. The object may be based on NAME.")) (defgeneric put-channel (backend channel name meta-data) (:documentation "Add a channel name NAME identified by CHANNEL with meta-data META-DATA to the list of channels that are stored in the data source represented by BACKEND.")) (defgeneric get-num-entries (backend channel) (:documentation "Return the number of entries stored in CHANNEL of the data source represented by BACKEND.")) (defgeneric get-timestamps (backend channel) (:documentation "Return a list of the timestamps for which entries are stored in CHANNEL of the data source represented by BACKEND.")) (defgeneric get-entry-at-index (backend channel index) (:documentation "Return the entry designated by INDEX of CHANNEL in the data source represented by BACKEND.")) (defgeneric get-entry-at-time (backend channel timestamp) (:documentation "Return the entry designated by TIMESTAMP of CHANNEL in the data source represented by BACKEND.")) (defgeneric put-entry (backend channel timestamp entry) (:documentation "Store ENTRY at the position designated by TIMESTAMP in CHANNEL in the data source represented by BACKEND.")) ;;; Stream protocol (defgeneric backend-stream (backend) (:documentation "Return the stream of the data source of BACKEND.")) ;;; Buffering protocol (defgeneric buffer-property (backend buffer name) (:documentation "Return the property of BUFFER used in BACKEND designated by NAME.")) (defgeneric make-buffer (backend previous) (:documentation "Allocate and return a suitable buffer for BACKEND based on the buffer PREVIOUS. PREVIOUS can be nil, for the initial allocation.")) (defgeneric write-buffer (backend buffer) (:documentation "Write the entries accumulated in BUFFER to the data source represented by BACKEND.")) (defgeneric flush (backend buffer) (:documentation "Commit the entries accumulated in BUFFER to the data source represented by BACKEND.")) (defgeneric backend-flush-strategy (backend) (:documentation "Return the strategy which is used by backend to schedule buffer flushes.")) ;;; Finding backend classes (service-provider:define-service backend (:documentation "Providers implement support for file formats.")) (defgeneric make-backend (spec &rest args) (:documentation "Return, potentially creating it first, a backend as specified by SPEC and ARGS. When SPEC is a `standard-object' it is just returned. When SPEC is a class or a symbol an instance is created, using ARGS as initargs, and returned. When SPEC is a list, it is assumed to be of the form (CLASS-OR-CLASS-NAME &rest INITARGS) and used as in the previously described cases with INITARGS and ARGS concatenated to form the list of initargs.")) (defmethod make-backend ((spec standard-object) &rest args) (if args (apply #'reinitialize-instance spec args) spec)) (defmethod make-backend ((spec class) &rest args) (apply #'make-instance spec args)) (defmethod make-backend ((spec symbol) &rest args) (apply #'service-provider:make-provider 'backend spec args)) (defmethod make-backend ((spec cons) &rest args) (apply #'make-backend (first spec) (append (rest spec) args))) ;;; Flush strategy protocol (defgeneric flush? (strategy backend buffer) (:documentation "Return non-nil when BUFFER which is used by BACKEND should be flushed according to STRATEGY.")) ;;; Flush strategy classes (service-provider:define-service flush-strategy (:documentation "Providers implement strategies for flushing backend buffers when writing log files.")) (defgeneric make-flush-strategy (thing &rest args) (:documentation "Return (potentially creating it first) an instance of the flushing strategy designated by THING.")) (defmethod make-flush-strategy ((spec standard-object) &rest args) (if args (apply #'reinitialize-instance spec args) spec)) (defmethod make-flush-strategy ((spec symbol) &rest args) (if (keywordp spec) (apply #'service-provider:make-provider 'flush-strategy spec args) (let ((provider (find spec (service-provider:service-providers 'flush-strategy) :key (compose #'class-name #'service-provider:provider-class) :test #'eq))) (apply #'service-provider:make-provider 'flush-strategy provider args)))) (defmethod make-flush-strategy ((spec class) &rest args) (let ((provider (find spec (service-provider:service-providers 'flush-strategy) :key #'service-provider:provider-class :test #'eq))) (apply #'service-provider:make-provider 'flush-strategy provider args))) (defmethod make-flush-strategy ((spec cons) &rest args) (apply #'make-flush-strategy (first spec) (append (rest spec) args)))
5,923
Common Lisp
.lisp
137
38.452555
85
0.73107
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
066a5052dee73d604a6a778ab8a90a22d7395e3fdd88d29dfb0c6a7a9979105b
37,713
[ -1 ]
37,714
flush-strategies.lisp
open-rsx_rsbag-cl/src/backend/flush-strategies.lisp
;;;; flush-strategies.lisp --- Flush strategy classes provided by backend module. ;;;; ;;;; Copyright (C) 2012, 2013, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend) ;;; `property-limit' strategy class (defclass property-limit () ((property :initarg :property :type keyword :accessor flush-strategy-property :documentation "Stores the name of the buffer property based on whose value the flushing decision should be made.") (limit :initarg :limit :type real :accessor flush-strategy-limit :documentation "Stores the ")) (:default-initargs :property (missing-required-initarg 'property-limit :property) :limit (missing-required-initarg 'property-limit :limit)) (:documentation "This strategy causes a buffer to be flushed every time a specified property violates a given limit.")) (service-provider:register-provider/class 'flush-strategy :property-limit :class 'property-limit) (defmethod shared-initialize :before ((instance property-limit) (slot-names t) &key property) ;; Search methods on `buffer-property' for one that is specialized ;; on PROPERTY. (let+ (((&flet property? (specializer) (and (typep specializer 'eql-specializer) (eq (eql-specializer-object specializer) property))))) (unless (some (compose #'property? #'third #'method-specializers) (generic-function-methods #'buffer-property)) (error "~@<Specified property ~A is invalid.~@:>" property)))) (defmethod flush? ((strategy property-limit) (backend t) (buffer t)) (let+ (((&structure-r/o flush-strategy- property limit) strategy)) (> (buffer-property backend buffer property) limit))) (defmethod print-object ((object property-limit) stream) (print-unreadable-object (object stream :type t :identity t) (format stream "~S > ~:D" (flush-strategy-property object) (flush-strategy-limit object)))) ;;; `composite-flush-strategy-mixin' mixin class (defclass composite-flush-strategy-mixin () ((children :initarg :children :type list :accessor flush-strategy-children :initform nil :documentation "A list of child strategies which are consulted to produce a decision.")) (:documentation "This class is intended to be mixed into flush strategy classes which produce their decisions by consulting subordinate strategies.")) (defmethod print-object ((object composite-flush-strategy-mixin) stream) (print-unreadable-object (object stream :type t :identity t) (format stream "~A (~D)" (class-name (class-of object)) (length (flush-strategy-children object))))) (macrolet ((define-simple-composite-strategy (name &key (spec (make-keyword name)) (class-name (format-symbol "FLUSH-IF-~A" name)) reducer) `(progn (defclass ,class-name (composite-flush-strategy-mixin) () (:documentation ,(format nil "This strategy flushes buffers when ~A of ~ its child strategies indicate that buffers ~ should be flushed." reducer))) (service-provider:register-provider/class 'flush-strategy ,spec :class ',class-name) (defmethod service-provider:make-provider ((service t) (provider (eql (service-provider:find-provider 'flush-strategy ,spec))) &rest args) (make-instance (service-provider:provider-class provider) :children (mapcar (curry #'apply #'make-flush-strategy) args))) (defmethod flush? ((strategy ,class-name) (backend t) (buffer t)) (,reducer (rcurry #'flush? backend buffer) (flush-strategy-children strategy)))))) (define-simple-composite-strategy or :class-name flush-if-some :reducer some) (define-simple-composite-strategy and :class-name flush-if-every :reducer every) (define-simple-composite-strategy not :class-name flush-if-notany :reducer notany))
4,753
Common Lisp
.lisp
106
33.330189
87
0.589162
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
fc6ab8eca31cfb566eccb8ed2017ebe4207ce184028aab0f97ddcfe900620756
37,714
[ -1 ]
37,715
conditions.lisp
open-rsx_rsbag-cl/src/backend/conditions.lisp
;;;; conditions.lisp --- Conditions used in backend modules. ;;;; ;;;; Copyright (C) 2011, 2012, 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend) (define-condition log-file-error (rsbag-error) ((source :initarg :source :reader log-file-error-source :documentation "Stores the source involved in the error.")) (:report (lambda (condition stream) (format stream "~@<An error has been encountered when operating ~ on ~A.~@:>" (log-file-error-source condition)))) (:documentation "Errors of this class and subclasses are signaled when operations involving log files fail.")) (define-condition invalid-file-structure (simple-error log-file-error) () (:report (lambda (condition stream) (format stream "~@<Invalid file structure encountered in ~ ~A~/more-conditions:maybe-print-explanation/~@:>" (log-file-error-source condition) condition))) (:documentation "This error is signaled if an invalid file structure is encountered while reading a log file."))
1,222
Common Lisp
.lisp
31
31.935484
70
0.638889
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5559087d1ba0a1573f81d05ed6a8440ba8024b009237b4f0ce13e2a9c4de3a1c
37,715
[ -1 ]
37,716
package.lisp
open-rsx_rsbag-cl/src/backend/tidelog/package.lisp
;;;; package.lisp --- Package definition for the backend.tidelog module. ;;;; ;;;; Copyright (C) 2011, 2012, 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.backend.tidelog (:use #:cl #:alexandria #:split-sequence #:let-plus #:iterate #:more-conditions #:rsbag #:rsbag.backend) ;; Conditions (:export #:tidelog-condition #:tidelog-file-error #:invalid-tidelog-structure #:no-such-block-class-error #:no-such-block-class-error-tag) ;; Block IO protocol (:export #:tag #:size #:scan #:unpack #:pack) (:documentation "This package contains a backend for the TIDE log file format as specified at https://retf.info/svn/drafts/rd-0001.txt. The most important interface classes are: file [class] Represents an entire TIDE log file (and handles access to its channels). index [class] Represents the index for one channel of a TIDE log file. In addition, there is lower-level input/output machinery based on code generated according to the TIDE log specification. This level operates on TIDE log blocks. The interface consists of the generic functions tag [generic function] Returns the four-character \"tag-string\" identifying the block type of an object or class. size [generic function] Returns the number of octets required to store a block object. scan [generic function] Finds blocks in a TIDE log file without reading their entire contents. unpack [generic function] Which reads blocks from TIDE log files. pack [generic function] Which stores blocks in TIDE log files The code generation is implemented by spec->* [function] Family of functions for generating methods on the above generic functions for specified block types. define-element [macro] Turns declarative block type specifications into calls to spec->* functions."))
2,303
Common Lisp
.lisp
61
32.655738
72
0.626075
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
fee133523d8e134c39d1bfff7758852ea95f2126cf1971ee568d30221ddd48c9
37,716
[ -1 ]
37,717
index-vector.lisp
open-rsx_rsbag-cl/src/backend/tidelog/index-vector.lisp
;;;; index-vector.lisp --- Data structure for index entries. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.tidelog) (deftype index-vector () '(array (unsigned-byte 64) (*))) (declaim (inline make-index-vector index-vector-length index-vector-push-entry index-vector-push-extend-entry index-vector-index->offset index-vector-index->timestamp index-vector-timestamp->offset)) (defun make-index-vector () (make-array 0 :element-type '(unsigned-byte 64) :adjustable t :fill-pointer 0)) (defun index-vector-length (vector) (/ (length vector) 2)) (defun index-vector-push-entry (vector timestamp offset) (vector-push timestamp vector) (vector-push offset vector)) (defun index-vector-push-extend-entry (vector timestamp offset) (vector-push-extend timestamp vector (floor (length vector) 8/2)) ; has to be even (vector-push offset vector)) (defun index-vector-add-entries (vector entries chunks) (declare (type index-vector vector)) (let+ ((num-entries (length entries)) (new-length (+ (length vector) (* 2 num-entries))) ((&flet add-offset! (entry) (let+ (((&structure-r/o index-entry- timestamp chunk-id offset) entry) (outer-offset (%chunk-id->offset chunk-id chunks)) (global-offset (+ outer-offset 12 25 offset))) ; TODO(jmoringe): get rid of the constants (index-vector-push-entry vector timestamp global-offset))))) (when (< (array-total-size vector) new-length) (adjust-array vector new-length)) (map nil #'add-offset! entries) vector)) (defun index-vector-add-indxs (vector indxs chunks) (declare (type index-vector vector)) (let* ((num-entries (reduce #'+ indxs :key #'indx-count)) (new-length (+ (length vector) (* 2 num-entries)))) (when (< (array-total-size vector) new-length) (adjust-array vector new-length)) (iter (for indx in-sequence indxs) (index-vector-add-entries vector (indx-entries indx) chunks)) vector)) (defun index-vector-index->offset (index vector) (aref vector (1+ (* 2 index)))) (defun index-vector-index->timestamp (index vector) (aref vector (* 2 index))) (defun index-vector-timestamp->offset (timestamp vector) (%timestamp->index timestamp vector)) ;;; Utilities (declaim (ftype (function ((unsigned-byte 64) index-vector) (values (unsigned-byte 64) &optional)) %timestamp->index)) (defun %timestamp->index (timestamp vector) (labels ((rec (start end) (declare (type array-index start end)) (let* ((pivot (ash (+ start end) -1)) (pivot* (aref vector (* 2 pivot)))) (cond ((< pivot* timestamp) (rec pivot end)) ((> pivot* timestamp) (rec start pivot)) (t (aref vector (1+ (* 2 pivot)))))))) (rec 0 (length vector))))
3,178
Common Lisp
.lisp
70
37.357143
109
0.614738
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
d293d659f938e84b2230cdbaa1b9007fe3ab0440a23e9a2872d7737884c18ef0
37,717
[ -1 ]
37,718
util.lisp
open-rsx_rsbag-cl/src/backend/tidelog/util.lisp
;;;; util.lisp --- Utility functions for the TIDELog backend. ;;;; ;;;; Copyright (C) 2012-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.tidelog) ;;; IO-related utility functions (defun file-position-error (stream) (error "~@<Failed to determine position in stream ~A.~@:>" stream)) (declaim (inline file-position-or-lose)) (defun file-position-or-lose (stream) (or (file-position stream) (file-position-error stream))) (defun read-chunk-of-length (length stream &optional (buffer (nibbles:make-octet-vector length))) "Create a `simple-octet-vector' (unless BUFFER is supplied) of length LENGTH and read LENGTH from STREAM into it. Return the buffer." (let ((read (read-sequence buffer stream))) (unless (= read length) (cerror "Continue with incomplete block" "~@<Could only read ~:D byte~:P when trying to read a ~ sequence of ~:D byte~:P at stream position ~ ~/rsbag.backend:print-offset/.~@:>" read length (file-position stream)))) buffer) ;;; Buffering (defmacro make-or-reuse-instance (array class &rest initargs) (once-only (array) (with-unique-names (fill-pointer element) `(let* ((,fill-pointer (fill-pointer ,array)) (,element (when (> (array-total-size ,array) ,fill-pointer) (aref ,array ,fill-pointer)))) (if (typep ,element ',class) (progn (incf (fill-pointer ,array)) (reinitialize-instance ,element ,@initargs)) (let ((,element (make-instance ',class ,@initargs))) (vector-push-extend ,element ,array) ,element))))))
1,824
Common Lisp
.lisp
42
34.904762
78
0.607887
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
1e31950acf0e3452ade53ef4ed455043341325f26e6454aa56ec1525d59931f8
37,718
[ -1 ]
37,719
protocol.lisp
open-rsx_rsbag-cl/src/backend/tidelog/protocol.lisp
;;;; protocol.lisp --- Protocol functions of the backend.tidelog module. ;;;; ;;;; Copyright (C) 2013, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.tidelog) ;;; Block IO protocol ;;; ;;; This protocol allows `pack' ing block instances into destinations ;;; (e.g. streams, `octet-vector' s), `unpack' ing block instances ;;; from sources and `scan' ning sources for blocks. (defgeneric tag (object-or-class) (:documentation "Return the tag for the block OBJECT-OR-CLASS as `octet-vector'.")) (defgeneric size (object) (:documentation "Return the packed size in bytes of OBJECT.")) (defgeneric scan (source object &optional start) (:documentation "Scan SOURCE for OBJECT and return the collected instances. In the most important case, OBJECT is :tide which causes SOURCE to be scanned as an entire TIDELog file. In this case, three values are returned: 1. a list of CHAN blocks 2. a list of INDX blocks 3. a list of descriptors of CHNK blocks. Each descriptor is of the form (ID . OFFSET) If corrupt data is detected, an `invalid-tidelog-structure' is signaled. The following restarts are established: `retry' Retry processing a particular block. `continue' Skip the current block and continue with the next block if possible or stop processing and return otherwise. `abort' Stop processing and return the blocks collected so far.")) (defgeneric unpack (source object &optional start) (:documentation "Unpack OBJECT from SOURCE, optionally starting at offset START. OBJECT can at least be one of the following :block-header Extract a block header from SOURCE and return two values: the class of the block and the length of the block in bytes. If the block tag in SOURCE does not correspond to a known block class, a `no-such-block-class-error' is signaled. :block Detect the block class and unpack the data in SOURCE into an appropriate instance. Can signal the same errors as the :block-header case when determining the block class. INSTANCE-OF-A-BLOCK-CLASS Unpack the data in SOURCE into the given block class instance. The data in SOURCE should start with the block body, not the block header in this case. If corrupt data is detected, an `invalid-tidelog-structure' is signaled. The following ")) (defgeneric pack (object destination &optional start) (:documentation "Pack the block class instance OBJECT into DESTINATION.")) ;;; Index protocol ;;; ;;; Generic functions for translating entry indices and entry ;;; timestamps to file offsets. (defgeneric index-count (index) (:documentation "Return the number of entries stored in INDEX.")) (defgeneric index-index->offset (index index*) (:documentation "Return the offset of the entry designated by INDEX* in INDEX.")) (defgeneric index-timestamp->offset (index timestamp) (:documentation "Return the offset of the entry designated by TIMESTAMP in INDEX.")) (defgeneric index-add-indxs (index indxs chunks) (:documentation "Add INDXS to INDEX, using CHUNKS to compute file offsets.")) (defgeneric index-add-entries (index entries chunks) (:documentation "Add ENTRIES to INDEX, using CHUNKS to compute file offsets.")) ;;; Output index protocol ;;; ;;; Flush management of output indices. (defgeneric index-derive-flush-strategy (index flush-strategy) (:documentation "Return a flush-strategy for INDEX based on FLUSH-STRATEGY."))
3,611
Common Lisp
.lisp
85
38.482353
72
0.739765
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
c9ffbfc82ce1c7b5781df05086cfb99dec3e0b53d506d51ed5341c5f760f3ea3
37,719
[ -1 ]
37,720
io.lisp
open-rsx_rsbag-cl/src/backend/tidelog/io.lisp
;;;; io.lisp --- Input and output of TIDE log structures. ;;;; ;;;; Copyright (C) 2011-2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.tidelog) ;;; Scan (define-condition-translating-method scan ((source t) (object t) &optional start) (((and error (not tidelog-condition)) invalid-tidelog-structure :var condition :cause-initarg nil) :source source :format-control "~@<Failed to ~A for block ~A~@[ at position ~ ~/rsbag.backend:print-offset/~]: ~A~@:>" :format-arguments (list 'scan object (when (streamp source) (file-position source)) condition))) (defmethod scan :before ((source stream) (object t) &optional start) ;; Seek to position START before starting to scan. (when start (file-position source start))) (defmethod scan ((source stream) (object (eql :tide)) &optional start) (declare (ignore start)) ;; Consume and check the TIDE block. (let ((block (unpack source :block))) (unless (typep block 'tide) (error "~@<Starts with a ~A block instead of a ~A block~@:>" (class-name (class-of block)) 'tide)) (let+ (((&structure-r/o tide- version-major version-minor) block)) (log:info "~@<Read ~A block with version ~D.~D~@:>" 'tide version-major version-minor) (unless (= +format-version-major+ version-major) (cerror "Try to process the file anyway." "~@<Cannot process format version ~D.~D (major version ~ is different from ~D.~D)~@:>" version-major version-minor +format-version-major+ +format-version-minor+)))) ;; Scan through remaining blocks. (function-calling-restart-bind (((retry () retry) :report (lambda (stream) (format stream "~@<Retry reading at the same ~ position in ~A.~@:>" source))) ((continue (&optional condition) skip bail) :report (lambda (stream) (format stream (if skip "~@<Skip ahead to the next undamaged ~ block in ~A.~@:>" "~@<Do not scan the remainder of ~ ~A.~@:>") source))) ((abort (&optinal condition) bail) :report (lambda (stream) (format stream "~@<Do not scan the remainder of ~ ~A.~@:>" source)))) (iter (with complete? = t) (when (first-iteration-p) (setf retry (lambda () (next-iteration)) bail (lambda (&optional condition) (declare (ignore condition)) (setf complete? nil) (return (values channels indices chunks complete?))) skip (lambda (&optional condition) (declare (ignore condition)) (let ((skip/old skip)) ; prevent recursion (setf skip nil complete? nil) (find-next-block source) (setf skip skip/old)) (next-iteration)))) (while (listen source)) (let+ (((&values offset block) (scan source :block))) (typecase block (chan (collect block :into channels)) ((cons (eql indx) integer) ; cdr is channel id (collect (cons (cdr block) offset) :into indices)) ((cons (eql chnk) integer) ; cdr is CHNK id (collect (cons (cdr block) offset) :into chunks)))) (finally (return (values channels indices chunks complete?)))))) (defmethod scan ((source stream) (object (eql :block)) &optional start) (declare (ignore start)) (let+ ((offset (file-position-or-lose source)) ((&values class length) (unpack source :block-header)) (class-name (class-name class))) (values offset (case class-name ((type1 chan) (unpack (read-chunk-of-length length source) (allocate-instance class))) ((indx chnk) (prog1 (cons class-name (nibbles:read-ub32/le source)) ; CHNK id / INDX channel id (file-position source (+ (file-position-or-lose source) (- length 4))))) (t (file-position source (+ (file-position-or-lose source) length))))))) ;;; Unpacking (define-condition-translating-method unpack ((source t) (object t) &optional start) (((and error (not tidelog-condition)) invalid-tidelog-structure :var condition) :source source :format-control "~@<Failed to ~A block ~A~@[ at position ~ ~/rsbag.backend:print-offset/~]: ~A~@:>" :format-arguments (list 'unpack object (when (streamp source) (file-position source)) condition))) (defmethod unpack :before ((source stream) (object t) &optional start) ;; Seek to position START before unpacking into OBJECT. (when start (file-position source start))) (defmethod unpack ((source stream) (object (eql :block-header)) &optional start) (declare (ignore start)) (let ((header (read-chunk-of-length 12 source))) (declare (dynamic-extent header)) (handler-bind ((error (lambda (condition) (error "~@<Could not decode header~:@_~ ~<| ~@;~,,,16/utilities.binary-dump:print-binary-dump/~:>~@:_~ ~A~:>" (list header) condition)))) (values (byte-pattern->block-class (subseq header 0 4)) (nibbles:ub64ref/le header 4))))) (defmethod unpack ((source stream) (object (eql :block)) &optional start) (declare (ignore start)) (let+ (((&values class length) (unpack source :block-header)) (file-length (ignore-errors (file-length source))) ; TODO cache this when we have the stream abstraction (file-position (file-position-or-lose source))) (when (and file-length (> (+ file-position length) file-length)) (cerror "Try to read the block anyway" "~@<Bounds [~/rsbag.backend:print-offset/, ~ ~/rsbag.backend:print-offset/[ of ~A block would be ~ outside bounds [~/rsbag.backend:print-offset/, ~ ~/rsbag.backend:print-offset/[ of ~A.~@:>" file-position (+ file-position length) (class-name class) 0 (file-length source) source)) (unpack (read-chunk-of-length (if (eq (class-name class) 'tide) 10 length) source) ; TODO(jmoringe): hack (allocate-instance class)))) ;;; Packing ;;; ;;; Nothing to do since everything is handled by the methods generated ;;; in spec.lisp
7,336
Common Lisp
.lisp
155
34.225806
113
0.532245
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
6da5eb595ff03106ba8ecedaf4b9a3984b94ce042ed0fe05a5c46ceb910cc89a
37,720
[ -1 ]
37,721
index.lisp
open-rsx_rsbag-cl/src/backend/tidelog/index.lisp
;;;; index.lisp --- Representation of TIDELog indices. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.tidelog) ;;; Lazy timestamp sequence #+sbcl (defclass timestamps (standard-object sequence) ((entries :initarg :entries :type index-vector :reader timestamps-entries :documentation "The vector of entries of the associated index.")) (:default-initargs :entries (missing-required-initarg 'timestamps :entries)) (:documentation "Instances of this class are sequences of timestamps represented as integers.")) #+sbcl (defmethod sequence:length ((sequence timestamps)) (index-vector-length (timestamps-entries sequence))) #+sbcl (defmethod sequence:elt ((sequence timestamps) (index integer)) (index-vector-index->timestamp index (timestamps-entries sequence))) ;;; Index creation (defun make-index (channel-id stream lock direction &key flush-strategy) (let+ (((&flet make-it (class &rest initargs) (apply #'make-instance class :stream stream :lock lock :direction direction :channel channel-id initargs)))) (ecase direction (:input (make-it 'input-index)) (:output (let ((derived (when flush-strategy (let ((class (find-class 'output-index))) (c2mop:finalize-inheritance class) (index-derive-flush-strategy (c2mop:class-prototype class) flush-strategy))))) (log:debug "~@<From flush strategy ~A, derived flush strategy ~ ~A~:@>" flush-strategy derived) (apply #'make-it 'output-index (when derived (list :flush-strategy derived))))) (:io (make-it 'io-index))))) ;;; `base-index' (defclass base-index (direction-mixin) ((channel :initarg :channel :type non-negative-integer :reader index-channel :documentation "Stores the id of the channel to which this index belongs.") (stream :initarg :stream :type stream :reader index-stream :documentation "Stores the stream to which the data of this index should be written when flushing.") (lock :initarg :lock :reader index-%lock :documentation "Stores a lock that protects the stream.")) (:default-initargs :channel (missing-required-initarg 'base-index :channel) :stream (missing-required-initarg 'base-index :stream) :lock (missing-required-initarg 'base-index :lock)) (:documentation "Superclass of index classes.")) ;;; `input-index' (defclass input-index (base-index) ((entries :type index-vector :accessor index-entries :initform (make-index-vector) :documentation "Stores the actual timestamp -> offset mapping. The storage is sorted and interleaved of the form TIMESTAMP1 OFFSET1 TIMESTAMP2 OFFSET2 ... .")) (:documentation "Instances of this class index events of individual channels for files opened with :input direction. These indices only store entry timestamps and corresponding offsets, are immutable and never write back any data.")) (defmethod close ((stream input-index) &key abort) (declare (ignore abort))) ; nothing to do (defmethod index-count ((index input-index)) (index-vector-length (index-entries index))) (defmethod index-index->offset ((index input-index) (thing integer)) (index-vector-index->offset thing (index-entries index))) (defmethod index-timestamp->offset ((index input-index) (timestamp integer)) (index-vector-timestamp->offset timestamp (index-entries index))) (defmethod index-add-indxs ((index input-index) (indxs sequence) (chunks vector)) (index-vector-add-indxs (index-entries index) indxs chunks)) (defmethod index-add-entries ((index input-index) (entries sequence) (chunks vector)) (index-vector-add-entries (index-entries index) entries chunks)) ;;; `output-index' (defclass output-index (base-index async-double-buffered-writer-mixin buffering-writer-mixin last-write-time-mixin) ((sorted-to :initarg :sorted-to :type (or integer null) :accessor index-%sorted-to :initform 0 :documentation "Stores the index into the entries vector up to which entries are sorted. The value nil indicates that entries are not sorted.")) (:default-initargs :flush-strategy (make-flush-strategy :property-limit :property :length/bytes :limit (expt 2 22))) (:documentation "Instances of this class store partial index information for individual channels until it is written to the output stream. These indices do not generally store information for all entries in one channel and cannot be queried.")) (defmethod index-derive-flush-strategy ((index output-index) (flush-strategy t)) flush-strategy) (defmethod index-derive-flush-strategy ((index output-index) (flush-strategy rsbag.backend::property-limit)) (if (eq :length/bytes (rsbag.backend::flush-strategy-property flush-strategy)) (let ((limit (rsbag.backend::flush-strategy-limit flush-strategy))) (make-flush-strategy :property-limit :property :length/bytes :limit (floor limit 4))) flush-strategy)) (defmethod index-derive-flush-strategy ((index output-index) (flush-strategy rsbag.backend::composite-flush-strategy-mixin)) (apply #'make-flush-strategy (class-of flush-strategy) (mapcar (compose #'list (curry #'index-derive-flush-strategy index)) (rsbag.backend::flush-strategy-children flush-strategy)))) (defmethod index-count ((index output-index)) (indx-count (backend-buffer index))) ; TODO wrong after flushing (defmethod put-entry ((index output-index) (timestamp integer) (offset integer) (chunk-id integer)) (let+ (((&accessors-r/o (buffer backend-buffer) (sorted-to index-%sorted-to)) index)) ;; Update index block. (incf (indx-count buffer)) (make-or-reuse-instance (indx-entries buffer) index-entry :chunk-id chunk-id :timestamp timestamp :offset offset) ;; Update sorted state. (when sorted-to (setf (index-%sorted-to index) (when (>= timestamp sorted-to) timestamp))))) ;; Buffering (defmethod make-buffer ((index output-index) (previous (eql nil))) (make-buffer index (make-instance 'indx :channel-id (index-channel index) :entries (make-array 0 :adjustable t :fill-pointer 0)))) (defmethod make-buffer ((index output-index) (previous indx)) (setf (fill-pointer (indx-entries previous)) 0) (reinitialize-instance previous :count 0)) (defmethod write-buffer ((index output-index) (buffer indx)) (let+ (((&structure-r/o index- stream (sorted-to %sorted-to)) index) ((&structure-r/o indx- entries) buffer)) ;; If some timestamps have been inserted out of order, sort the ;; entire index block now. (unless sorted-to (warn "~@<Sorting index block due to out-of-order ~ insertions.~@:>") (setf entries (sort entries #'< :key #'index-entry-timestamp))) ;; If we have anything to write, write it and reset fill pointer ;; so we can start filling the buffer again. (unless (zerop (indx-count buffer)) (bt:with-lock-held ((index-%lock index)) (pack buffer stream) (force-output stream))))) (defmethod buffer-property ((backend output-index) (buffer indx) (name (eql :length/entries))) (indx-count buffer)) (defmethod buffer-property ((backend output-index) (buffer indx) (name (eql :length/bytes))) (+ 8 (* 20 (buffer-property backend buffer :length/entries)))) ;;; `io-index' (defclass io-index (input-index output-index) () (:documentation "Instances of this class manage mutable and queryable index information for individual channels. Such an index contains timestamp and index information for all entries of the associated channel as well as a buffer of unwritten index information.")) (defmethod put-entry ((index io-index) (timestamp integer) (offset integer) (chunk-id integer)) ;; Next method updates current in-memory `indx' block. (call-next-method) ;; Add to entries. (index-vector-push-extend-entry (index-entries index) timestamp offset))
9,845
Common Lisp
.lisp
226
32.765487
80
0.592921
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
2b4746fa20aeb05dc6204cb9d92016d1188f14bc4102e1432818857757c457d5
37,721
[ -1 ]
37,722
repair.lisp
open-rsx_rsbag-cl/src/backend/tidelog/repair.lisp
;;;; repair.lisp --- Recover from damage in log files. ;;;; ;;;; Copyright (C) 2012, 2013, 2014, 2015 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.tidelog) ;;; Reconstructing indices (defun reconstruct-indices (stream chunks ensure-index) "Reconstruct index information for CHUNKS based on the contents of STREAM. CHUNKS is a list of entries of the form (ID . OFFSET) . Call ENSURE-INDEX with a channel number to retrieve (creating it if necessary) an `index' instance and add entries. Returns nothing." (log:info "~@<Reconstructing indices for ~:D chunk~:P in ~A~@:>" (length chunks) stream) ;; For each channel there is a queue of `index-entry' instances to ;; that should eventually be added to the corresponding index. (let+ ((queues (make-hash-table)) ((&flet make-queue () (make-array 0 :adjustable t :fill-pointer 0))) ((&flet flush-queue (queue) (fill queue nil) (setf (fill-pointer queue) 0))) ((&flet add-to-queue (channel-id entry) (vector-push-extend entry (ensure-gethash channel-id queues (make-queue))))) ((&flet flush-indices () (log:info "~@<Flushing ~:D collected index entr~:@P~@:>" (reduce #'+ (hash-table-values queues) :key #'length)) (iter (for (channel-id queue) :in-hashtable queues) (let ((index (funcall ensure-index channel-id))) (index-add-entries index queue chunks)) (flush-queue queue))))) ;; For each chunk, visit all its entries and add them to the ;; temporary index lists. (function-calling-restart-bind (((continue (&optional condition) skip bail) :report (lambda (stream1) (format stream1 (if skip "~@<Skip ahead to the next undamaged ~ block in ~A.~@:>" "~@<Do not process the remainder of ~ ~A.~@:>") stream))) ((abort (&optional condition) bail) :report (lambda (stream1) (format stream1 "~@<Do not process the remainder ~ of ~A.~@:>" stream)))) (iter (when (first-iteration-p) (setf skip (lambda (&optional condition) (declare (ignore condition)) (next-iteration)) bail (lambda (&optional condition) (declare (ignore condition)) (return)))) (for (id . offset) each chunks :with-index i) ;; Flush collected index entries into the respective ;; `index' instances where they will be integrated into ;; a memory-efficient representation. This limits the ;; peak memory use. (with offset/previous = 0) (when (> (- offset offset/previous) (ash 1 27)) (flush-indices) #+sbcl (sb-ext:gc :full t) (setf offset/previous offset)) ;; Make and collect index entries for chunk entries. (let+ ((chunk (unpack stream :block offset)) ((&accessors-r/o (chunk-id chnk-chunk-id)) chunk)) (iter (for entry each (chnk-entries chunk) :with-index j) (with offset1 = 0) (let+ (((&structure-r/o chunk-entry- channel-id timestamp size) entry)) (add-to-queue channel-id (make-instance 'index-entry :timestamp timestamp :chunk-id chunk-id :offset offset1)) (incf offset1 (+ 16 size))))))) (flush-indices) (values))) ;;; Finding undamaged blocks (defun find-next-block (stream &key (blocks (hash-table-alist *byte-pattern->block-class*))) "Return as two values the file position and class name of the next block in STREAM. The file position of STREAM is changed. When a block is found, the file position of STREAM is changed to the start of that block. The searched-for block classes can be controlled via BLOCKS. When supplied, BLOCKS has to be an alist with elements of the form (PATTERN . BLOCK-CLASS) where PATTERN is a block tag as a `nibbles:octet-vector' and BLOCK-CLASS is a block class." (let* ((buffer-length (* 1024 1024)) (buffer (nibbles:make-octet-vector buffer-length)) (eof? (not (listen stream)))) (declare (dynamic-extent buffer)) (iter (until eof?) (for global-offset next (file-position stream)) (let ((read (read-sequence buffer stream))) ;; Search for tags of all known block classes in BUFFER. (iter (for ((the nibbles:simple-octet-vector pattern) . class) in blocks) (when-let* ((local-offset (search pattern buffer :end2 read)) (offset (+ global-offset local-offset))) (file-position stream offset) (return-from find-next-block (values offset (class-name class))))) (setf eof? (not (listen stream))) ;; Back up to catch instances spanning buffer borders. (when (> (+ global-offset read) 4) (file-position stream (+ global-offset read -4)))))) (values))
5,850
Common Lisp
.lisp
116
35.913793
85
0.536607
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
2340453437b6bf314b1fb65098412c6e1cabbedf794ac6ae6c931a3f075c87e3
37,722
[ -1 ]
37,723
spec.lisp
open-rsx_rsbag-cl/src/backend/tidelog/spec.lisp
;;;; spec.lisp --- Based on TIDE log file format specification. ;;;; ;;;; Copyright (C) 2011, 2012, 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.tidelog) (define-element (tide) (version-major (unsigned-byte 8) :documentation "Major version of the TIDE format used.") (version-minor (unsigned-byte 8) :documentation "Minor version of the TIDE format used.") (num-channels (unsigned-byte 32) :documentation "Number of channels of data in the file.") (num-chunks (unsigned-byte 32) :documentation "Number of chunk blocks that are in the file.") (:toplevel? t) (:documentation "Header block of TIDELog file. Implementations are required to support any TIDE file with the same major version as the implementation, although not all features supported by the file may be available. Note: num-channels and num-chunks are not used or written by RSBag and will hopefully be removed from the specification.")) (define-element (chan) (id (unsigned-byte 32) :documentation "Channel identification, used to link entries to the channel.") (name (:string (unsigned-byte 8)) :documentation "Name of the channel, as a character string.") (type (:string (unsigned-byte 32)) :documentation "String describing the type of the format.") (source-name (:string (unsigned-byte 32)) :documentation "Human-readable source description.") (source-config (:string (unsigned-byte 32)) :documentation "Raw data describing the source of this channel's data.") (format (:string (unsigned-byte 32)) :documentation "Raw data describing the format of the channel's data.") (:toplevel? t) (:documentation "The CHAN block stores the meta-data for one channel of data. A channel stores a set of data entries of a single type, indexed by time. The channel is identified internally within the file by its unique identification, stored in the `id' field. The channel may be identified externally by its id or by its unique human-readable name, stored in the `name' field. The `type' field indicates the type of source and format in use by this channel. It should indicate both the connection/transport type and serialization type, and will vary by these. For example, a logging tool for the OpenRTM-aist architecture may specify \"openrtm-cdr\" or \"openrtm-ros\" to indicate that the source connection was an OpenRTM-aist port using either the CDR serialisation or the ROS serialisation scheme. The `source-name' field provides a human-readable form of the source information. This allows introspection tools to describe the file contents more completely. For example, this field could contain the human-readable path of a ROS topic that provided the data. The `source-config' field provides space for describing the source of the channel's data in a machine-readable form. Typically this will describe the connection that was recorded. For example, an implementation for ROS may store the connection header in this field, while an implementation for OpenRTM-aist may store the name of the source port and the port's properties. The `format' field provides space for describing the serialized data. It is intended that this field contain enough information to deserialize the data stored in the file, such that it can be reconstructed later without any extra information from external to the file. For example, a ROS implementation may store the message description in this field.")) (define-element (indx) (channel-id (unsigned-byte 32) :documentation "Points to the channel this block indexes.") (count (unsigned-byte 32) :documentation "Number of indices in this block.") (entries (:repeated count index-entry)) (:toplevel? t) (:documentation "The INDX block provides an index for random-access in time to the data of one channel stored in the file. It links timestamps with the data values stored in the chunk blocks. This block has a fixed-length section consisting of the `channel-id' and `count' fields and a variable-length section consisting of COUNT `index-entry' elements.")) (define-element (index-entry) (chunk-id (unsigned-byte 32) :documentation "Points to the chunk this entry is stored in.") (timestamp (unsigned-byte 64) :documentation "Timestamp of the entry.") (offset (unsigned-byte 64) :documentation "Offset (in bytes) in the chunk's uncompressed data of the entry.") (:documentation "The offset points to the specific position in the data of the entry relative to the start of its chunk. If the chunk is compressed, the offset refers to the data once it has been uncompressed.")) (define-element (chnk) (chunk-id (unsigned-byte 32) :documentation "Chunk identification, used to link entries to chunks.") (count (unsigned-byte 32) :documentation "Number of entries in this chunk.") (start (unsigned-byte 64) :documentation "Timestamp of the first entry in this chunk.") (end (unsigned-byte 64) :documentation "Timestamp of the last entry in this chunk.") (compression (unsigned-byte 8) :documentation "Indicates the compression used on the entries. The value must be one of the following values: 0: No compression. 1: gzip compression. 2: bzip2 compression.") (entries (:repeated count chunk-entry)) (:toplevel? t) (:documentation "Each CHNK block stores a collection of recorded data items. This block has a fixed-length section consisting of the `chunk-id', `count', `start', `end' and `compression' fields and a variable-length section consisting of COUNT `chunk-entry' elements.")) (define-element (chunk-entry) (channel-id (unsigned-byte 32) :documentation "Points to the channel this entry belongs to.") (timestamp (unsigned-byte 64) :documentation "Timestamp of the entry.") (size (unsigned-byte 32) :documentation "Size of the following serialised data.") (entry (:blob size) :documentation "Serialized entry data.") (:documentation "A CHUNK-ENTRY block stores a single data item that was recorded on a particular channel and a particular point in time."))
7,172
Common Lisp
.lisp
157
37.280255
71
0.655951
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
fa2f085fa1108baaeadf79dd977cec05299e23c9353238ac82892acbcc45eb61
37,723
[ -1 ]
37,724
generator.lisp
open-rsx_rsbag-cl/src/backend/tidelog/generator.lisp
;;;; generator.lisp --- Generate data-holders and (de)serializers for TIDE log. ;;;; ;;;; Copyright (C) 2011, 2012, 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.tidelog) ;;; Class generator (defun specs->class (name specs &key documentation toplevel? (tag-name (string name))) (let ((tag `(load-time-value (sb-ext:string-to-octets ,tag-name :external-format :ascii)))) `(progn (defclass ,name () (,@(mapcar (curry #'spec->slot name) specs)) ,@(when documentation `((:documentation ,documentation)))) ,@(when toplevel? `((defmethod tag ((class (eql (find-class ',name)))) ,tag) (defmethod tag ((object ,name)) (tag (class-of object))) (let* ((class (find-class ',name)) (tag (tag class))) (setf (gethash tag *byte-pattern->block-class*) class))))))) (defun spec->slot (class-name spec) (let+ (((name type &key documentation) spec) (type (type-spec->lisp-type type)) (accessor-name (symbolicate class-name "-" name))) `(,name :initarg ,(make-keyword name) :type ,type :accessor ,accessor-name ,@(when documentation `(:documentation ,documentation))))) (defun type-spec->lisp-type (spec) (typecase spec ((cons (eql :string) list) 'string) ((cons (eql :repeated) list) 'vector) ((cons (eql :blob) list) 'nibbles:simple-octet-vector) (t spec))) ;;; Size method (defun specs->size (class-name specs) `(defmethod size ((object ,class-name)) (+ ,@(mapcar (rcurry #'spec->size class-name 'object) specs)))) (defun spec->size (spec class-name object) (let+ (((name type &rest &ign) spec) (accessor-name (symbolicate class-name "-" name))) (type-spec->size type `(,accessor-name ,object)))) (defun type-spec->size (type-spec value) (etypecase type-spec ((cons keyword list) (destructuring-ecase type-spec ((:repeated count-slot sub-type) (declare (ignore count-slot)) `(iter (for val each ,value) (summing ,(type-spec->size sub-type 'val)))) ((:blob length-slot) (declare (ignore length-slot)) `(length ,value)) ((:string length-type) `(+ ,(type-spec->size length-type :unused) (length ,value))))) ((cons (eql unsigned-byte) list) (/ (second type-spec) 8)) (symbol `(size ,value)))) ;;; Deserializer (defun specs->deserializer (class-name specs) `(defmethod unpack ((source simple-array) (object ,class-name) &optional (start 0)) (check-type source nibbles:simple-octet-vector) (let ((offset start)) ,@(mapcar (rcurry #'spec->deserializer class-name 'source 'object 'offset) specs) (values object (- offset start))))) (defun spec->deserializer (spec class-name source object offset) (let+ (((name type &rest &ign) spec) (accessor-name (symbolicate class-name "-" name))) `(let+ (((&values value length) ,(type-spec->deserializer type source offset))) (declare (type ,(type-spec->lisp-type type) value)) (setf (,accessor-name ,object) value) (incf offset length)))) (defun type-spec->deserializer (type-spec source offset) (etypecase type-spec ((cons keyword list) (destructuring-ecase type-spec ((:repeated count-slot sub-type) `(iter (repeat (slot-value object ',count-slot)) ; TODO(jmoringe): slot access (with offset = ,offset) (restart-case (let+ (((&values value length) ,(type-spec->deserializer sub-type source offset))) (incf offset length) (collect value :into result :result-type vector) (summing length :into length*)) (continue (&optional condition) :report (lambda (stream) (format stream "~@<Ignore the rest of the ~ ~S chunk at (local ~ offset) ~ ~/rsbag.backend:print-offset/ ~ and continue ~ processing.~@:>" ',type-spec offset)) (declare (ignore condition)) (terminate))) (finally (return (values result length*))))) ((:blob length-slot) `(let* ((length (slot-value object ',length-slot))) ; TODO(jmoringe): slot access (values (subseq ,source ,offset (+ ,offset length)) length))) ((:string length-type) `(let+ (((&values length length-length) ,(type-spec->deserializer length-type source offset)) (data-offset (+ ,offset length-length))) (values (sb-ext:octets-to-string source :start data-offset :end (+ data-offset length)) (+ length-length length)))))) ((cons (eql unsigned-byte) list) (ecase (second type-spec) (8 `(values (aref ,source ,offset) 1)) (32 `(values (nibbles:ub32ref/le ,source ,offset) 4)) (64 `(values (nibbles:ub64ref/le ,source ,offset) 8)))) (symbol `(let ((object (allocate-instance (find-class ',type-spec)))) (unpack ,source object ,offset))))) ;;; Serializer (defun specs->serializer (class-name specs &key toplevel?) (let+ (((&flet make-pack-method (source-class medium &key source-type) `(defmethod pack ((object ,class-name) (source ,source-class) &optional (start 0)) ,@(when source-type `((check-type source ,source-type))) (check-type start non-negative-integer) (let ((offset start)) ,@(mapcar (rcurry #'spec->serializer class-name medium 'source 'object 'offset) specs) (- offset start)))))) `(progn ,(make-pack-method 'simple-array :buffer :source-type 'nibbles:simple-octet-vector) ,(make-pack-method 'stream :stream) ,@(when toplevel? `((defmethod pack :around ((object ,class-name) (source stream) &optional start) (declare (ignore start)) (write-sequence (load-time-value (tag (find-class ',class-name))) source) (nibbles:write-ub64/le (size object) source) (call-next-method))))))) (defun spec->serializer (spec class-name medium source object offset) (let+ (((name type &rest &ign) spec) (accessor-name (symbolicate class-name "-" name)) (next-function (symbolicate '#:type-spec->serializer/ medium))) `(let ((value (,accessor-name ,object))) (declare (type ,(type-spec->lisp-type type) value)) (incf offset ,(funcall next-function type 'value source offset))))) (defun type-spec->serializer/buffer (type-spec value source offset) (etypecase type-spec ((cons keyword list) (destructuring-ecase type-spec ((:repeated count-slot sub-type) (declare (ignore count-slot)) `(iter (for val each value) (with offset* = ,offset) (incf offset* ,(type-spec->serializer/buffer sub-type 'val source 'offset*)) (finally (return (- offset* ,offset))))) ((:blob length-slot) (declare (ignore length-slot)) `(progn (setf (subseq ,source ,offset (+ ,offset (length ,value))) value) (length ,value))) ((:string length-type) `(let ((offset* ,offset) (octets (sb-ext:string-to-octets ,value))) (incf offset* ,(type-spec->serializer/buffer length-type '(length octets) source 'offset*)) (replace ,source octets :start1 offset*) (incf offset* (length octets)) (- offset* ,offset))))) ((cons (eql unsigned-byte) list) `(progn ,(ecase (second type-spec) (8 `(setf (aref ,source ,offset) ,value)) (32 `(setf (nibbles:ub32ref/le ,source ,offset) ,value)) (64 `(setf (nibbles:ub64ref/le ,source ,offset) ,value))) ,(/ (second type-spec) 8))) (symbol `(pack ,value ,source ,offset)))) (defun type-spec->serializer/stream (type-spec value source offset) (etypecase type-spec ((cons keyword list) (destructuring-ecase type-spec ((:repeated count-slot sub-type) (declare (ignore count-slot)) `(iter (for val each value) (with offset* = ,offset) (incf offset* ,(type-spec->serializer/stream sub-type 'val source 'offset*)) (finally (return (- offset* ,offset))))) ((:blob length-slot) (declare (ignore length-slot)) `(progn (write-sequence ,value ,source) (length ,value))) ((:string length-type) `(let ((offset* ,offset) (octets (sb-ext:string-to-octets ,value))) (incf offset* ,(type-spec->serializer/stream length-type '(length octets) source 'offset*)) (write-sequence octets ,source) (incf offset* (length octets)) (- offset* ,offset))))) ((cons (eql unsigned-byte) list) `(progn ,(ecase (second type-spec) (8 `(write-byte ,value ,source)) (32 `(nibbles:write-ub32/le ,value ,source)) (64 `(nibbles:write-ub64/le ,value ,source))) ,(/ (second type-spec) 8))) (symbol `(pack ,value ,source ,offset))))
10,201
Common Lisp
.lisp
229
32.834061
91
0.542325
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8653776d3a60501bb9c1b892cf107bd12e7730eba91d42bd8f1cc0a50235e0f8
37,724
[ -1 ]
37,725
variables.lisp
open-rsx_rsbag-cl/src/backend/tidelog/variables.lisp
;;;; variables.lisp --- Variables used in the TIDE log file format backend. ;;;; ;;;; Copyright (C) 2011-2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.tidelog) ;;; Version variables (defconstant +format-version-major+ 0 "Major version of the TIDE log file format supported by this backend.") (defconstant +format-version-minor+ 0 "Minor version of the TIDE log file format supported by this backend.") ;;; Known block classes (declaim (type hash-table *byte-pattern->block-class*)) (defvar *byte-pattern->block-class* (make-hash-table :test #'equalp) "Stores a mapping from block tags as `octet-vecor' patterns to block classes.") (declaim (ftype (function (nibbles:simple-octet-vector &key (:if-does-not-exist t)) (values class &optional)) byte-pattern->block-class)) (defun byte-pattern->block-class (pattern &key (if-does-not-exist #'error)) "Return the block class corresponding to PATTERN. Act according to IF-DOES-NOT-EXIST, if there is no such class." (or (gethash pattern *byte-pattern->block-class*) (error-behavior-restart-case (if-does-not-exist (no-such-block-class-error :tag pattern)))))
1,264
Common Lisp
.lisp
28
40.857143
83
0.708809
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
09fecfbd13a2b493b0c5630fb5cb62fbcd98313416adff13914474e12eed817c
37,725
[ -1 ]
37,726
macros.lisp
open-rsx_rsbag-cl/src/backend/tidelog/macros.lisp
;;;; macros.lisp --- Macros for code generation. ;;;; ;;;; Copyright (C) 2011, 2012, 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.tidelog) (defmacro define-element ((name) &body specs-and-options) (check-type name symbol "a symbol") (let+ (((&values specs (&plist-r/o (documentation :documentation) (toplevel? :toplevel?))) (parse-specs-and-options specs-and-options))) `(progn ,(specs->class name specs :toplevel? toplevel? :documentation documentation) ,(specs->size name specs) ,(specs->serializer name specs :toplevel? toplevel?) ,(specs->deserializer name specs)))) (defun parse-specs-and-options (specs-and-options) (let ((specs (remove-if #'keywordp specs-and-options :key #'first)) (options (remove-if-not #'keywordp specs-and-options :key #'first))) (values specs (apply #'append options))))
1,084
Common Lisp
.lisp
23
37.521739
67
0.591296
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f5650b3a0ee3ff252b427a814723cdc260031a514b78815d73be6259ea09543a
37,726
[ -1 ]
37,727
package.lisp
open-rsx_rsbag-cl/src/backend/elan/package.lisp
;;;; package.lisp --- Package definition for the backend.elan module. ;;;; ;;;; Copyright (C) 2011, 2012, 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.backend.elan (:use #:cl #:alexandria #:split-sequence #:let-plus #:iterate #:rsbag #:rsbag.backend) ;; Variables (:export #:+format-version-major+ #:+format-version-minor+) (:documentation "This package contains a reading and writing backend for the XML-based EAF file format used by the Elan annotation software."))
577
Common Lisp
.lisp
21
24.285714
70
0.693841
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
a4a3ead9c571e19046d4e7dbbabcb8b253893dc8177957a32fdfc4ab67de7767
37,727
[ -1 ]
37,728
util.lisp
open-rsx_rsbag-cl/src/backend/elan/util.lisp
;;;; util.lisp --- Utilities used by the Elan backend. ;;;; ;;;; Copyright (C) 2013, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.elan) ;;; Utilities for cxml (defun parse/keep-open (stream builder) "Similar to `cxml:parse' but does not close STREAM." (cxml:parse (make-two-way-stream stream (make-broadcast-stream)) builder)) (defun serialize/keep-open (document stream) "Similar to `stp:serialize' but does not close STREAM." (stp:serialize document (cxml:make-octet-stream-sink (make-broadcast-stream stream)))) ;;; Timestamp utilities (declaim (inline milliseconds->nanoseconds nanoseconds->milliseconds)) (defun milliseconds->nanoseconds (value) (* value 1000000)) (defun nanoseconds->milliseconds (value) (floor value 1000000)) (defun nanoseconds->timestamp (value) (let+ (((&values secs nsecs) (truncate value 1000000000))) (local-time:unix-to-timestamp secs :nsec nsecs))) (defun timestamp->nanoseconds (value) (let+ (((&accessors-r/o (secs local-time:timestamp-to-unix) (nsecs local-time:nsec-of)) value)) (+ (* 1000000000 secs) nsecs)))
1,230
Common Lisp
.lisp
29
37.586207
70
0.691856
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
7fc294f4ed6e5237cfab8ba0beb87e3feb39e68f8fa93dcdfe6c62cf009f022b
37,728
[ -1 ]
37,729
types.lisp
open-rsx_rsbag-cl/src/backend/elan/types.lisp
;;;; types.lisp --- Types used in the rsbag Elan backend. ;;;; ;;;; Copyright (C) 2011-2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.elan) (deftype timestamp/milliseconds () "Time since reference timestamp in milliseconds." '(unsigned-byte 64)) (deftype timestamp/nanoseconds () "Time since reference timestamp in nanoseconds." '(unsigned-byte 64)) (deftype time-slot/cons () "A list of the form (ID TIMESTAMP) to be interpreted as an Elan time slot consisting of a string id and an associated `timestamp/nanoseconds'." '(cons string timestamp/nanoseconds)) (deftype annotation/list () "A list of the form (ID START-TIME-SLOT END-TIME-SLOT DATUM) to be interpreted as an annotation consisting of two time slot string ids and an associated string datum." '(cons string (cons string (cons string (cons string null))))) (deftype linguistic-type/list () "A list of the form (ID GRAPHIC-REFERENCES TIME-ALIGNABLE) to be interpreted as a linguistic type." '(cons string (cons boolean (cons boolean null)))) (deftype tier/list () "A list of the form (NAME LINGUISTIC-TYPE-REF ANNOTATIONS) to be interpreted as a named tier containing the annotation items ANNOTATIONS." '(cons string (cons string (cons list null)))) (deftype version/cons () "A version specification of the form (MAJOR . MINOR) ." '(cons non-negative-integer non-negative-integer)) (deftype file/list () "A list of the form (AUTHOR DATE MEDIA-URLS TIME-SLOTS TIERS) where MEDIA-URLS is a list of strings, TIME-SLOTS is a list of elements of type TIME-SLOT/CONS and TIERS is a list of elements of type TIER/LIST." '(cons string ; author (cons local-time:timestamp ; date in ISO timestamp format (cons list ; media URLs (cons list ; time slots (cons list)))))) ; tiers
2,080
Common Lisp
.lisp
51
36.098039
80
0.668825
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
a62523d8edfbdd9d5d5d11998b1a605a15f4bf6fb1125a93db1cebacfc8833df
37,729
[ -1 ]
37,730
xml.lisp
open-rsx_rsbag-cl/src/backend/elan/xml.lisp
;;;; xml.lisp --- To- and from-XML conversion for Elan types. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.elan) ;;; (defmethod xloc:xml-> ((value string) (type (eql 'boolean)) &key &allow-other-keys) (cond ((string= value "false") nil) ((string= value "true") t) (t (error "~@<Invalid value for type ~A: ~S~@:>" type value)))) (defmethod xloc:->xml ((value symbol) (dest (eql 'string)) (type (eql 'boolean)) &key &allow-other-keys) (check-type value boolean) (if value "true" "false")) ;;; time-slot/cons (defmethod xloc:xml-> ((value stp:element) (type (eql 'time-slot/cons)) &key &allow-other-keys) (xloc:with-locations-r/o (((:@ (id "TIME_SLOT_ID")) ".") ((:@ (value "TIME_VALUE") :type 'timestamp/milliseconds) ".")) value (cons id (milliseconds->nanoseconds value)))) (defmethod xloc:->xml ((value cons) (dest stp:element) (type (eql 'time-slot/cons)) &key &allow-other-keys) (check-type value time-slot/cons) (xloc:with-locations (((:@ (id "TIME_SLOT_ID")) ".") ((:@ (value* "TIME_VALUE") :type 'timestamp/milliseconds) ".")) dest (setf id (car value) value* (nanoseconds->milliseconds (cdr value)))) value) ;;; annotation/list (defmethod xloc:xml-> ((value stp:element) (type (eql 'annotation/list)) &key &allow-other-keys) (xloc:with-locations-r/o (((:@ (id "ANNOTATION_ID")) "ALIGNABLE_ANNOTATION") ((:@ (start "TIME_SLOT_REF1")) "ALIGNABLE_ANNOTATION") ((:@ (end "TIME_SLOT_REF2")) "ALIGNABLE_ANNOTATION") (associated-value "ALIGNABLE_ANNOTATION/ANNOTATION_VALUE/text()")) value (list id start end associated-value))) (defmethod xloc:->xml ((value list) (dest stp:element) (type (eql 'annotation/list)) &key &allow-other-keys) (check-type value annotation/list) (xloc:with-locations (((:@ (id "ANNOTATION_ID")) "ALIGNABLE_ANNOTATION") ((:@ (start "TIME_SLOT_REF1")) "ALIGNABLE_ANNOTATION") ((:@ (end "TIME_SLOT_REF2")) "ALIGNABLE_ANNOTATION") (associated-value "ALIGNABLE_ANNOTATION/ANNOTATION_VALUE/text()")) dest (multiple-value-setq (id start end associated-value) (values-list value))) value) ;;; linguistic-type/list (defmethod xloc:xml-> ((value stp:element) (type (eql 'linguistic-type/list)) &key &allow-other-keys) (xloc:with-locations-r/o (((:@ (id "LINGUISTIC_TYPE_ID")) ".") ((:@ (graphic-references? "GRAPHIC_REFERENCES") :type 'boolean) ".") ((:@ (time-alignable? "TIME_ALIGNABLE") :type 'boolean) ".")) value (list id graphic-references? time-alignable?))) (defmethod xloc:->xml ((value list) (dest stp:element) (type (eql 'linguistic-type/list)) &key &allow-other-keys) (check-type value linguistic-type/list) (xloc:with-locations (((:@ (id "LINGUISTIC_TYPE_ID")) ".") ((:@ (graphic-references? "GRAPHIC_REFERENCES") :type 'boolean) ".") ((:@ (time-alignable? "TIME_ALIGNABLE") :type 'boolean) ".")) dest (multiple-value-setq (id graphic-references? time-alignable?) (values-list value))) value) ;;; tier/list (defmethod xloc:xml-> ((value stp:element) (type (eql 'tier/list)) &key &allow-other-keys) (xloc:with-locations-r/o (((:@ (id "TIER_ID")) ".") ((:@ (linguistic-type-ref "LINGUISTIC_TYPE_REF")) ".") ((:val annotations :type 'annotation/list) "ANNOTATION" :if-multiple-matches :all)) value (list id linguistic-type-ref annotations))) (defmethod xloc:->xml ((value list) (dest stp:element) (type (eql 'tier/list)) &key &allow-other-keys) (check-type value tier/list) (xloc:with-locations (((:@ (id "TIER_ID")) ".") ((:@ (linguistic-type-ref "LINGUISTIC_TYPE_REF")) ".") ((:val annotations :type 'annotation/list) "ANNOTATION" :assign-mode :append)) dest (multiple-value-setq (id linguistic-type-ref annotations) (values-list value))) value) ;;; File (defmethod xloc:xml-> ((value string) (type (eql 'version/cons)) &key &allow-other-keys) (let ((index (or (position #\. value) (error "~@<No \".\" in ~S~@:>" value)))) (cons (parse-integer value :end index) (parse-integer value :start (1+ index))))) (defmethod xloc:->xml ((value cons) (dest (eql 'string)) (type (eql 'version/cons)) &key &allow-other-keys) (check-type value version/cons) (format nil "~D.~D" (car value) (cdr value))) (defmethod xloc:xml-> ((value stp:element) (type (eql 'file/list)) &key &allow-other-keys) (xloc:with-locations-r/o (((:@ (format "FORMAT") :type 'version/cons) ".") ((:@ (version "VERSION") :type 'version/cons) ".") ((:@ (author "AUTHOR")) ".") ((:@ (date "DATE") :type 'local-time:timestamp) ".") ;; ((:@ (time-units "TIME_UNITS")) "HEADER") ((:@ (urls "MEDIA_URL")) "HEADER/MEDIA_DESCRIPTOR" :if-multiple-matches :all) ((:val time-slots :type 'time-slot/cons) "TIME_ORDER/TIME_SLOT" :if-multiple-matches :all) ((:val tiers :type 'tier/list) "TIER" :if-multiple-matches :all)) value (unless (= +format-version-major+ (car version)) (cerror "Try to process the file anyway." "~@<Cannot process format version ~D.~D (major version ~ is different from ~D.~D)~@:>" (car version) (cdr version) +format-version-major+ +format-version-minor+)) (values (list author date urls time-slots tiers) format version))) ; TODO version should be part of file/list? (defmethod xloc:->xml ((value list) (dest stp:element) (type (eql 'file/list)) &key &allow-other-keys) (check-type value file/list) (xloc:with-locations (((:@ (schema "xsi:noNamespaceSchemaLocation")) "." :namespaces '(("xsi" . "http://www.w3.org/2001/XMLSchema-instance"))) ((:@ (format "FORMAT") :type 'version/cons) ".") ((:@ (version "VERSION") :type 'version/cons) ".") ((:@ (author "AUTHOR")) ".") ((:@ (date "DATE") :type 'local-time:timestamp) ".") ((:@ (time-units "TIME_UNITS")) "HEADER") ((:@ (urls "MEDIA_URL")) "HEADER/MEDIA_DESCRIPTOR" :assign-mode :append) ((:val slots :type 'time-slot/cons) "TIME_ORDER/TIME_SLOT" :assign-mode :append) ((:val tiers :type 'tier/list) "TIER" :assign-mode :append) ((:val linguistic-types :type 'linguistic-type/list) "LINGUISTIC_TYPE" :assign-mode :append)) dest (let ((version/cons (cons +format-version-major+ +format-version-minor+))) (multiple-value-setq (schema format version time-units) (values (princ-to-string +schema-url+) version/cons version/cons "milliseconds"))) (multiple-value-setq (author date urls slots tiers) (values-list value)) (setf linguistic-types '(("Default" nil t)))) value)
8,470
Common Lisp
.lisp
181
37.353591
114
0.50926
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
993c1b51d14f6688b384103297e827f1e414dc0fe502b31c64ef340dd2eb3ed3
37,730
[ -1 ]
37,731
variables.lisp
open-rsx_rsbag-cl/src/backend/elan/variables.lisp
;;;; variables.lisp --- Variables used by the Elan backend. ;;;; ;;;; Copyright (C) 2013 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.elan) (defparameter +schema-url+ (puri:uri "http://www.mpi.nl/tools/elan/EAFv2.7.xsd")) (defparameter +format-version-major+ 2 "Major version of the ELAN format.") (defparameter +format-version-minor+ 2 "Minor version of the ELAN format.")
450
Common Lisp
.lisp
12
35.666667
61
0.723502
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
ab89ddd7d1492279606c0635bc5fdc983590b1617327f3b60140021983bccf4b
37,731
[ -1 ]
37,732
file.lisp
open-rsx_rsbag-cl/src/backend/elan/file.lisp
;;;; file.lisp --- Elan file format support. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.backend.elan) (defclass file (stream-mixin direction-mixin) ((author :type (or null string) :accessor file-%author :initform nil :documentation "Stores the author of the file.") (channels :type list :reader get-channels :accessor file-%channels :initform '() :documentation "Stores information of the channels (or tiers, rather) present in the file. Entries are of the form (ID NAME META-DATA) where ID is the numeric id of the channel, NAME is the name as string and META-DATA is a plist of additional data associated to the channel.") (data :type hash-table :reader file-%data :initform (make-hash-table :test #'eq) :documentation "Maps channel ids to channel data. Each entry of a channel is of the form (START END DATUM) where START and END are the start and end timestamps respectively and DATUM is the (string) datum of the entry.") (document :type stp:document :accessor file-%document :documentation "Stores the `stp:document' instance which contains the DOM representation of the file. The document is not updated continuously but only on write-back.") (next-channel-id :type non-negative-integer :accessor file-%next-channel-id :initform 0 :documentation "Stores the id that will be assigned to the next new channel.")) (:documentation "Instances of this class represent Elan eaf-files. All data is serialized and written or read and deserialized when the file is written or read respectively.")) (service-provider:register-provider/class 'backend :eaf :class 'file) (defmethod shared-initialize :after ((instance file) (slot-names t) &key) (let+ (((&accessors (direction backend-direction) (stream backend-stream) (document file-%document) (author file-%author) (channels file-%channels) (data file-%data) (next-channel-id file-%next-channel-id)) instance) (urls '()) (time-slots '()) (tiers '()) (base-time (local-time:now)) ((&flet resolve (id) (+ (timestamp->nanoseconds base-time) (cdr (assoc id time-slots :test #'string=)))))) (cond ;; Data is available - parse as XML document. ((and (member direction '(:input :io)) (listen stream)) (setf document (parse/keep-open stream (stp:make-builder))) (setf (values author base-time urls time-slots tiers) (values-list (xloc:xml-> (stp:document-element document) 'file/list)))) ;; No data is available, but direction implies output - ;; create an empty XML document and write it back later. ((member direction '(:output :io)) (setf document (stp:make-document (stp:make-element "ANNOTATION_DOCUMENT")))) ;; No data is available and direction does not imply ;; output - signal an error. (t (error "~@<Trying to read an empty EAF file from: ~S~@:>" stream))) ;; Add video channels. (iter (for url each urls :with-index i) (let* ((name (format nil "video~D" i)) (id (make-channel-id instance name))) (push (list id name `(:type (,rsbag.transform:+rsb-schema-name+ :|.rst.vision.Image|))) channels))) ;; Add annotation channels. (iter (for (name linguistic-type-ref content) in tiers) (let ((id (make-channel-id instance name))) (push (list id name `(:type :utf-8-string :linguistic-type ,linguistic-type-ref)) channels) (setf (gethash id data) (map 'list (lambda+ ((&ign start end datum)) (list (resolve start) (resolve end) datum)) content)))))) (defmethod close ((file file) &key abort) (declare (ignore abort)) (when (member (backend-direction file) '(:output :io)) (let+ (((&accessors-r/o (stream backend-stream) (document file-%document) (author file-%author) (channels file-%channels) (data file-%data)) file) (current-time-slot-id 0) ((&flet make-time-slot-id () (format nil "ts~D" (incf current-time-slot-id)))) (time-slots (make-hash-table :test #'eql)) ((&flet time-slot (timestamp) (ensure-gethash timestamp time-slots (make-time-slot-id)))) (current-annotation-id 0) ((&flet make-annotation-id () (format nil "as~D" (incf current-annotation-id)))) (tiers (iter (for (id name meta-data) in channels) (for entries next (gethash id data)) (collect (list name (getf meta-data :linguistic-type "Default") (map 'list (lambda+ ((start end datum)) (list (make-annotation-id) (time-slot start) (time-slot end) datum)) (sort (coerce entries 'vector) #'< :key #'first)))))) (base-time (or (extremum (hash-table-keys time-slots) #'<) 0)) (time-slots/cons (iter (for (timestamp id) in-hashtable time-slots) (collect (cons id (- timestamp base-time)))))) (xloc:->xml (list (or author "") (nanoseconds->timestamp base-time) '() time-slots/cons tiers) ; TODO(jmoringe, 2011-12-01): media stuff (stp:document-element document) 'file/list) (file-position stream 0) (serialize/keep-open document stream))) (when (next-method-p) (call-next-method))) (defmethod make-channel-id ((backend file) (name string)) (prog1 (file-%next-channel-id backend) (incf (file-%next-channel-id backend)))) (defmethod put-channel ((backend file) (channel integer) (name string) (meta-data list)) (let+ (((&plist-r/o (type :type :utf-8-string)) meta-data) ((&accessors (channels file-%channels)) backend)) (unless (eq type :utf-8-string) (error "~@<Cannot handle channel type ~S; only ~S is supported.~@:>" type :utf-8-string)) (push (list channel name (append (remove-from-plist meta-data :type) (list :type type))) channels))) (defmethod get-num-entries ((file file) (channel integer)) (length (gethash channel (file-%data file)))) (defmethod get-timestamps ((file file) (channel integer)) (map 'list #'first (gethash channel (file-%data file)))) (defmethod get-entry-at-index ((file file) (channel integer) (index integer)) (third (nth index (gethash channel (file-%data file))))) (defmethod get-entry-at-time ((file file) (channel integer) (timestamp local-time:timestamp)) (third (find timestamp (gethash channel (file-%data file)) :test #'local-time:timestamp= :key #'first))) (defmethod put-entry ((file file) (channel integer) (timestamp integer) (entry string)) (let+ (((&accessors-r/o (data file-%data)) file)) (push (list timestamp timestamp entry) (gethash channel data))))
8,935
Common Lisp
.lisp
179
34.162011
131
0.503263
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
3a3dfd5c8b4998b4ae8d141743d131fcdfbf21b46644a9c64b4aae6ead309e64
37,732
[ -1 ]
37,733
package.lisp
open-rsx_rsbag-cl/src/rsb/package.lisp
;;;; package.lisp --- Package definition for rsb module. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.rsb (:use #:cl #:alexandria #:let-plus #:iterate #:more-conditions #:rsbag #:rsbag.transform #:rsbag.view #:rsb) (:shadowing-import-from #:rsbag #:direction #:meta-data #:meta-data-count #:meta-data-keys #:meta-data-values #:meta-data-plist #:meta-data-alist) ;; Conditions (:export #:connection-condition #:connection-condition-connection #:entry-condition #:entry-condition-entry) ;; connection construction protocol (:export #:events->bag #:bag->events) ;; connection protocol (:export #:done? #:wait #:start #:stop) ;; Convenience macros (:export #:with-open-connection #:with-events->bag #:with-bag->events) ;; Composite connection protocol and `composite-connection-mixin' class (:export #:connection-direct-connections #:connection-connections #:composite-connection-mixin) ;; `bag-connection' class and protocol (:export #:bag-connection #:connection-bag #:connection-channels) ;; `recording-bag-connection' class (:export #:recording-bag-connection) ;; `channel-connection' class and protocol (:export #:channel-connection) ;; `endpoint-channel-connection' class and protocol (:export #:endpoint-channel-connection #:connection-endpoint) ;; `participant-channel-connection' subclass (:export #:participant-channel-connection) (:documentation "This package contains functions and classes that enable the recording and playback of RSB events into/from rsbag log files."))
1,767
Common Lisp
.lisp
71
21.15493
73
0.702687
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
100547b93bc96a2d017a1e1cda1bd9398e3f4a7e22f6df92711da8a7a19920b3
37,733
[ -1 ]
37,734
channel-connection.lisp
open-rsx_rsbag-cl/src/rsb/channel-connection.lisp
;;;; channel-connection.lisp --- A class for bag channel <-> RSB connections. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.rsb) ;;; `channel-connection' class (defclass channel-connection (rsb.ep:error-policy-mixin print-items:print-items-mixin) ((bag :initarg :bag :reader connection-bag :documentation "Stores the bag object that is connected to event sources or sinks.") (channels :initarg :channels :type list :accessor connection-channels :initform '() :documentation "Stores the bag channels that are connected to event sources or sinks by the connection.")) (:default-initargs :bag (missing-required-initarg 'channel-connection :bag)) (:documentation "Connection between bag channels and an event source or sink.")) (defmethod close ((connection channel-connection) &key abort) (declare (ignore abort))) ; nothing to do (defmethod print-items:print-items append ((object channel-connection)) `((:channel-count ,(length (connection-channels object)) " (~D)"))) ;;; `endpoint-channel-connection' class (defclass endpoint-channel-connection (channel-connection) ((endpoint :initarg :endpoint :reader connection-endpoint :documentation "Stores the endpoint that is connected to a bag channel.")) (:default-initargs :endpoint (missing-required-initarg 'endpoint-channel-connection :endpoint)) (:documentation "Instances of this class represent the connections being established when individual channels of bags are used as data sources or sinks and connected to event sources or sinks such as functions or RSB participants.")) ;;; `participant-channel-connection' class (defclass participant-channel-connection (endpoint-channel-connection) () (:documentation "A `channel-connection' with an RSB participant endpoint.")) (defmethod shared-initialize :after ((instance participant-channel-connection) (slot-names t) &key) (setf (rsb.ep:processor-error-policy instance) (rsb.ep:processor-error-policy instance))) (defmethod (setf rsb.ep:processor-error-policy) :before ((new-value t) (object participant-channel-connection)) (setf (hooks:hook-handlers (rsb:participant-error-hook (connection-endpoint object))) (when new-value (list new-value)))) (defmethod close ((connection participant-channel-connection) &key abort) (declare (ignore abort)) (detach/ignore-errors (connection-endpoint connection)))
2,800
Common Lisp
.lisp
61
38.606557
87
0.679135
open-rsx/rsbag-cl
0
0
2
LGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
ba5c975f026482ed4fe7657d0715455223c506d2f0c387c71b562491733a0c91
37,734
[ -1 ]