Add initial conversion framework to OS10
This commit is contained in:
21
.gitmodules
vendored
21
.gitmodules
vendored
@ -4,3 +4,24 @@
|
|||||||
[submodule "tools/cl-yacc"]
|
[submodule "tools/cl-yacc"]
|
||||||
path = tools/cl-yacc
|
path = tools/cl-yacc
|
||||||
url = https://github.com/jech/cl-yacc.git
|
url = https://github.com/jech/cl-yacc.git
|
||||||
|
[submodule "tools/cxml"]
|
||||||
|
path = tools/cxml
|
||||||
|
url = https://apps.pmsf.net/stash/scm/oscl/cxml.git
|
||||||
|
[submodule "tools/closure-common"]
|
||||||
|
path = tools/closure-common
|
||||||
|
url = https://apps.pmsf.net/stash/scm/oscl/closure-common.git
|
||||||
|
[submodule "tools/trivial-gray-streams"]
|
||||||
|
path = tools/trivial-gray-streams
|
||||||
|
url = git://github.com/trivial-gray-streams/trivial-gray-streams.git
|
||||||
|
[submodule "tools/puri"]
|
||||||
|
path = tools/puri
|
||||||
|
url = https://apps.pmsf.net/stash/scm/oscl/puri.git
|
||||||
|
[submodule "tools/babel"]
|
||||||
|
path = tools/babel
|
||||||
|
url = git://github.com/cl-babel/babel.git
|
||||||
|
[submodule "tools/trivial-features"]
|
||||||
|
path = tools/trivial-features
|
||||||
|
url = https://github.com/trivial-features/trivial-features.git
|
||||||
|
[submodule "tools/alexandria"]
|
||||||
|
path = tools/alexandria
|
||||||
|
url = https://gitlab.common-lisp.net/alexandria/alexandria.git
|
||||||
|
|||||||
11
OSN.asd
11
OSN.asd
@ -22,10 +22,14 @@
|
|||||||
:components ((:module "lib"
|
:components ((:module "lib"
|
||||||
:components
|
:components
|
||||||
((:file "pkgdef")
|
((:file "pkgdef")
|
||||||
(:file "macro-utilities"
|
(:file "macro-utilities"
|
||||||
:depends-on ("pkgdef"))
|
:depends-on ("pkgdef"))
|
||||||
(:file "common-utilities"
|
(:file "common-utilities"
|
||||||
:depends-on ("pkgdef"))
|
:depends-on ("pkgdef"))
|
||||||
|
(:file "float-utilities"
|
||||||
|
:depends-on ("pkgdef"))
|
||||||
|
(:file "time-utilities"
|
||||||
|
:depends-on ("pkgdef"))
|
||||||
(:file "parsing-utilities"
|
(:file "parsing-utilities"
|
||||||
:depends-on ("pkgdef"))))
|
:depends-on ("pkgdef"))))
|
||||||
(:module "src"
|
(:module "src"
|
||||||
@ -34,6 +38,7 @@
|
|||||||
(:file "conditions" :depends-on ("pkgdef"))
|
(:file "conditions" :depends-on ("pkgdef"))
|
||||||
(:file "osn" :depends-on ("pkgdef"))
|
(:file "osn" :depends-on ("pkgdef"))
|
||||||
(:file "osn-parser" :depends-on ("pkgdef" "conditions" "osn"))
|
(:file "osn-parser" :depends-on ("pkgdef" "conditions" "osn"))
|
||||||
(:file "osn-writer" :depends-on ("pkgdef" "conditions" "osn")))
|
(:file "osn-writer" :depends-on ("pkgdef" "conditions" "osn"))
|
||||||
|
(:file "osn-to-os10" :depends-on ("pkgdef" "conditions" "osn")))
|
||||||
:depends-on ("lib")))
|
:depends-on ("lib")))
|
||||||
:depends-on ("cl-ppcre" "yacc"))
|
:depends-on ("cl-ppcre" "yacc" "cxml"))
|
||||||
|
|||||||
@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
(cl:in-package #:pmsf-lib)
|
(cl:in-package #:pmsf-lib)
|
||||||
|
|
||||||
(pmsf-lib:file-version :pmsf-lib "$Id$")
|
|
||||||
|
|
||||||
;;;; %File Description:
|
;;;; %File Description:
|
||||||
;;;;
|
;;;;
|
||||||
;;;; This file contains utilities for AES encryption
|
;;;; This file contains utilities for AES encryption
|
||||||
|
|||||||
@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
(cl:in-package #:pmsf-lib)
|
(cl:in-package #:pmsf-lib)
|
||||||
|
|
||||||
(pmsf-lib:file-version :pmsf-lib "$Id$")
|
|
||||||
|
|
||||||
;;;; %File Description:
|
;;;; %File Description:
|
||||||
;;;;
|
;;;;
|
||||||
;;;; This file contains utilities to access the command line and to
|
;;;; This file contains utilities to access the command line and to
|
||||||
|
|||||||
87
lib/doc.lisp
87
lib/doc.lisp
@ -1,87 +0,0 @@
|
|||||||
;;;; PMSF-Lib --- PMSF Common Lisp Utility Library
|
|
||||||
;;;; This is copyrighted software. See documentation for terms.
|
|
||||||
;;;;
|
|
||||||
;;;; doc.lisp --- Documentation of file origins and versions
|
|
||||||
;;;;
|
|
||||||
;;;; $Id$
|
|
||||||
|
|
||||||
(cl:in-package #:pmsf-lib)
|
|
||||||
|
|
||||||
;;;; %File Description:
|
|
||||||
;;;;
|
|
||||||
;;;; This file provides mechanisms to record the id of files compiled
|
|
||||||
;;;; and loaded to create a runtime image.
|
|
||||||
;;;;
|
|
||||||
|
|
||||||
(defvar *file-versions* nil
|
|
||||||
"Associaton list of loaded file-ids.")
|
|
||||||
|
|
||||||
(defmacro file-version (system id-string)
|
|
||||||
"Register the File-Id `id-string' in the system `system'."
|
|
||||||
;; On CMUCL we use `ext:file-comment' in addition to our own
|
|
||||||
;; tracking, so that the File-Id gets embedded in the fasl, and can
|
|
||||||
;; be seen in descriptions of functions, etc. See the documentation
|
|
||||||
;; of `ext:file-comment' for more details.
|
|
||||||
`(progn
|
|
||||||
#+cmucl
|
|
||||||
(ext:file-comment ,id-string)
|
|
||||||
;; Do compile-time processing by MD5 checksumming the file itself.
|
|
||||||
(process-file-version ',system *load-truename* ',id-string
|
|
||||||
',*compile-file-truename*
|
|
||||||
',(md5:md5sum-file *compile-file-truename*))))
|
|
||||||
|
|
||||||
(defun process-file-version (system file-name id-string
|
|
||||||
source-file-name source-md5)
|
|
||||||
"Load-time part of `file-version'."
|
|
||||||
(let* ((system-list (or (assoc system *file-versions*)
|
|
||||||
(let ((sys (cons system nil)))
|
|
||||||
(push sys *file-versions*)
|
|
||||||
sys)))
|
|
||||||
(file-entry (or (assoc file-name (cdr system-list) :test #'equal)
|
|
||||||
(let ((entry (cons file-name nil)))
|
|
||||||
(push entry (cdr system-list))
|
|
||||||
entry))))
|
|
||||||
(setf (cdr file-entry)
|
|
||||||
(list id-string (md5:md5sum-file file-name)
|
|
||||||
source-file-name source-md5))
|
|
||||||
nil))
|
|
||||||
|
|
||||||
(defun get-file-versions (system)
|
|
||||||
(let ((system-list (assoc system *file-versions*)))
|
|
||||||
(if system-list
|
|
||||||
(cdr system-list)
|
|
||||||
(error "System ~S not found!" system))))
|
|
||||||
|
|
||||||
(defun list-file-versions (system)
|
|
||||||
(loop for (path id) in (get-file-versions system)
|
|
||||||
do
|
|
||||||
(format t "~20A ~A~%" path id)
|
|
||||||
initially
|
|
||||||
(format t "~&~20A ~A~2%" "Path" "Version-Id")))
|
|
||||||
|
|
||||||
(defun list-file-checksums (system)
|
|
||||||
(loop for (path nil md5) in (get-file-versions system)
|
|
||||||
do
|
|
||||||
(format t "~40A ~{~2,'0X~}~%" path (coerce md5 'list))
|
|
||||||
initially
|
|
||||||
(format t "~&~40A ~32A~2%" "Path" "MD5")))
|
|
||||||
|
|
||||||
(defun list-source-checksums (system)
|
|
||||||
(loop for (nil nil nil source-path source-md5) in (get-file-versions system)
|
|
||||||
do
|
|
||||||
(format t "~40A ~{~2,'0X~}~%" source-path (coerce source-md5 'list))
|
|
||||||
initially
|
|
||||||
(format t "~&~40A ~32A~2%" "Source-Path" "MD5")))
|
|
||||||
|
|
||||||
(defun md5-file-versions (system)
|
|
||||||
(md5:md5sum-string
|
|
||||||
(with-output-to-string (stream)
|
|
||||||
(loop for (path id md5) in (sort (copy-list (get-file-versions system))
|
|
||||||
#'string< :key
|
|
||||||
(lambda (x)
|
|
||||||
(if (pathnamep (car x))
|
|
||||||
(namestring (car x))
|
|
||||||
(car x))))
|
|
||||||
do
|
|
||||||
(format stream "~A!~A!~{~2,'0X~}~%" path id (coerce md5 'list))))
|
|
||||||
:external-format :utf-8))
|
|
||||||
@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
(cl:in-package #:pmsf-lib)
|
(cl:in-package #:pmsf-lib)
|
||||||
|
|
||||||
(pmsf-lib:file-version :pmsf-lib "$Id$")
|
|
||||||
|
|
||||||
;;;; %File Description:
|
;;;; %File Description:
|
||||||
;;;;
|
;;;;
|
||||||
;;;; This file contains utilities for handling floating point
|
;;;; This file contains utilities for handling floating point
|
||||||
|
|||||||
@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
(cl:in-package #:pmsf-pecoff)
|
(cl:in-package #:pmsf-pecoff)
|
||||||
|
|
||||||
(pmsf-lib:file-version :pmsf-lib "$Id$")
|
|
||||||
|
|
||||||
;;;; %File Description:
|
;;;; %File Description:
|
||||||
;;;;
|
;;;;
|
||||||
;;;; This file contains utilities for PE/COFF file handling
|
;;;; This file contains utilities for PE/COFF file handling
|
||||||
|
|||||||
@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
(cl:in-package #:pmsf-lib)
|
(cl:in-package #:pmsf-lib)
|
||||||
|
|
||||||
(pmsf-lib:file-version :pmsf-lib "$Id$")
|
|
||||||
|
|
||||||
;;;; %File Description:
|
;;;; %File Description:
|
||||||
;;;;
|
;;;;
|
||||||
;;;; This file contains a pipe-stream implementation based on
|
;;;; This file contains a pipe-stream implementation based on
|
||||||
|
|||||||
@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
(cl:in-package #:pmsf-lib)
|
(cl:in-package #:pmsf-lib)
|
||||||
|
|
||||||
(pmsf-lib:file-version :pmsf-lib "$Id$")
|
|
||||||
|
|
||||||
;;;; %File Description:
|
;;;; %File Description:
|
||||||
;;;;
|
;;;;
|
||||||
;;;; This file contains a parser for C-style printf format
|
;;;; This file contains a parser for C-style printf format
|
||||||
|
|||||||
@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
(cl:in-package #:pmsf-lib)
|
(cl:in-package #:pmsf-lib)
|
||||||
|
|
||||||
(pmsf-lib:file-version :pmsf-lib "$Id$")
|
|
||||||
|
|
||||||
;;;; %File Description:
|
;;;; %File Description:
|
||||||
;;;;
|
;;;;
|
||||||
;;;; This file contains utilities for time processing, especially time
|
;;;; This file contains utilities for time processing, especially time
|
||||||
|
|||||||
@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
(cl:in-package #:pmsf-lib)
|
(cl:in-package #:pmsf-lib)
|
||||||
|
|
||||||
(pmsf-lib:file-version :pmsf-lib "$Id$")
|
|
||||||
|
|
||||||
;;;; %File Description:
|
;;;; %File Description:
|
||||||
;;;;
|
;;;;
|
||||||
;;;; This file contains utilities for ZIP archive processing.
|
;;;; This file contains utilities for ZIP archive processing.
|
||||||
|
|||||||
@ -21,5 +21,8 @@
|
|||||||
;; The OSN directory itself
|
;; The OSN directory itself
|
||||||
(push base-dir asdf:*central-registry*)
|
(push base-dir asdf:*central-registry*)
|
||||||
;; All needed and bundled tools
|
;; All needed and bundled tools
|
||||||
(dolist (path '(#p"tools/cl-ppcre/" #p"tools/cl-yacc/"))
|
(dolist (path '(#p"tools/cl-ppcre/" #p"tools/cl-yacc/" #p"tools/puri/"
|
||||||
|
#p"tools/trivial-gray-streams/" #p"tools/trivial-features/"
|
||||||
|
#p"tools/alexandria/" #p"tools/babel/"
|
||||||
|
#p"tools/closure-common/" #p"tools/cxml/"))
|
||||||
(push (merge-pathnames path base-dir) asdf:*central-registry*)))
|
(push (merge-pathnames path base-dir) asdf:*central-registry*)))
|
||||||
|
|||||||
77
src/osn-to-os10.lisp
Normal file
77
src/osn-to-os10.lisp
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
;;;; OpenScenarioNext --- OpenScenario Language Design
|
||||||
|
;;;; This is copyrighted software. See documentation for terms.
|
||||||
|
;;;;
|
||||||
|
;;;; osn-to-os10.lisp --- OpenScenarioNext To OpenSCENARIO 1.0
|
||||||
|
|
||||||
|
(cl:in-package #:openscenarionext-os10)
|
||||||
|
|
||||||
|
;;;; %File Description:
|
||||||
|
;;;;
|
||||||
|
;;;; Conversion of OpenScenarioNext to OpenSCENARIO 1.0
|
||||||
|
;;;;
|
||||||
|
|
||||||
|
(defun write-os10-stream (osn stream)
|
||||||
|
(cxml:with-xml-output (cxml:make-character-stream-sink
|
||||||
|
stream :indentation 2 :canonical nil)
|
||||||
|
(cxml:with-element "OpenSCENARIO"
|
||||||
|
(cxml:with-element "FileHeader"
|
||||||
|
(cxml:attribute "revMajor" "1")
|
||||||
|
(cxml:attribute "revMinor" "0")
|
||||||
|
(cxml:attribute "date"
|
||||||
|
(pmsf-lib:format-iso8601-time :time (get-universal-time)
|
||||||
|
:format :strict))
|
||||||
|
(cxml:attribute "author"
|
||||||
|
(format nil "OSN2OS10"))
|
||||||
|
(cxml:attribute "description"
|
||||||
|
(format nil "Generated by OSN2OS10 from OSN")))
|
||||||
|
(cxml:with-element "Catalogs"
|
||||||
|
)
|
||||||
|
(cxml:with-element "RoadNetwork"
|
||||||
|
;; TODO: Map
|
||||||
|
)
|
||||||
|
(cxml:with-element "Entities"
|
||||||
|
(generate-objects-from-osn osn))
|
||||||
|
(cxml:with-element "Storyboard"))))
|
||||||
|
|
||||||
|
(defun generate-objects-from-osn (osn)
|
||||||
|
(dolist (act (scenario-acts osn))
|
||||||
|
(dolist (rule (act-rules act))
|
||||||
|
(when (eq (rule-condition rule) 'openscenarionext-language::|init|)
|
||||||
|
(dolist (action (rule-actions rule))
|
||||||
|
(when (and (consp action)
|
||||||
|
(eq (car action) 'openscenarionext-language::|CreateVehicle|))
|
||||||
|
(destructuring-bind (sym id proto . args)
|
||||||
|
action
|
||||||
|
(cxml:with-element "Object"
|
||||||
|
(cxml:attribute "name" (symbol-name id))
|
||||||
|
(cxml:with-element "Vehicle"
|
||||||
|
(cxml:attribute "name" (symbol-name proto))
|
||||||
|
(cxml:attribute "category" "car")
|
||||||
|
(cxml:with-element "BoundingBox"
|
||||||
|
(cxml:with-element "Center"
|
||||||
|
(cxml:attribute "x" "1.5")
|
||||||
|
(cxml:attribute "y" "0.0")
|
||||||
|
(cxml:attribute "z" "0.9"))
|
||||||
|
(cxml:with-element "Dimension"
|
||||||
|
(cxml:attribute "width" "2.1")
|
||||||
|
(cxml:attribute "length" "4.5")
|
||||||
|
(cxml:attribute "height" "1.8")))
|
||||||
|
(cxml:with-element "Performance"
|
||||||
|
(cxml:attribute "maxSpeed" "100.0")
|
||||||
|
(cxml:attribute "maxAcceleration" "10")
|
||||||
|
(cxml:attribute "maxDeceleration" "10")
|
||||||
|
(cxml:attribute "mass" "2000"))
|
||||||
|
(cxml:with-element "Axles"
|
||||||
|
(cxml:with-element "Front"
|
||||||
|
(cxml:attribute "maxSteering" "0.5")
|
||||||
|
(cxml:attribute "wheelDiameter" "0.6")
|
||||||
|
(cxml:attribute "trackWidth" "1.8")
|
||||||
|
(cxml:attribute "positionX" "3.1")
|
||||||
|
(cxml:attribute "positionZ" "0.3"))
|
||||||
|
(cxml:with-element "Rear"
|
||||||
|
(cxml:attribute "maxSteering" "0.0")
|
||||||
|
(cxml:attribute "wheelDiameter" "0.6")
|
||||||
|
(cxml:attribute "trackWidth" "1.8")
|
||||||
|
(cxml:attribute "positionX" "0.0")
|
||||||
|
(cxml:attribute "positionZ" "0.3")))
|
||||||
|
(cxml:with-element "Properties"))))))))))
|
||||||
@ -78,3 +78,11 @@
|
|||||||
#:parse-osn-stream
|
#:parse-osn-stream
|
||||||
#:write-osn-file
|
#:write-osn-file
|
||||||
#:write-osn-stream))
|
#:write-osn-stream))
|
||||||
|
|
||||||
|
(defpackage #:openscenarionext-os10
|
||||||
|
(:nicknames #:osn-os10)
|
||||||
|
(:use #:common-lisp
|
||||||
|
#:openscenarionext-utils
|
||||||
|
#:openscenarionext)
|
||||||
|
(:export
|
||||||
|
#:write-os10-stream))
|
||||||
|
|||||||
1
tools/alexandria
Submodule
1
tools/alexandria
Submodule
Submodule tools/alexandria added at 3b849bc011
1
tools/babel
Submodule
1
tools/babel
Submodule
Submodule tools/babel added at 546fa82ecc
1
tools/closure-common
Submodule
1
tools/closure-common
Submodule
Submodule tools/closure-common added at 377f8275f2
1
tools/cxml
Submodule
1
tools/cxml
Submodule
Submodule tools/cxml added at 63562bb4ef
1
tools/puri
Submodule
1
tools/puri
Submodule
Submodule tools/puri added at 67987e7276
1
tools/trivial-features
Submodule
1
tools/trivial-features
Submodule
Submodule tools/trivial-features added at b78b2df5d7
1
tools/trivial-gray-streams
Submodule
1
tools/trivial-gray-streams
Submodule
Submodule tools/trivial-gray-streams added at ebd59b1afe
Reference in New Issue
Block a user