X-Git-Url: http://git.kpe.io/?p=rlc.git;a=blobdiff_plain;f=main.lisp;fp=main.lisp;h=87fec0580b5888a1e5a78600bdda04bb00bd3e20;hp=171b51849b1c651214317881b0052a95a49f732b;hb=a55a2dd7c48c32fb5c53b2246f4ca988ddff375d;hpb=e7afefae2500cee78b352577daff456f826a6a84 diff --git a/main.lisp b/main.lisp index 171b518..87fec05 100644 --- a/main.lisp +++ b/main.lisp @@ -12,15 +12,16 @@ (in-package #:rlc) -(defun plot-series-rlc-current (v r l c t-inc t-end &optional (t-start 0)) +(defun plot-series-rlc-current (v r l c t-inc t-end &optional (t-start 0) + (graph-function 'run-xgraph)) (let ((path (make-pathname :directory '(:absolute "tmp") :name (concatenate 'string "rlc-data-" (write-to-string (get-universal-time))) :type "dat"))) - (write-series-rlc-graph path v r l c t-inc t-end t-start) - (run-xgraph path) + (write-series-rlc-current-graph path v r l c t-inc t-end t-start) + (funcall graph-function path) (sleep 2) (delete-file path))) @@ -29,12 +30,16 @@ (defun write-series-rlc-current-graph (path v r l c t-inc t-end &optional (t-start 0)) + (with-open-file (out path :direction :output :if-exists :supersede + :if-does-not-exist :create) + (write-series-rlc-current-graph-stream out v r l c t-inc t-end t-start))) + +(defun write-series-rlc-current-graph-stream (out v r l c t-inc t-end + &optional (t-start 0)) (multiple-value-bind (x y) (series-rlc-current-graph-data v r l c t-inc t-end t-start) - (with-open-file (out path :direction :output :if-exists :supersede - :if-does-not-exist :create) - (dotimes (i (length x)) - (format out "~D ~D~%" (aref x i) (aref y i)))))) + (dotimes (i (length x)) + (format out "~D ~D~%" (aref x i) (aref y i))))) (defun series-rlc-current-graph-data (v r l c t-inc t-end &optional (t-start 0)) (let* ((formula-list (series-rlc-current-formula v r l c)) @@ -88,7 +93,7 @@ 0))) (:l `(lambda (tm) - (* ,(/ v l) t))) + (* ,(/ v l) tm))) (:rl `(lambda (tm) (* ,(/ v r) (- 1 (exp (- (* tm ,(/ r l))))))))