Constraint Rule on Electrical Utility Network

667
2
Jump to solution
08-25-2021 02:51 PM
LindseyStone
Occasional Contributor III

I'm getting the the below error message when attempting to apply a Rated KVA attribute to Medium Voltage Transformers.  This was a default constraint rule on devices with the Utility Utility Network Enterprise v1.  The only difference is I applied this to a Enterprise Server 10.8.1 instead of 10.9.1.  Does the arcade expression have an actual error or is because I'm applying it to an older server?

 

 

// Assigned To: ElectricDevice
// Type: Constraint
// Name: ElectricDevice - Transformer kVA
// Description: Validates that the features kVA is valid based on the type of transformer
// Subtypes: All
// Error Number: 5702
// Error Message: Feature kVA is not valid
// Trigger: Insert, Update
// Exclude From Client: False
// Disable: False

// Related Rules: Some rules rely on additional rules for execution. If this rule works in conjunction with another, they are listed below:
//    - None

// Duplicated in: This rule may be implemented on other classes, they are listed here to aid you in adjusting those rules when a code change is required.
//    - None

// *************       User Variables       *************
// This section has the functions and variables that need to be adjusted based on your implementation

// 38 - Medium Voltage Transformer
// 39 - Medium Voltage Step Transformer
var valid_asset_groups = [38, 39];
var kva = $feature.ratedpower;

// ************* End User Variables Section *************

// *************       Functions            *************
function asset_type_to_kva(id) {
    return Decode(id,
        782, [5000, 10000, 15000, 25000, 37500, 50000],
        783, [45000, 75000, 112500, 150000, 225000, 300000, 500000, 750000, 1000000, 1500000, 2000000, 2500000, 3000000, 3750000, 5000000, 7000000, 7500000, 10000000],
        785, [5000, 10000, 15000, 25000, 37500, 50000, 75000, 100000, 167000, 250000, 333000, 500000],
        788, [30000, 45000, 75000, 112500, 150000, 225000, 300000],
        789, [5000, 10000, 15000, 25000, 37500, 50000, 75000, 100000, 167000, 250000, 333000],
        792, [45000, 75000, 112500, 150000, 225000, 300000, 500000, 750000, 1000000, 1500000, 2000000, 2500000, 3000000, 3750000, 5000000, 7000000, 7500000, 10000000],
        793, [25000, 37500, 50000, 75000, 100000, 167000],
        794, [150000, 225000, 300000, 500000, 750000, 2500000],
        801, [5000, 10000, 15000, 25000, 37500, 50000, 75000, 100000, 167000, 250000, 333000, 500000],
        null)
}

// *************       End Functions         *************
if (IsEmpty(kva)){
    return true;
}

if (!Includes(valid_asset_groups, $feature.assetgroup)) {
    return true;
}

// Find the valid values, if an entry was not found, null is returned
var valid_kva = asset_type_to_kva($feature.assettype);
if (IsEmpty(valid_kva)) {
    return true;
}
return Includes(valid_kva, kva)

 

 

KVA Transformer Rule Error.JPG

 

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

The expression uses the Includes() function, which is only available since Arcade 1.12 with ArcGIS Enterprise Server 10.9

You can do it the "old" way, which is more cumbersome:

// Assigned To: ElectricDevice
// Type: Constraint
// Name: ElectricDevice - Transformer kVA
// Description: Validates that the features kVA is valid based on the type of transformer
// Subtypes: All
// Error Number: 5702
// Error Message: Feature kVA is not valid
// Trigger: Insert, Update
// Exclude From Client: False
// Disable: False

// Related Rules: Some rules rely on additional rules for execution. If this rule works in conjunction with another, they are listed below:
//    - None

// Duplicated in: This rule may be implemented on other classes, they are listed here to aid you in adjusting those rules when a code change is required.
//    - None

// *************       User Variables       *************
// This section has the functions and variables that need to be adjusted based on your implementation

// 38 - Medium Voltage Transformer
// 39 - Medium Voltage Step Transformer
var valid_asset_groups = [38, 39];
var kva = $feature.ratedpower;

// ************* End User Variables Section *************

