AppleScript to handle digital inputs?

Supporting 10.7 and up
drc
Phidgetly
Posts: 16
Joined: Sat Nov 15, 2014 8:33 am
Location: Ottawa
Contact:

AppleScript to handle digital inputs?

Postby drc » Sat Nov 15, 2014 9:25 am

I've just discovered the wonderful world of phidgets, which looks perfect for my winter project to instrument my new gas furnace. I want to capture events (state changes) from the burner and blower fan relays and save time-stamped records so I know how often/long the furnace is running. The data would get written to a CSV file, and eventually find its way into an Excel for analysis. I have an old Mac Mini w/OSX gathering dust which would work well as a headless server in the furnace room.

The 1011 interface board looks perfect. I'm an EE, and can easily condition the 24VAC relay voltages to something suitable for the 1011 digital inputs. But my programming skills are rusty, nay nonexistent. My last real-time programming project was an interrupt handler in PDP-11 assembler.

Using AppleScript is appealing since the price is right. But I have little experience with it. I've read a few tutorial articles, but can't find much guidance in using it for asynchronous events coming from 3rd-party hardware. I reviewed the sample code from phidget (PhidgetInterfaceKit with Events.scpt). At the present time, it's over my head, though I'm continue to study AppleScript documents.

This application seems pretty straightforward, and I'm hoping someone has already written a similar program to capture digital events with AppleScript. If so, I'd appreciate any hints, tips, (or even some sample code). On the other hand, if AppleScript is not suitable, recommendations on better approaches would be valuable (though I'm not sure I'm up to learning C++, Java, Ruby, etc).

Thank for your help.

User avatar
Patrick
Lead Developer
Posts: 3078
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: AppleScript to handle digital inputs?

Postby Patrick » Mon Nov 17, 2014 9:34 am

Applescript would work, but support is limited. I think Python might be a better solution for you - probably the easiest to lean language for Phidgets and it's cross-platform.

-Patrick

drc
Phidgetly
Posts: 16
Joined: Sat Nov 15, 2014 8:33 am
Location: Ottawa
Contact:

Re: AppleScript to handle digital inputs?

Postby drc » Mon Nov 17, 2014 11:02 am

Patrick,
Thanks for the prompt reply.

I think I've run into a bigger roadblock: according to the Phidgets programming page, AppleScript support requires OSX 10.6 or better. My old Mac Mini is on 10.5.8. It's a PPC machine, and can't be upgraded to 10.6.

I looked at your Python support page, and can't find any explicit statement about OSX dependency. A quick visit to python.org overwhelmed me with Too Much Information. There's Python 2 and Python 3, etc. Are there any particular dependencies on your Python libraries? Do they need V3? I suspect my old Mac Mini will have Python 2 on it (if it's there at all). I have no idea if Python3 is compatible with an old PPC Mac, nor how to upgrade if it is...

Thanks.

User avatar
Patrick
Lead Developer
Posts: 3078
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: AppleScript to handle digital inputs?

Postby Patrick » Mon Nov 17, 2014 2:17 pm

You should use Python 2.6 on Mac. I'm not sure if it's installed already, but you can just download an installer from the Python website: https://www.python.org/downloads/mac-osx/

-Patrick

drc
Phidgetly
Posts: 16
Joined: Sat Nov 15, 2014 8:33 am
Location: Ottawa
Contact:

Re: AppleScript to handle digital inputs?

Postby drc » Mon Nov 17, 2014 3:53 pm

Patrick,
Last question before I jump into Python:
I've spent some of the afternoon exploring python.org.
It appears I can upgrade my Leopard Mac's present python (2.5) to 2.6.6, or jump to 3.4.2. Both are claimed to work on OSX 10.5.8, through I understand that V2 is no longer being supported.

Is there a reason you suggested 2.6 versus 3? I'm sure I don't need the additional bells and whistles that are in V3. Simpler is better. If you feel that 2.6 is sufficiently robust/stable/compatible with the Phidget library, that's the way I'll go. And place an order for some Phidget interfaces.

Thanks.

User avatar
Patrick
Lead Developer
Posts: 3078
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: AppleScript to handle digital inputs?

Postby Patrick » Tue Nov 18, 2014 9:45 am

Python 3 will work fine too, anything above 2.6.

-Patrick

drc
Phidgetly
Posts: 16
Joined: Sat Nov 15, 2014 8:33 am
Location: Ottawa
Contact:

Re: AppleScript to handle digital inputs?

Postby drc » Tue Nov 18, 2014 10:02 am

@Patrick,
Thanks for the feedback.
I've updated my old Mac Mini (OSX 10.5.8) to 2.6.6 and am good to go. Now to learn some Python so I can program some Phidgets...


Return to “macOS”

Who is online

Users browsing this forum: No registered users and 2 guests