Hey guys I’m trying to get my phidget sensors to generate a document with the temp results in it,
tell application "PhidgetsOSA"
get library version
set thisScript to path to me
if first phidget temperature sensor exists then
set phid to the first phidget temperature sensor
else
set phid to make the phidget temperature sensor
tell phid to make new attach handler with properties {script file:thisScript}
tell phid to make new detach handler with properties {script file:thisScript}
tell phid to make new temperature change handler with properties {script file:thisScript}
open phid wait 1000 --allows application 1 second to attach to the Phidget
end if
if phid is attached then
tell phid
set tName to name
log tName & " is attached"
set tSerialNumber to serial number
log "Serial Number: " & tSerialNumber
set tVersion to version
log "Version: " & tVersion
set tInputCount to (temperature sensor count)
log " # Sensors: " & tInputCount
set ambTemp to ambient temperature
log "Ambient Temperature: " & ambTemp
set every temperature sensor's sensitivity to 0.1
repeat with sensorIndex from 1 to count temperature sensor
log ""
set tempMin to temperature sensor sensorIndex's minimum temperature
log "Sensor " & sensorIndex & "'s minimum temperature is " & tempMin
set tempMax to temperature sensor sensorIndex's maximum temperature
log "Sensor " & sensorIndex & "'s maximum temperature is " & tempMax
--TemperatureSensor IR does not support potential
if device id is not Phidget_TemperatureSensor_IR then
set pot to temperature sensor sensorIndex's potential
log "Sensor " & sensorIndex & "'s potential is " & pot
set potMin to temperature sensor sensorIndex's minimum potential
log "Sensor " & sensorIndex & "'s minimum potential is " & potMin
set potMax to temperature sensor sensorIndex's maximum potential
log "Sensor " & sensorIndex & "'s maximum potential is " & potMax
end if
end repeat
set countme to 0
log "
Outputting temperature information 2 times at 10 second intervals"
repeat with i from 2 to 10
log ""
repeat with sensorIndex from 1 to count temperature sensor
set temp to temperature sensor sensorIndex's temperature
if temp is not missing value then
log "Sensor " & sensorIndex & "'s temperature is " & temp & " degrees celsius"
else
log "Sensor " & sensorIndex & "'s temperature is missing value"
end if
end repeat
delay 1
end repeat
log "
Freeing lock on Phidget and exiting PhidgetsOSA"
delete attach handlers of phid
delete detach handlers of phid
delete temperature change handler of phid
close phid
delete phid
quit
end tell
else
log "Couldn't attach to PhidgetTemperatureSensor"
display dialog "Couldn't attach to PhidgetTemperatureSensor"
end if
end tell
using terms from application "PhidgetsOSA"
on attach phid
say "attach " & (name of phid)
end attach
on detach phid
say "detach " & (name of phid)
--uncomment the following code to free the Phidget object upon it's detach event
--delete attach handlers of phid
--delete detach handlers of phid
--delete temperature change handler of phid
--close phid
--delete phid
--quit
end detach
--runs whenever the temperature change is greater than the sensitivity
on temperature changed ind to temp on phid
log "Sensor " & (ind as text) & "'s temperature changed to " & (temp as text)
--insert code
end temperature changed
end using terms from
right now this script works great and gives me the 4 sensors temp data in the messages window of script editor, i need that same info to go to a .txt on my desktop