Phidget Controled via localhost website!

Supporting Visual Studio on Windows
Post Reply

Do you have a use for controlling phidgets from over the internet?

yes
6
86%
no
1
14%
 
Total votes: 7

WLeyes
Phidgetsian
Posts: 7
Joined: Sun Dec 18, 2011 2:41 pm
Contact:

Phidget Controled via localhost website!

Post by WLeyes »

I almost have 100% success! I created a mvc 3 Intranet website following and modifying for my web application from asp.net site. i pointed my sqlCE 4.0 db to the root of my c drive I then created a C# win form application added the phidget library as well as the SQLCE library (the work needed work around in order to connect to the asp.net database). So far my web app writes to the database and my win for app reads it and turns on the led to my rfid reader based on Boolean value from the db. The only part that I need some help wit in order for me to get it to work 100% is to figure out how to poll the database from my win form to see if the database has changed. I am currently looking into SqlCeChangeTracking to see if I can make that work. if you need some part of my code please be very specific on what part as the main part of this project being the mvc 3 web app has many files ... my win form is your run of the mill rfid reader the only difference is that all the values are pulled from the database then forwarded out to/from the phidget based on the result. once i get this figured out i will be also needing to do the same think look for db changes via the web app. If you think you have an idea please post ... once this is figured out and I can build a new app and document step by step how to I will then share with the community as this idea has intrigued me ever since i bought my phidgets a couple years ago.
WLeyes
Phidgetsian
Posts: 7
Joined: Sun Dec 18, 2011 2:41 pm
Contact:

Re: Phidget Controled via localhost website!

Post by WLeyes »

I should also point out that they way I am building this the win form controller and the web app do not need to be on the same computer as the phidgets the only requirements really the computer that runs the controller needs to have the phidget manager app on it and the sql CE database needs to be accessible to both the win form app and web app :) so in theory you could if desired set it up so that in all it runs off of 3 (or more for that matter) separate computers.
WLeyes
Phidgetsian
Posts: 7
Joined: Sun Dec 18, 2011 2:41 pm
Contact:

Re: Phidget Controled via localhost website!

Post by WLeyes »

I am thinking I might have over thought this project .... I might not need the win form part ... I am going to try adding a reference to the phidget library and creating a private method in the mvc 3 web app :D
WLeyes
Phidgetsian
Posts: 7
Joined: Sun Dec 18, 2011 2:41 pm
Contact:

Re: Phidget Controled via localhost website!

Post by WLeyes »

Like usual ... this idea has been over thought ... I have now confirmed that youdo not need any db or any other controller such as a windows form, WCF or console app ... just build your mvc 3 app and add your good ol' phidget library and methods the same way you would write any .net app ... it works :) now time for me to write the full web app :D the requirements based on this test self hosted via IIS and phidget instal on the same machine as the IIS server
WLeyes
Phidgetsian
Posts: 7
Joined: Sun Dec 18, 2011 2:41 pm
Contact:

Re: Phidget Controled via localhost website!

Post by WLeyes »

*Update* okay so this is where I am at on this project. I am so far able to communicate with my phidgets via the web application. I have decided it is still better practice to send to the database then have the phidget pick it up from the DB. I have placed my phidget C# code in a Controller page. Now the fun part is trying to return data to the web app page. I might need to do this via javaScript or php (iis 7 supports both asp and php) I have now tested and sent commands to rfid reader (antenna and led - on/off) and TextLCD - IK8/8/8 sent text to both rows on the textLCD as well as got both relays on my double relay board to toggle. any ideas on the best method on returning data from the phidget to the web app? I am just going to keep trying different methods until i get something to work!
dengfengsoft
Phidgetly
Posts: 23
Joined: Thu Feb 10, 2011 8:33 pm
Contact:

Re: Phidget Controled via localhost website!

Post by dengfengsoft »

In my opinion, the best way to do this is to use HTML5 web socket (If you want to try something new...) to build a html client. It's very easy to do.Then you can use C# to program a server site app to read/write Phidgets and send or receive the data to/from the client.
Please refer to :
http://nugget.codeplex.com/
for more information.
:D
WLeyes
Phidgetsian
Posts: 7
Joined: Sun Dec 18, 2011 2:41 pm
Contact:

Re: Phidget Controled via localhost website!

Post by WLeyes »

lol ... I was thinking of that ... I have switched gears on this project and spent the last month and a bit taking some crash courses over at lynda.com on php as the backbone to my HTML5 phidget control site. Everything so far comes back to returning feedback back to the page and that is where php seems to deal with this in a much more flexible way. I had looked into using web sockets however at this point it is not an option do to the amount of unsupported browsers and devices which is my main goal. Unfortunately web sockets are not compatible with any Android browser, Opera mobile 10.0 or less Safari 4.0 or less or IE 9.0 or less. Yes it only leaves the good browsers as compatible but I want this to work regardless of the browser ... Thanks for the idea though ... it is very much appreciated and a viable option, just not one that i can use at this point. 8)
dengfengsoft
Phidgetly
Posts: 23
Joined: Thu Feb 10, 2011 8:33 pm
Contact:

Re: Phidget Controled via localhost website!

Post by dengfengsoft »

You are right, Html5 's websocket can not work directly in Android. You need a java plug-in. You can find the following link for the details:
https://github.com/anismiles/websocket- ... t/phonegap

I've already successfully use desktop browser to control Phidgets 1014 relay. I still need sometime to learn how to use Eclipse to compile the plug-in so I can use it in my Android phone.

http://eclipse.org/downloads/packages/e ... /heliossr2
this edition contains a html5 editor and can help you output your html5 app to an Android installation package.
WLeyes
Phidgetsian
Posts: 7
Joined: Sun Dec 18, 2011 2:41 pm
Contact:

Re: Phidget Controled via localhost website!

Post by WLeyes »

cool ... anyways .. after needing to step away from this project for a bit for RL commitments I am now actively working on this again. sum up where I am at ... a) C# middle-ware to bridge/bind phidget to MySQL database (I was forgetting that in order to connect c# to Mysql I needed to get the mysql .net connector dl from Mysql) b) html/php form to get and set the values of the phidget via the web. it is actually rather simple now that I have been working with php for the last couple months :) I am hoping to share a very basic code soon :D and see what the community can come up with off of it
dengfengsoft
Phidgetly
Posts: 23
Joined: Thu Feb 10, 2011 8:33 pm
Contact:

Re: Phidget Controled via localhost website!

Post by dengfengsoft »

If you are not dealing with a lot of data, you can try to use Perst embedded database which is a lightweight database designed for c# desktop applications. :wink:
Post Reply

Who is online

Users browsing this forum: No registered users and 28 guests