(load "/usr/local/slisp/station.lsp")(defvar with-freesat nil)(defvar with-dvbs-cont nil)(defun digital-ts-tune (src sat onid tsid physical_ch ntype freq)(let ((tsl-key) (dev))(if (get-signal-source-devices src)
nil
(progn
(my-device-open 'psi (if (eq (get-signal-source-no src) 0) 0 2))(my-device-open 'tsport (if (eq (get-signal-source-no src) 0) 0 2))(my-device-open (get-signal-source-tuner src) (get-signal-source-no src))(init-tuner-object (get-signal-source-tuner src))(when (or with-dvbs-cont with-freesat)(mapcar #'(lambda (x)(tuner-setup (get-signal-source-tuner src)
:satellite (nth 0 x)
:dish-low (nth 1 x)
:dish-high (nth 2 x)
:dish-tone-en (nth 3 x)))
dish-param))(set-signal-source-devices src (list (get-signal-source-tuner src) 'psi 'tsport))(set-tuning-tsl-key (get-tuner-tsl-key (get-signal-source-tuner src)))(setup-node (get-signal-source-node src))))(if sat
(setf tsl-key (svl-create-key "TSL"
:freq freq
:ntype ntype))(progn
(setf tsl-key (svl-create-key "TSL"
:physical_ch physical_ch
:onid onid
:tsid tsid)))(tsl-query tsl-key 'ntype 'ya_nid))(set-signal-source-svl src nil)(set-signal-source-tsl src tsl-key)(set-tuning-tsl-key tsl-key)(set-tuning-tsid tsid)(set-tuning-svcid nil)(my-select-channel)))(defvar tuning-tuner 'tuner)(defun get-tuning-tuner ()
tuning-tuner)(defun my-select-channel ()(if (tsl-equal (get-tuning-tsl-key) (get-tuner-tsl-key (get-tuning-tuner)))(if (eq (get-tuning-svcid) (get-psi-svcid 'psi))(make-event 'psi-update)(set-psi-valid 'psi nil)(set-psi-error 'psi nil)(make-event 'psi-invalid)(search-svcid-in-pat (get-tuning-svcid))(make-event 'service-change))(set-psi-valid 'psi nil)(set-psi-error 'psi nil)(make-event 'psi-invalid)(make-event 'tuner-req)))(defvar dish-param nil)(defmacro dish-setup (sat low high tone-en)
`(setf dish-param (cons (list ,sat ,low ,high ,tone-en) dish-param)))(register-node 'my-tuner-freq-valid
#'(lambda ()(tsl-equal (get-tuning-tsl-key) (get-tuner-tsl-key (get-tuning-tuner))))
#'(lambda ()(set-tuner-tsl-key (get-tuning-tuner) (get-tuning-tsl-key))(eval-events (list 'tuner-req 'tuner-change)))
#'(lambda ()
nil))(register-node 'my-tuner-connect
#'(lambda ()(tuner-status (get-tuning-tuner)))
#'(lambda ()(unless (tuner-connect (get-tuning-tuner)
:tsl (get-tuner-tsl-key (get-tuning-tuner)))(set-tuner-tsl-key (get-tuning-tuner) (tuner-tsl-key (get-tuning-tuner))))(eval-events (list (list 'tuner-lock (get-tuning-tuner))(list 'tuner-unlock (get-tuning-tuner))(list 'tuner-disconnect (get-tuning-tuner)))))
#'(lambda ()(tuner-disconnect (get-tuning-tuner))))(register-node 'my-tsport-connect
#'(lambda ()(device-source-p 'tsport (get-tuning-tuner)))
#'(lambda ()(tsport-connect 'tsport (get-tuning-tuner))(eval-events (list 'tsport-available 'tsport-change)))
#'(lambda ()
nil))(defun use-digital-tuner (no src)(set-signal-source-no 'dig no)(set-signal-source-tuner 'dig 'tuner)(let (port)(setf port (list nil nil))(if (eq (get-signal-source-no 'dig) 0)(setf (nth 0 port) "FE_IN1")(if (eq (get-signal-source-no 'dig) 1)(progn
(setf (nth 1 port) "FE_IN2")(if (or with-freesat with-dvbs-cont)(setf (nth 0 port) "FE_IN1")))))(tsport-config 'tsport port))(tuner-config 'tuner (list "ttuner" "stuner")))(init-signal-source-object 'dig)(append-t
'my-tuner-freq-valid
'my-tuner-connect
'my-tsport-connect)(node-key 'my-tuner-freq-valid 'dig)(set-signal-source-node 'dig 'my-tuner-freq-valid)(defun c-program-on (sym arg)(digital-ts-tune 'dig nil (first arg) (second arg) (fourth arg) nil nil))(defun c-program-on-satellite (ntype freq)(digital-ts-tune 'dig t nil nil nil ntype freq))(defun c-program-off ()(cancel-node (get-signal-source-node 'dig))(mapcar #'(lambda (x)(my-device-close x))(get-signal-source-devices 'dig))(set-signal-source-devices 'dig nil)(set-signal-source-svl 'dig nil)(set-signal-source-tsl 'dig nil))
