loadrt conv_s32_u32 names=laser.motion.type-conv
loadrt bitslice names=laser.motion.type-slice personality=2
loadrt limit1 names=laser.power.min.limit,laser.power.max.limit,laser.power.cmd.limit
loadrt laserpower names=laser.control
loadrt raster names=laser.raster
loadrt not names=motion.enabled-not

addf laser.power.min.limit                      servo-thread
addf laser.power.max.limit                      servo-thread
addf laser.power.cmd.limit                      servo-thread
addf laser.motion.type-conv                     servo-thread
addf laser.motion.type-slice                    servo-thread
addf laser.control                              servo-thread
addf laser.raster                               servo-thread
addf motion.enabled-not                         servo-thread


#the laser will fire when the the machine is in motion
#and motion.motion-type is 2 or 3, which is linear feed or arc feed 
#we use a bit-slice to determine if we can fire out laser
net laser.motion.type <= motion.motion-type
net laser.motion.type => laser.motion.type-conv.in
net laser.motion.type-u32 <= laser.motion.type-conv.out
net laser.motion.type-u32 => laser.motion.type-slice.in
net laser.motion.feed-move <= laser.motion.type-slice.out-01


#enables laser to fire
net laser.motion.feed-move => laser.control.enabled

setp laser.power.min.limit.min 0
setp laser.power.min.limit.max 100

net laser.power.min.cmd <= motion.analog-out-00
net laser.power.min.cmd => laser.power.min.limit.in
net laser.power.min.value <= laser.power.min.limit.out
net laser.power.min.value => laser.control.min-power

setp laser.power.max.limit.min 0
setp laser.power.max.limit.max 100
 
net laser.power.max.cmd <= motion.analog-out-01
net laser.power.max.cmd => laser.power.max.limit.in
net laser.power.max.value <= laser.power.max.limit.out
net laser.power.max.value => laser.control.max-power

setp laser.power.cmd.limit.min 0
setp laser.power.cmd.limit.max 100

net laser.power.cmd <= motion.analog-out-02
net laser.power.cmd => laser.power.cmd.limit.in
net laser.power.cmd.value <= laser.power.cmd.limit.out
net laser.power.cmd.value => laser.control.vector-power

net laser.motion.distance-to-go <= motion.distance-to-go
net laser.motion.distance-to-go => laser.control.distance-to-go

net laser.motion.cur-vel <= motion.current-vel
net laser.motion.cur-vel => laser.control.cur-velocity

net laser.motion.req-vel <= motion.requested-vel
net laser.motion.req-vel => laser.control.req-velocity

#rastering controller
net J0:pos-fb => laser.raster.position

net laser.raster.program-sig <= laser.raster.program
sets laser.raster.program-sig 20000

net laser.power.raster-power <= laser.raster.output
net laser.power.raster-power => laser.control.raster-power

net laser.power.raster-enabled <= laser.raster.enabled
net laser.power.raster-enabled => laser.control.raster-mode

net motion.enable-not <= laser.raster.fault
net motion.enable-not => motion.enabled-not.in
net motion:enable <= motion.enabled-not.out
net motion:enable => motion.enable
