Jump to content
Software FX Community

Using the PowerGadget Creator then using PowerShell


cswannack

Recommended Posts

I have a couple of map powergadgets that I created using the PowerGadget Creator program just to get something up and running for use in a call center.  However it would be nice now to migrate this to an actual PowerShell script so that I could have more programmatic control over the display of the map.  I also wanted to combine several of these map gadgets into a single pane that forward from one gaget to the next as you learned to create in the "Getting Started" Guide.

Using the PowerGadget Creator application was a great way to get started but now I need to really start building something with more features.  I looked at the internals of the ".pgf" document and found that it was an XML file.  So I am assuming that this is sometype of configuration template file that is read into powershell 'behind' the scenes to accomplish it's work along with calling the out-map cmdlet.  (Just speculating here.)

How would I best accomlplish what I want to do.  Thank you.

...cordell...

Link to comment
Share on other sites

I haven't seen a response yet as to whether there's a hidden .pgf to .ps1 'translator'.  It is possible that your only option currently is to build the .ps1 yourself by hand.

Just for fun, I'm thinking about if I can easily create a PSH script to convert, but it could be days/weeks before I have something written.

If you're willing to post it here/share it, I might be able to translate it for you, but again, it could be a few days.

Link to comment
Share on other sites

When you create a gadget using the PowerGadgets Creator there are two main elements combined: data and gadget properties (type, look, etc.). In order to convert a pgf gadget to a ps1 gadget you must separate the two portions.

First, to obtain the gadget properties you can use a feature in PowerGadgets which allows you to use the clipboard to pass gadgets from the Creator to Template Creator and viceversa. You must first open your pgf gadget and click Edit->Copy. Then you open the Template Creator by invoking out-map -config in PowerShell (or out-gauge/out-chart depending on your gadget type). This will invoke a UI very similar to the PowerGadgets Creator but will not allow you to pass any data, since you are defining a template. Click Edit->Paste and you will have a template with the same look of your original gadget, which you will save as a .pgt file (e.g. MyTemplate.pgt). You don't need to to any of this if your gadget uses the default properties.

Second, you will move the data section from your pgf gadget to the ps1. If you are using PowerShell data, this is as simple as copy/paste from the Creator data section into your ps1 file. If you are using databases or web services, then you must use the corresponding cmdlets (invoke-sql or invoke-webservice).

Finally, you will combine both pieces in your ps1. For example, if your original gadget was a map of the US Election results reading a csv file using PowerShell, your final ps1 will look like this:

import-csv USElectionResults.csv | select StateAbbreviated,@{Expression={[int]$_.Bush};Name="Bush"},@{Expression={[int]$_.Gore};Name="Gore"} | out-map -template MyTemplate.pgt

You also mention that you want to combine several gadgets into a single pane, which we call a gadget group. In order to do that, you must use the -group MyGroup -name <gadgetName> parameters when invoking the cmdlet. It's important to mention that you can also achieve groups with the PowerGadgets Creator by simply adding more gadgets to your pgf file, using the Edit->Add Item option or the + icon in the toolbar.

It would be interesting if you please elaborate on what kind of "more programmatic control over the display of the map" you are looking for.

IvanGPowerGadgets

Link to comment
Share on other sites

Thank you Ivan for the detailed response to my question.  I look forward to implementing this.

What I mean by more programmatic control...

I have two map gadgets (Registration Activty by State and Call Activity by State) that are used to show staff in the call center what has been 'handled' for the day.  Each gadget executs a simple SQL query to get the activity counts by state about every 2 minutes.

One issue that I see is that the 5 ranges that are displayed in the legend do not dynamically adjust as the overal range of counts get larger.  Initially when I first created the gadget the top value was 50.  But now that I am using the gadget in production...the top value is 200+ but the 5 buckets that make up the ranges in the legend do not dynamically readjust to reflect the new range of values, 1 - 200.  I have tried adjusting this with the creator tool...but it is still stuck at a top-end value of 50.

Another programmatic control feature using powershell and the map gadget I would be able to momentarily turn the interior color of a state to something like 'red'.  I have access to the telephony system and all of its KPI data...I can get a value from the telephony system about the number people who are waiting in the queue.  The map is a helpful way for staff to visually see a "hot" spot when thresholds are passed.

Some examples of more 'programmatic' control.  Thanks for asking.

...cordell....

Link to comment
Share on other sites

"One issue that I see is that the 5 ranges that are displayed in the legend do not dynamically adjust as the overal range of counts get larger.  Initially when I first created the gadget the top value was 50.  But now that I am using the gadget in production...the top value is 200+ but the 5 buckets that make up the ranges in the legend do not dynamically readjust to reflect the new range of values, 1 - 200.  I have tried adjusting this with the creator tool...but it is still stuck at a top-end value of 50."

Sounds like you have hardcoded values from Creator.  Once you see the full out-map command in a ps1 script or on the command line, you will have other options like not declaring any values at all and using "-steps", for example.  The -steps option to out-map will cause out-map to calculate the best fit for your values, and if you do "-steps 5", for example, out-map will split your minimum value (or 0?), and your maximum value in 5 equal blocks.  This may cause you to have to rethink how you do your coloring though.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...