My Blog List

Thursday, September 29, 2011

Debugging components in ArcMap - Start External program

The trick to debugging components in ArcMap is to set the Startup program on the Debug tab in Visual studio as shown:




Set the path to:

C:\Program Files (x86)\ArcGIS\Desktop10.0\Bin\ArcMap.exe

Friday, September 23, 2011

Telvent.SE.SWGasQARules - QA rule to check for Excess Flow Valve

The Telvent.SE.SWGasQARules contains a QA rule that checks for the necessity of an Excess Flow Valve (EFV).  It was desgined to work on SW Gas data with minimal configuration (the EXCESSFLOWVALVE model name needs to be added and the QA rule assigned to Service).  The idea with the QA rule was to check if an EFV valve is required using the following logic:

1 - If the Service being QA'ed does not branch (meaning that there is not a three way intersection with all three lines being service) then you must have an Excess Flow Valve present.  In this case, a QA error is generated.  In this, the most simple negative case, you typically just see a single service line feeding a house without a EFV
2- A single service line with an EFV is OK
3 - A branched service line without an EFV is OK
4 - A branched service line with an EFV results in a QA Error (which is described as a warning in the QA/QC tab).

CONFIGURATION -

  • RegX the .dll
  • Add model name EXCESSFLOWVALVE
  • Verify that SERVICEPOINT uniquely identifies MeterSetting (e.g. Riser) as the only feature class.  Note that this may cause problems with Minerville data or other geodatabases where there is an electric dataset which has a ServicePoint feature class. 
  • Verify that the SERVICE model name exists on the Service feature class. 
  • Add the QA rule to the Service Line - It is name Telvent.SE.SWGasQA or something like that...it might have the word EFV in it too. 

Thursday, September 22, 2011

COM components don't show up in ArcCatalog??

If a COM component doesn't show up in ArcCatalog or ArcMap, check the following:

<---->.dll is not a valid assembly

I got an error say ---.dll is not a valid assembly.  Turned out that I had accidentlally set to x64 compilation instead of x86.

Monday, September 12, 2011

Responder AMI Advanced (Telvent.SE.ResponderAMIAdvanced)