// *************       Functions            *************
function asset_type_to_kva(id) {
    return Decode(id,
        782, [5000, 10000, 15000, 25000, 37500, 50000],
        783, [45000, 75000, 112500, 150000, 225000, 300000, 500000, 750000, 1000000, 1500000, 2000000, 2500000, 3000000, 3750000, 5000000, 7000000, 7500000, 10000000],
        785, [5000, 10000, 15000, 25000, 37500, 50000, 75000, 100000, 167000, 250000, 333000, 500000],
        788, [30000, 45000, 75000, 112500, 150000, 225000, 300000],
        789, [5000, 10000, 15000, 25000, 37500, 50000, 75000, 100000, 167000, 250000, 333000],
        792, [45000, 75000, 112500, 150000, 225000, 300000, 500000, 750000, 1000000, 1500000, 2000000, 2500000, 3000000, 3750000, 5000000, 7000000, 7500000, 10000000],
        793, [25000, 37500, 50000, 75000, 100000, 167000],
        794, [150000, 225000, 300000, 500000, 750000, 2500000],
        801, [5000, 10000, 15000, 25000, 37500, 50000, 75000, 100000, 167000, 250000, 333000, 500000],
        null)
}

// *************       End Functions         *************
if (IsEmpty(kva)){
    return true;
}

//if (!Includes(valid_asset_groups, $feature.assetgroup)) {
//    return true;
//}
for (var i in valid_asset_groups) {
    if(valid_asset_groups[i] == $feature.assetgroup) {
        return true;
    }
}

// Find the valid values, if an entry was not found, null is returned
var valid_kva = asset_type_to_kva($feature.assettype);
if (IsEmpty(valid_kva)) {
    return true;
}
//return Includes(valid_kva, kva)
for (var i in valid_kva) {
    if (valid_kva[i] == kva) {
        return true;
    }
}
return false;

 


Have a great day!
Johannes

View solution in original post

0 Kudos
2 Replies
JohannesLindner
MVP Frequent Contributor

The expression uses the Includes() function, which is only available since Arcade 1.12 with ArcGIS Enterprise Server 10.9

You can do it the "old" way, which is more cumbersome:

// Assigned To: ElectricDevice
// Type: Constraint
// Name: ElectricDevice - Transformer kVA
// Description: Validates that the features kVA is valid based on the type of transformer
// Subtypes: All
// Error Number: 5702
// Error Message: Feature kVA is not valid
// Trigger: Insert, Update
// Exclude From Client: False
// Disable: False

// Related Rules: Some rules rely on additional rules for execution. If this rule works in conjunction with another, they are listed below:
//    - None

// Duplicated in: This rule may be implemented on other classes, they are listed here to aid you in adjusting those rules when a code change is required.
//    - None

// *************       User Variables       *************
// This section has the functions and variables that need to be adjusted based on your implementation

// 38 - Medium Voltage Transformer
// 39 - Medium Voltage Step Transformer
var valid_asset_groups = [38, 39];
var kva = $feature.ratedpower;

// ************* End User Variables Section *************

// *************       Functions            *************
function asset_type_to_kva(id) {
    return Decode(id,
        782, [5000, 10000, 15000, 25000, 37500, 50000],
        783, [45000, 75000, 112500, 150000, 225000, 300000, 500000, 750000, 1000000, 1500000, 2000000, 2500000, 3000000, 3750000, 5000000, 7000000, 7500000, 10000000],
        785, [5000, 10000, 15000, 25000, 37500, 50000, 75000, 100000, 167000, 250000, 333000, 500000],
        788, [30000, 45000, 75000, 112500, 150000, 225000, 300000],
        789, [5000, 10000, 15000, 25000, 37500, 50000, 75000, 100000, 167000, 250000, 333000],
        792, [45000, 75000, 112500, 150000, 225000, 300000, 500000, 750000, 1000000, 1500000, 2000000, 2500000, 3000000, 3750000, 5000000, 7000000, 7500000, 10000000],
        793, [25000, 37500, 50000, 75000, 100000, 167000],
        794, [150000, 225000, 300000, 500000, 750000, 2500000],
        801, [5000, 10000, 15000, 25000, 37500, 50000, 75000, 100000, 167000, 250000, 333000, 500000],
        null)
}

// *************       End Functions         *************
if (IsEmpty(kva)){
    return true;
}

//if (!Includes(valid_asset_groups, $feature.assetgroup)) {
//    return true;
//}
for (var i in valid_asset_groups) {
    if(valid_asset_groups[i] == $feature.assetgroup) {
        return true;
    }
}

// Find the valid values, if an entry was not found, null is returned
var valid_kva = asset_type_to_kva($feature.assettype);
if (IsEmpty(valid_kva)) {
    return true;
}
//return Includes(valid_kva, kva)
for (var i in valid_kva) {
    if (valid_kva[i] == kva) {
        return true;
    }
}
return false;

 


Have a great day!
Johannes
0 Kudos
LindseyStone
Occasional Contributor III

Thanks Johannes, that was what I was assuming.  I just disabled the rule for now and I can make edits appropriately.  I will also give your adjustments a try.

0 Kudos