/// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void Validation() { //Form currForm = Form.ActiveForm; //Control.ControlCollection coll = currForm.Controls; //PPLMain pMain = currForm.ActiveControl as PPLMain; //foreach (Control ctl in coll) //{ //} //pMain.Focus(); //FormCollection frmColl = Application.OpenForms; //foreach (Form f in frmColl) //{ // if (f.Name.Contains("PGE")) // { // PPLMain main = f.ActiveControl as PPLMain; // } //} //cPPLMain = pPPLMain; PPLPole pole = cPPLMain.GetPole(); cPPLMain.cInventory.SortInventory(); string sapPM = pole.GetValueString("Aux Data 1"); string ocalcPoleLoc = pole.GetValueString("Aux Data 3"); double poleSetDepth = pole.GetValueDouble("BuryDepthInInches"); double upperCommHoa = 0; string owner = null; string[] allowableCompositePoles = new string[] { "T1D45", "T3D45", "H2D45", "H4D45", "T1D50", "T3D50", "H2D50", "H4D50", "T1D55", "T3D55", "H2D55", "H4D55", "H3D65", "H5D65" }; //these are the poles we can order in EES double lowestCrossArmHeight = pole.GetValueDouble("LengthInInches"); //initialize to height of pole. check each iteration of crossarm to find the lowest double[] poleSettingDepth = new double[] { (4.5 * 12), (5 * 12), (5.5 * 12), (6 * 12), (6.5 * 12), (7 * 12), (7.5 * 12), (8 * 12), (8.5 * 12), (9 * 12), (9.5 * 12), (10 * 12), (10.5 * 12) }; double[] allowableMoment = new double[] { 8050, 11000, 17300, 24500, 35300, 47500, 67000, 91000, 126000, 170000, 225000, 295000, 395000 }; PPLElementCollection elems = pole.GetElementList(); //check for undefined owners & get highest comm height of attachment & check for composite poles that can't be ordered & //update composite pole overturn moment foreach (PPLElement elem in elems) { //check for element with undefined owner owner = elem.GetValueString("Owner"); if (owner == "<Undefined>") { MessageBox.Show("The owner of " + elem.DescriptionString + " is Undefined."); } //set undefined owner of anchor to PG&E if (owner == "<Undefined>" && elem is PPLAnchor) { elem.SetValue("Owner", "PG&E"); } //check for composite pole that can't be ordered if (elem is PPLCompositePole) { string poleCatalogName = elem.GetValueString("CatalogName"); bool isAllowed = false; for (int i = 0; i < allowableCompositePoles.Length; i++) { isAllowed = allowableCompositePoles[i].Equals(poleCatalogName); if (isAllowed) { break; } else if (i == allowableCompositePoles.Length - 1) { PPLMessageBox.Show("Pole cannot be ordered in EES. Please choose a different pole."); } } //update allowable moment if pole setting depth is manually changed for (int j = 0; j < allowableMoment.Length; j++) { double currentPoleSetDepth = elem.GetValueDouble("BuryDepthInInches"); double currentOverturnMoment = elem.GetValueDouble("OverturnMoment"); if (Array.IndexOf(poleSettingDepth, currentPoleSetDepth).Equals(Array.IndexOf(allowableMoment, currentOverturnMoment))) { break; } else if (currentPoleSetDepth == poleSettingDepth[j]) { elem.SetValue("OverturnMoment", allowableMoment[j]); PPLMessageBox.Show("Overturn moment has been updated to match current set depth"); break; } else if (j == allowableMoment.Length - 1) { PPLMessageBox.Show("Could not find an overturn moment to match " + currentPoleSetDepth / 12 + "' set depth"); break; } } } //check for comm out of grade if (elem is PPLSpan && elem.Parent is PPLInsulator && (owner == "Comm" | owner == "COMM" | owner == "comm" | owner == "CATV" | owner == "catv" | owner == "Catv")) { double commHoa = (elem.Parent.GetValueDouble("CoordinateZ") - poleSetDepth) / 12; if (commHoa > upperCommHoa) { upperCommHoa = commHoa; } } //check for wood crossarm if (elem is PPLCrossArm) { string crossarmMaterial = elem.GetValueString("Material"); if (crossarmMaterial == "Wood" | crossarmMaterial == "Other") { MessageBox.Show("The " + elem.DescriptionString + " crossarm material is not currently allowed."); } //get height of lowest crossarm for transformer mounting height reference double currentCrossarmHeight = elem.GetValueDouble("CoordinateZ"); if (currentCrossarmHeight <= lowestCrossArmHeight) { lowestCrossArmHeight = currentCrossarmHeight; } //PPLMessageBox.Show(Convert.ToString(lowestCrossArmHeight)); } //check that transformer is mounted 3.25' below lowest primary crossarm and set mounting height if it is not if (/*elem is PPLGenericEquipment || */ elem is PPLTransformer && elem.TypeString == "Transformer") { double txHeight = elem.GetValueDouble("CoordinateZ"); if (txHeight != (lowestCrossArmHeight - (3.25 * 12))) { DialogResult dialogResult = MessageBox.Show("Current height of transformer is not 3.25' below lower crossarm. Do you want to set it?", "Transformer Height Notification", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { elem.SetValue("CoordinateZ", lowestCrossArmHeight - (3.25 * 12)); MessageBox.Show("Transformer height has been updated"); } else { MessageBox.Show("Transformer height has not been updated"); } } } } //MessageBox.Show("the highest comm hoa is " + upperCommHoa.ToString()); //check for pge owner assigned guys below comm owned spans foreach (PPLElement guy in elems) { if (guy is PPLGuyBrace) { double guyHoa = (guy.GetValueDouble("CoordinateZ") - poleSetDepth) / 12; string guyOwner = guy.GetValueString("Owner"); if (guyHoa <= upperCommHoa && guyOwner != "Comm") { MessageBox.Show("The " + guy.DescriptionString + " guy attached at " + guyHoa + "ft, is in communication's space, but the owner is " + guyOwner + "."); guy.SetValue("Owner", "Comm"); } //Check for comm owned guys above comm owned spans else if (guyHoa > upperCommHoa && guyOwner == "Comm") { PPLMessageBox.Show("The " + guy.DescriptionString + " guy attached at " + guyHoa + "ft is above communication's space, but the owner is " + guyOwner + "."); guy.SetValue("Owner", "PG&E"); } } } OcalcReload(cPPLMain); }