Basic steps required for demonstration / testing

  1. Clear out all existing incidents in Responder Explorer
  2. On Claymaker, run TroubleMaker (TM) and select anything with "UP" and "Connect" in the scenario. This will bascially reset the demonstration. 
    1. You can verify that the meters involved in the demo are powered up by running the SQL command QueryStateStore.sql in SQL Management studio (you should see that 13 are Power Up" and 66,000 are unknown).
  3. In ArcMap, open the Smart Grid 2 stored display
  4. Run the Remote Disconnect scenario in TM
  5. Log into Responder Web (http://claymaker/Responder/login.aspx) using Administrator / adminpass
    1. Go to the Customer Service tab and perform a Customer Call
    2. For meter number, type e46295 and click the Search button
  6. Note that the critical status is "Disconnected AMI" but that the status is "Power Up".  This customer simply didn't pay their bill. 
  7. Run AMI power down in TM
  8. Go to the AMI outage area bookmark in ArcMap and refresh the screen (multple times possibly).  You should see six or so customers out of power. 
  9. In RxExplorer, assign crew to the newly created incident
  10. Right-click (RC) on crew assignments to get the crew status to read "working" (indicated by a blue dot)...assing crew IPC 001....you have to go through Dispatced state first, and then wait a few seconds before going to Working. 
  11. Set ETR (estimated time of Restore by RC on incident. 
  12. On RxWeb, note that Jean Haverfield is now power down. 
  13. In TM, select remote connect and AMI power up and execute those scenarios.  Poor customer paid his bill, but the power was off when he did so. 
  14. Manage the incident in RxExplorer through "Restore".

Saturday, September 10, 2011

DOWNLOADS

Telvent.SE.ReportTools - Includes the Gas and Electric Customer reports and many others. download

SW Gas Model Name Report

Bug fix / enhancement request to have the descriptions from coded values output instead of database values.  Completed today (9-10-11)

Gas Customer Report

The Gas customer report now supports multiple customers at a single ServiceAddress. In the example below, three meters are selected. One of the meters has two customers at a single service address.  Note that I have not tested having multiple service addressses at a single meter.  That probably won't work as is. 

Friday, September 2, 2011

SW Gas: Logica WMS / GIS Integration

Assumptions: This code only works on an SDE database. You will get errors when trying to save your design if you are working with a personal geodatabase because in Brook's code, he assumes the existence of a VERSION node in the Design XML.

Exporting image

I was thinking for some reports it might be nice to include a map image.  Here's a little VBA code to do that.  I'd like to see if I can get this to work in the context of an HTML report (e.g. Brook's MM Report tools)


Private Sub export()
    Dim pexp As IExport
    Set pexp = New ExportJPEG
    pexp.ExportFileName = "c:\temp\test.jpg"
    pexp.Resolution = 96
    Dim x As tagRECT
    Dim mxDoc As IMxDocument
    Set mxDoc = ThisDocument
    Dim av As IActiveView
    Set av = mxDoc.ActiveView
    x = av.ExportFrame
    Dim env As IEnvelope
    Set env = New Envelope
    env.PutCoords x.Left, x.Top, x.Right, x.bottom
    pexp.PixelBounds = env
    Dim hdc As Long
    hdc = pexp.StartExporting
    av.Output hdc, pexp.Resolution, x, Nothing, Nothing
    pexp.FinishExporting
    pexp.Cleanup
End Sub

Getting IApplication

When working with IApplication, you can't call New AppRefClass() because AppRef is a singleton object.  Here's what you do instead. 
Type t2 = Type.GetTypeFromProgID("esriCore.AppRef");
System.Object obj = Activator.CreateInstance(t2);
IApplication app = obj as IApplication;
http://forums.esri.com/Thread.asp?c=93&f=1170&t=67573#177441


JAX: AAL - Using conditional logic, ancestor labeler, and SQL functions

I put together a label expression for JAX today for fuses that was rather interesting.  Below are the requirements and the email that I sent to Greg Garner:

Attached are two screen shots showing the label expression that satisfy (I believe) the label expression you were looking for for JAX. This is on Minerville, so of course some of the field names might be different...I used FuseUnit:LinkRating instead of FuseSize (which Minerville doesn't have).  And I used FuseBank:FacilityID because Minerville doesn't have a FuseNumber field.  I changed the errors from "ERROR" to more explicitly state why there was an error (e.g. 'Bank has a null FacilityID' or 'Unit sizes don't match').

The two screen shots show the required SQL for the two relationship labelers that are used.  Note that the expression also uses an ancestor labeler.  Anyway, it is a bit to swallow, but it does, I think, nicely showcase the power of AAL and if you know SQL, it is quite readable.  Let me know if you want to go through the expression or if you have questions about it.

Devon

1.3        Fuse Labeltext AU

Requirement
JAX has map labeling requirements for OH Fuses that include attributes from related child objects, namely the related eFuseunit records.

 The logic for the AU is provided below:

If the eFusebank is 2 or 3 phase and the eFuseUnit.FuseSizes do not match
or the eFuseBank.FuseNumber is null or = “UN”

Then set Label = “ERROR”

Else
eFuseUnit.FuseSize & “A “ & eFuseBank.FuseNumber

Ex. 10A 3321



SQL Expression for first Relationship Labeler
SQL Expression for second relationship labeler

S

Thursday, September 1, 2011

SW Gas: Create perpendicular bisectors

Although as it turns out this code is no longer really needed, I wrote some VBA code to create perpendicular from points to lines (e.g. from disconnected service point to secondary OH).  As shown in the image, this works in edit mode on a selected set of points (first layer in the TOC).  The second layer is the line layer. Click the button and "Bob's your uncle".  You can modify the VBA code (below) to increase or decrease the search distance as required.  Note that it finds the NEAREST line to the selected point, but if outside the search tolerance, than no perpendicular is created.  Make sure to save your edits after editing.  If you undo, all the edits for that one click of the button are undone.

Click to enlarge
Here's the code which you can paste into the VBA editor.  You might want to add a button to the ArcMap UI as shown in the image. 

Option Explicit
Private Sub CreateBisectors()
'PURPOSE - Constructs perpindicular bisectors from the selected point
'in layer #1 to the nearest line in layer #2 within xx feet. Note that
'you must save your edits after using this tool.
'ASSUMPTIONS - must be editing to use the layer.
'This code assumes that the point layer is the first layer in the TOC
'and that the line layer (the layer that we will be adding to) is the
'the second layer
Dim SEARCHDISTANCE As Double, SUBTYPECODE As Long
SEARCHDISTANCE = 10
SUBTYPECODE = 1

On Error GoTo eh
Dim startedOperation As Boolean
Dim ed As IEditor
Set ed = Application.FindExtensionByName("ESRI OBJECT EDITOR")
ed.StartOperation
startedOperation = True
Dim sf As ISpatialFilter
Set sf = New SpatialFilter
sf.GeometryField = "SHAPE"
sf.SpatialRel = esriSpatialRelIntersects
Dim mxdoc As IMxDocument
Set mxdoc = ThisDocument
Dim pntLayer As IFeatureLayer, linLayer As IFeatureLayer
Set pntLayer = mxdoc.FocusMap.Layer(0)
Set linLayer = mxdoc.FocusMap.Layer(1)
Dim linFC As IFeatureClass
Set linFC = linLayer.FeatureClass
Dim feSel As IFeatureSelection
Set feSel = pntLayer
Dim pntCur As IFeatureCursor
feSel.SelectionSet.Search Nothing, False, pntCur
Dim pntFE As IFeature
Set pntFE = pntCur.NextFeature
Do While Not pntFE Is Nothing
  Dim selPoint As IPoint
  Set selPoint = pntFE.ShapeCopy
  Dim topOp As ITopologicalOperator
  Set topOp = selPoint
  Dim buf As IGeometry
  Set buf = topOp.Buffer(SEARCHDISTANCE)
  Set sf.Geometry = buf
  Dim linCur As IFeatureCursor
  Set linCur = linLayer.Search(sf, False)
  Dim linFe As IFeature
  Set linFe = linCur.NextFeature
  Dim nearestSoFar As Double
  nearestSoFar = SEARCHDISTANCE
  Dim nearestLineFe As IFeature
  Set nearestLineFe = Nothing
  Do While Not linFe Is Nothing
    Dim proxOp As IProximityOperator
    Set proxOp = linFe.ShapeCopy
    Dim retDist As Double
    retDist = proxOp.ReturnDistance(selPoint)
    If (retDist < nearestSoFar) Then
      Set nearestLineFe = linFe
      nearestSoFar = retDist
    End If
    Set linFe = linCur.NextFeature
  Loop
  If Not nearestLineFe Is Nothing Then
    Dim c3 As ICurve3
    Set c3 = nearestLineFe.ShapeCopy
    Dim outPoint As IPoint, dac As Double, dfc As Double, brs As Boolean
    Set outPoint = New Point
    c3.QueryPointAndDistance esriNoExtension, selPoint, False, outPoint, dac, dfc, brs
    If Not outPoint Is Nothing Then
        Dim newFe As IFeature
        Set newFe = linFC.CreateFeature
        Dim pl As ISegmentCollection
        Set pl = New Polyline
        Dim ln As ILine
        Set ln = New Line
        ln.FromPoint = outPoint
        ln.ToPoint = selPoint
        pl.AddSegment ln
        Set newFe.Shape = pl
        newFe.Value(newFe.Fields.FindField("SUBTYPECD")) = SUBTYPECODE
        newFe.Store
    End If
  End If
  Set pntFE = pntCur.NextFeature
Loop
ed.StopOperation "Create perpindicular bisectors"
startedOperation = False
mxdoc.ActiveView.Refresh
Exit Sub
eh:
MsgBox "An error occured. Please stop editing, and do NOT save edits."
If startedOperation = True Then
    ed.StopOperation "An error occured. Please do not save edits"
End If

End Sub


Private Sub UIButtonControl1_Click()
CreateBisectors
End Sub