Author Topic: Ggcal plugin  (Read 5607 times)

0 Members and 1 Guest are viewing this topic.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Ggcal plugin
« Reply #15 on: October 16, 2013, 01:07:01 PM »
Your solution is tidy, even if long.

Since the plugin really only allows you to retrieve information from one feed at a time, I think your command approach makes sense.

When you say that it's slow, do you mean that it's slow to create the code, or that it is slow to execute?

Another way you might consider doing this is to create a command group. Within the group, keep each calendar's feedback in its own command, but allow each command to trigger the next. To add more calendars later, you can clone the last command in your group and alter the clone as needed.

I tested this with just 3 calendars and it executes quite efficiently, but I don't have a lot of calendar events so it's difficult to know for sure.

Possible benefits of this approach are:
(1) you can change some of the details for individual calendar commands without having to scroll through a big long command;  
(2) you could clone individual commands, substitute in trigger phrases and delete the trigger events, so that when you want to, you can ask for results from particular calendars rather than all calendars at once.

You, James or others may see disadvantages to my approach, or ways to improve upon it. Here is an example with 3 calendars:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<commandGroup open="True" name="Today's events" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="485" name="Today's MyCal1 events" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>GgCal.GetDay</cmdType>
      <cmdString>0&amp;&amp;MyCal1</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="True">
      <ifType>(A)==(B)</ifType>
      <ifParams>{LastResult}&amp;&amp;no events</ifParams>
      <then>
        <action>
          <cmdType>Results.MatchConcat</cmdType>
          <cmdString>{CR}</cmdString>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <cmdString>MyCal1: {LastResult}</cmdString>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <cmdString>MyCal2</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>What's happening today, Tell me today's events</phrase>
  </command>
  <command id="488" name="Today's MyCal2 events" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>VC.Pause</cmdType>
      <cmdString>2000</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>GgCal.GetDay</cmdType>
      <cmdString>0&amp;&amp;MyCal2</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="True">
      <ifType>(A)==(B)</ifType>
      <ifParams>{LastResult}&amp;&amp;no events</ifParams>
      <then>
        <action>
          <cmdType>Results.MatchConcat</cmdType>
          <cmdString>{CR}</cmdString>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <cmdString>MyCal2: {LastResult}</cmdString>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <cmdString>MyCal3</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>MyCal2</event>
  </command>
  <command id="552" name="Today's MyCal3 events" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>VC.Pause</cmdType>
      <cmdString>3000</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>GgCal.GetDay</cmdType>
      <cmdString>0&amp;&amp;MyCal3</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="True">
      <ifType>(A)==(B)</ifType>
      <ifParams>{LastResult}&amp;&amp;no events</ifParams>
      <then>
        <action>
          <cmdType>Results.MatchConcat</cmdType>
          <cmdString>{CR}</cmdString>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <cmdString>MyCal3: {LastResult}</cmdString>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <cmdString>No new TV today</cmdString>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <cmdString>NextCal</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Today's MyCal3 events</phrase>
    <event>MyCal3</event>
  </command>
</commandGroup>

I honestly don't know if this is a better solution or even a good one. I simply offer it as an alternative. Let the debates begin!  ::hmm
« Last Edit: October 16, 2013, 01:09:06 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Ggcal plugin
« Reply #16 on: October 16, 2013, 01:48:45 PM »
OK.  I was inspired by nime5ter.

this method is probably the easiest to maintain.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<commandGroup open="True" name="What's happening today" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="553" name="updateAcal" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>GgCal.GetDay</cmdType>
      <cmdString>0&amp;&amp;{1}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)&lt;(B)</ifType>
      <ifParams>0&amp;&amp;{#M}</ifParams>
      <then>
        <action>
          <cmdType>Results.MatchConcat</cmdType>
          <cmdString>{CR}</cmdString>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <cmdString>allEvents&amp;&amp;{Var.allEvents}{CR}{1}:{CR} {LastResult}</cmdString>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
    <event>updateAcal</event>
  </command>
  <command id="554" name="call for updates" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Results.SetVar</cmdType>
      <cmdString>allEvents&amp;&amp;Calendar info:</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <cmdString>updateAcal&amp;&amp;Birthdays</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <cmdString>updateAcal&amp;&amp;tvcountdown.com</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <cmdString>updateAcal&amp;&amp;James Richards</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <cmdString>{Var.allEvents}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>What's happening today, Tell me today's events</phrase>
  </command>
</commandGroup>

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Ggcal plugin
« Reply #17 on: October 16, 2013, 01:59:20 PM »
Whoa man. You're blowin' my mind.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Ggcal plugin
« Reply #18 on: October 16, 2013, 03:32:29 PM »
From a programmer's point of view it is a relatively straightforward thing.  We are just using VC.TriggerEvent the same way we could use a subroutine.



This command gets called once for each calendar and it adds to the variable "allEvents"

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Ggcal plugin
« Reply #19 on: October 16, 2013, 07:15:01 PM »
Since earlier there was discussion of using VC to learn Python, here is something similar to what James just did above, but using some very basic Python (it requires that the Python plugin is installed).

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<commandGroup open="True" name="What's happening today" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="553" name="iterate Calendar feeds" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>PY.ExecFile</cmdType>
      <cmdString>{Path.VC}\PY\CalendarFeed.py</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>What's happening today?</phrase>
  </command>
  <command id="559" name="Reads feeds (OSD)" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="True" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>VC.Pause</cmdType>
      <cmdString>2000</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <cmdString>thisFeed&amp;&amp;{1}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>GgCal.GetDay</cmdType>
      <cmdString>0&amp;&amp;{1}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)&lt;(B)</ifType>
      <ifParams>0&amp;&amp;{#M}</ifParams>
      <then>
        <action>
          <cmdType>Results.MatchConcat</cmdType>
          <cmdString>{CR}</cmdString>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <cmdString>{var.thisFeed}:{CR}{LastResult}</cmdString>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
    <event>DaysEvents</event>
  </command>
</commandGroup>
« Last Edit: October 16, 2013, 07:17:02 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)