;; -*- Mode: LISP; Syntax: Common-Lisp; Package: (USER); -*-
;***************************************************************
;*
;*  OBJECT DEFINITIONS - for everything but parsing
;*
;*  July 10
;* 
;***************************************************************
;*

(in-package 'USER)

(proclaim '(optimize (speed 3)))

(defvar *socket-obj1* nil)

;*****************
;*   BEHAVIORS   *
;*****************

(defclass basic-behavior () 
  ( ;Top behavior node
   (name    :accessor name   :initarg :name   :initform nil)  ;What does the beh post?
   (msgs    :accessor msgs   :initarg :msgs   :initform nil)  ;What does the beh post?
   (state   :accessor state  :initarg :state  :initform nil)  ;Is the beh allowed to be exec?
   (active  :accessor active :initarg :active :initform nil)
   (extent  :accessor extent :initarg :extent :initform nil)
   (stamp   :accessor stamp  :initarg :stamp  :initform 0) ;Time of de/activation.
  ))   ;stamp: the clock at the time the beh was posted last.

(defclass reactive-beh (basic-behavior)  ())

(defclass int-beh (basic-behavior) ())
(defclass ext-beh (basic-behavior) ())

(defclass conds ()
  ( ;Contains common cond slots.
   (positive-conditions :accessor pos-cond :initarg :pos-cond :initform nil)
   (negative-conditions :accessor neg-cond :initarg :neg-cond :initform nil)
   ))

(defclass state (basic-behavior) 
  (
   (doc  :initform "Turn-behaviors control the giving and taking of turns.")
   (next :accessor next :initarg :next :initform nil)  ;list of next state(s).
   (active-descriptors :accessor active-descr :initarg :active-descr :initform nil)
   (threshold :accessor thresh :initarg :thresh :initform nil) ;don't need this?
   ))

(defclass turn-state-beh (reactive-beh state int-beh conds)   ;All turn beh are reactive
  ())

(defclass one-shot () 
  ( ;Acts that are only to be done once until ?after time interval or ?when situation
   (pos-restr-cond :accessor pos-restr-cond :initarg :pos-restr-cond :initform nil)
   (neg-restr-cond :accessor neg-restr-cond :initarg :neg-restr-cond :initform nil)
   (done-executing :accessor done  :initarg :done    :initform nil)
   ))

(defclass cont ()
  ( ;Acts like blink, tics, etc., i.e. continuous activities.
   (period  :accessor period  :initarg :period  :initform 100) ;100=one sec.
   ;this could also be that it fires every time condition arises and resets when
   ;condition ceases to be true. If pos-cond = t, do that.
   ))

(defclass int-one-shot-rea-beh (reactive-beh int-beh one-shot conds) ())
(defclass ext-cont-rea-beh     (reactive-beh ext-beh cont conds)     ())
(defclass ext-one-shot-rea-beh (reactive-beh ext-beh one-shot conds) ())

; 2/3/96: question how to design the spatial actions?
;spatial-beh is for shipping out coordinates with spatial action request.
; See also Dia1.lisp

(defclass spatial-rea-beh (ext-one-shot-rea-beh) ())

;node is the base object for multimodal descriptors and virtual sensors
(defclass node () 
  ((name    :accessor name   :initarg :name)
   (msgs    :accessor msgs   :initarg :msgs) ;This is just to coordinate with behaviors.
   (state   :accessor state  :initarg :state :initform nil)
   (stamp   :accessor stamp  :initarg :stamp :initform 0) ;added 3/9/96
   (active  :accessor active :initform T)))  ;whether it gets updated or not.

(defclass turn-system-node (node) ())

(defclass descriptor (turn-system-node) ())

(defclass turn-descriptor (descriptor)
  ((positive-conditions :accessor pos-cond :initarg :pos-cond :initform nil)
   (negative-conditions :accessor neg-cond :initarg :neg-cond :initform nil)
   (threshold :accessor thresh :initarg :thresh :initform 1))) 
    ;what the weights have to sum to post a T.

(defclass sensor (turn-system-node) 
  ((func  :accessor func  :initarg :func  :initform nil)
   ;Values from user->
   (data1 :accessor data1  :initarg :data1  :initform (vector 1 1 1)) 
   ;Data value #2->
   (data2 :accessor data2 :initarg :data2 :initform (vector 1 1 1)) 
   ;index into data records->
   (index1 :accessor index1 :initarg :index1 :initform nil) 
   ;only used for bs-fix-ref->
   (index2 :accessor index2 :initarg :index2 :initform nil) 
  ))
  
(defclass body-sensor (sensor)       ())     ;for gesture, body position
(defclass bs-fix-ref (body-sensor)   ())     ;with one changing value, one fixed.
(defclass bs-var-ref (body-sensor)   ())     ;body sensor with 2 CHANGING values.  
(defclass inton-sensor (sensor)      ())     ;intonation, 
(defclass socket-sensor (sensor)     ())     ;Monitors sockets
  
(defclass spatio-temporal-sensor (sensor) 
  ()) ;gaze,gesture--time-dependent behaviors.
 
       ;Not sure we need this one or that it should be in the sensors,,,
       ;perhaps rather beh.
       ;well, if there are any crucial spatio-temporal 
       ;FEATURES in dialogue then it should be here.

(defclass speech-sensor (sensor) ()) ;speech



;-------- WORLD CLASSES  --------

(defclass planetoid (object)
  (
   (name  :accessor name  :initarg :name)
   (pos   :accessor pos   :initarg :pos)
   (color :accessor color :initarg :color)
   (size  :accessor size  :initarg :size)
   (tilt  :accessor tilt  :initarg :tilt)
   (id    :accessor id    :initarg :id)                ;nucleus id
   (vis-id :accessor vis-id :initarg :vis-id)          ;visual object id
   (vis-spd   :accessor vis-spd   :initarg :vis-spd)   ;self-rotation
   (ring  :accessor ring  :initarg :ring :initform nil)
   (y-n-tilt :accessor y-n-tilt :initarg :y-n-tilt :initform nil)
   (far-out  :accessor far-out  :initarg :far-out :initform nil)
   (clos-up :accessor clos-up :initarg :clos-up :initform nil)
   ))

(defclass planet (planetoid)
  (
   (moons :accessor moons :initarg :moons :initform nil)
   ))

(defclass moon   (planetoid) 
  (
   (slant :accessor slant :initarg :slant)    ;slant of orb-object
   (orb-id :accessor orb-id :initarg :orb-id) ;id of rotating object
;  (orb-anim :accessor orb-anim :initarg :orb-anim)  ;animation of rotating object
   (orb-spd :accessor orb-spd :initarg :orb-spd)
   ))
