| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 
 | //genesis
// synactivator object
//
// This is an extended object built from scratch to provide
// for synaptic activation equivalent to a single spike of
// a given weight.  The activation is delivered by calling
// an action.  This is something that would be nice to have
// in the various synaptic channel objects.
int __SYN_ACTIVATOR_OBJECT_DEFINED__
if (__SYN_ACTIVATOR_OBJECT_DEFINED__)
    return
end
// a synactivator is a neutral with the following actions and fields:
//
// FIELDS
//
//	weight	(rw)	: spike weight (alias for z)
//	act	(ro)	: calculated activation to deliver (alias for y)
//	path	(ro)	: channel to deliver to
//
// ACTIONS
//
//	SEND_SPIKE path	: send a spike to the given channel
//	PROCESS		: called from schedule to terminate activation
//
// The object is defined to be in the device class.  This is important
// as the order in which the synactivator PROCESS action is called from
// the schedule determines when the activation is terminated.  Since
// devices follow the channels in the schedule, we can terminate the
// activation on the next call to PROCESS.
create neutral /synactivator
pushe /synactivator > /dev/null
addfield . weight -indirect . z -description "Spike weight"
addfield . act -indirect . y -description "Calculated activation"
addfield . path -description "Destination channel"
setfieldprot . -readonly path act
addaction . SEND_SPIKE __synactivatorSEND_SPIKE
addaction . PROCESS __synactivatorPROCESS
addclass . device
pope > /dev/null
addobject synactivator /synactivator
// ACTION functions
// SEND_SPIKE action
//
// calculate the activation for the channel and send an ACTIVATION
// message causing the activation to be added to the channel when
// it is next processed.
function __synactivatorSEND_SPIKE(action, chanpath)
    if ({getfield act} != 0.0)
	echo synactivator: already sending a spike to {getfield path}
    end
    str chantype
    foreach chantype (manualconduct channelC channelC2 channelC3 \
	    channelA channelB synchan synchan2 hebbsynchan hebbsynchan2)
	if ({isa {chantype} {chanpath}})
	    chantype = "Ok"
	    break
	end
    end
    if (chantype != "Ok")
	echo synactivator: '{chanpath}' not a synaptic channel
	return
    end
    setfield act { {getfield weight} / {getclock 0} }
    setfield path {chanpath}
    addmsg . {chanpath} ACTIVATION act
end
// PROCESS action
//
// Remove the ACTIVATION message if there is one and zero the act
// field which indicates no spike being sent
function __synactivatorPROCESS
    if ({getfield act} != 0.0)
	setfield act 0
	deletemsg {getfield path} 0 -find . ACTIVATION
    end
end
__SYN_ACTIVATOR_OBJECT_DEFINED__ = 1
 |