Community Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Interacting with Google Documents using Google Data Api

Please be sure to include at minimum the content and screenshots called out below.  Be sure to read the complete Rules for each Tournament Round

First Round:

Summary:

Google documents offer great platform for creating and sharing documents. This application interacts with google documents and downloads the spreadsheet type of documents to local PC.

Function:

To get list of spreadsheet documents available in google documents. and download all spreadsheets in csv format.

Changes made for Round 2

  • Implemented the code into state machine modified for publisher subscriber framework.
  • My example needs downloading of .net library and creating google account  for checking the example. In some compnies user can not install such libraries without IT permission. Also Just because of lengthy setup process some visitors may not actually try out code. To help them i have included “Simulation” mode for Task1 code. The process for enabling or disablling simulation mode is given below.
  • Created LVProj
  • Minor modification in subvis for compatibility with simulation mode

Enabling Disabling Simulation mode

  • open GoogleDocAPI.lvproj
  • Right click on “Project: GoogleDocAPI.lvproj” and select properties
  • go to conditional disable symobols
  • Set SIMULATE=TRUE for enabling simulation.(Set it to FALSE for disabling)
  • click ok

CondDisable.png

Steps to execute code:

  1. Download ".NET library for the Google Data API" from http://code.google.com/p/google-gdata/downloads/detail?name=Google%20Data%20API%20Setup%20(1.7.0.1).... (Not required for Simulation Mode execution)
  2. Install the Library (Not required for Simulation Mode execution)
  3. If required google account for Google documents (Not required for Simulation Mode execution)
  4. If required create some spreadsheet documents (Not required for Simulation Mode execution)
  5. Open GoogleDocAPI.lvproj
  6. Open the "GoogleDocSpreadsheetDownloader.vi" "GoogleDocSpreadsheetDownloader_2.0.vi" open block diagram and putup your gmail id and password in username and password string constants (Not required for Simulation Mode execution)
  7. Run the vi

See Video attached below to see example at work

Screenshots:

Main Front Panel:

GoogleAPI_FP.png

Main Block Diagram:

GoogleAPI_BD.png

VI Snippet:

snippet.png

Second Round: Transfer data to other VI:

Communication Mechanism

Self Built Framework which implements publisher subscriber pattern or observer pattern.

Advantages

  • No need to pass any referance or configuration data between Vis for transfering data
  • Publisher and subscriber doesnt know about each other, the framework ensures the delivery. This gives following advantages       
    • makes application extension very much powerful as well as easy

    • Attaching and removing debugging tools become easy
  • Totaly asynchronous operation without polling ensures optimum performance
  • Each parrallel VI executes “CALLBACK State” in state machine in response to the event(along with Event Data)
  • Has many adavantages over native Event driven porgramming       
    • No development time check for event Name and event data type(much more flexible for future extension, ideal choice for plugins)

    • Events can be discarded(flushed)
    • Events can be given priority
    • with introduction of lossy queues framework can be modified to ensure max events to be queued(Not yet implemented in current framework)
  • multiple Vis can subscribe to same message in this case each VI gets a copy of event data
  • framework provides debugging tool to detect most common problems in async communication(such as continuously increasing backlog in case producer consistently send data faster than the consumer can consume)
  • ALL THIS IN JUST 7 very well encapsulated Vis(No complicated stuff outside so even new developer can use it without understanding complex logic inside)
    • Create

    • Destroy
    • Subscribe Event
    • Unsubscribe Event
    • Raize event
    • flush/discard events
    • Get Event

Highlights of new code (including changes in task 1 code)

  • Using diagram disable structure
  • Simulating data sources(Can be useful for simulating non ni hardwares/ Communication protocols etc as well)
  • understand publisher subscriber architecture
  • understand plugins

Function:

in publisher subscriber architecture VI can subscribe to perticular events. whenever event with that name is raized by any VI. subscribing VI goes to the state with the name of event. it receives the event data there and executes the callback code written

Task 1 Code(GoogleDocSpreadsheetDownloader_2.0.vi) subscribes following event:

  • GetDocList:
    • Raized by: SubscriberVI.vi when user presses refresh list button
    • What happens: GoogleDocSpreadsheetDownloader_2.0.vi goes to "GetDocList"case. fetches Names of all the spreadsheet document names from google docs and returns them in event "DocList Retrieved"(This event is subscribed by "SubscriberVI.vi" which then fills that list in All Spreadsheets combo box)
  • GetDocByName (Not used yet)
  • GetCacheDocByName
    • Raized by: SubscriberVI.vi when user presses Load Doc button (Document selected in All spreadsheets combo is passed as parameter)
    • What happens: GoogleDocSpreadsheetDownloader_2.0.vi goes to "GetCacheDocByName" case. Reads spreadsheet name present in event data. fetches perticular spreadsheet data from google docs cache and returns them in event "CacheDoc Retrieved"(This event is subscribed by "SubscriberVI.vi" which then fills that in table. It is also subscribed by sniffer)
  • LoadCache
    • Raized by: SubscriberVI.vi when user presses Reload Doc Cache button
    • What happens: GoogleDocSpreadsheetDownloader_2.0.vi goes to "LoadCache" case. Reads all the spreadsheet document names and their content. and stores it in memory cache.

Steps to execute code:

  • Open GoogleDocAPI.lvproj(Include both round 1 and round 2 code)
  • Open “GoogleDocSpreadsheetDownloader_2.0.vi” and “SubscriberVI.vi”
  • Run them. Order is NOT important. (Note: See that VIs communicate between them without knowing anything about other. I am not calling one VI dynamically from other to show this feature) 
  • if you want to see doc sniffer at     work then open “DocLoadSniffer.vi” and run it.

Screenshots:

Front Panel

FP_Round2.png

BlockDiagram

BD_Round2.png

VI Snippet:

Round2Snippet.png

VI attached below

Comments
G-Money
NI Employee (retired)
on

Very clean code! Was the documentation on the Google .NET API pretty helpful or did you have to learn a lot by trial and error?

OyeeInter
Member
Member
on

Hello, I'm trying to implement this code. I need the attached video as guide, but can't find it. 

Please resend it.

 

Contributors