View Issue Details

IDProjectCategoryView StatusLast Update
0004086Compliance Test Tool (CTT) Unified Architecture1 - Script Issuepublic2019-08-31 14:45
ReporterBernd Edlinger Assigned ToAlexander Allmendinger  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
PlatformPCOSWindowsOS Version8.1
Product Version1.03.340.378 
Target Version1.03Fixed in Version1.03 
Summary0004086: Attribute Services/Attribute Write Values/012.js writes larger array than expected
Description

Due to a logic error in this script the dimension of the first array
is written to the second array:

var expectedResultsArray = [];
var arrayWriteValues = [];
var itemsArray  = MonitoredItem.fromSettings( settingArray );
if( !isDefined( itemsArray ) || itemsArray.length === 0 ) {
    addSkipped( "Node type(s) not configured within the setting: " + settingArray + "." );
    return( false );
}
if( ReadHelper.Execute( { NodesToRead: itemsArray } ) ) {
    for ( var j=0; j<itemsArray.length; j++ ) {
        // cache the values so that we can revert them
        itemsArray[j].OriginalValue = itemsArray[j].Value.Value.clone();
        expectedResultsArray[j] = new ExpectedAndAcceptedResults( [ StatusCode.BadOutOfRange, StatusCode.BadIndexRangeNoData, StatusCode.Good ] );
        valueLen = itemsArray[j].Value.Value.getArraySize();
        for (var jj=0; jj<valueLen; jj++ ) { arrayWriteValues[jj] = NaN; } // <= error happens here
        // We can't be sure that a zero-length array can be changed, so make sure the array is populated
        if( Assert.GreaterThan( 0, valueLen, "The array is currently empty. Please reconfigure the array with a value and test again." ) ) {
            setValue( itemsArray[j], arrayWriteValues, itemsArray[j].Value.Value.DataType, true );
        }
    }// for(var j = 0;
    // Write the value; we expect it to succeed
    WriteHelper.Execute( { NodesToWrite: itemsArray, OperationResults: expectedResultsArray, CheckNotSupported: true, ReadVerification: false } );

    // revert to original values 
    for( var i=0; i<itemsArray.length; i++ ) itemsArray[i].Value.Value = itemsArray[i].OriginalValue.clone();
    WriteHelper.Execute( { NodesToWrite: itemsArray, ReadVerification: false } );
}

arrayWriteValues "accumulates" NaNs from the first iteration.
Result is that first array has 6 doubles and second array has 3 floats
but write request writes 6 doubles and 6 floats. The server does not
support more than 3 floats in the second array.

TagsNo tags attached.
Files Affected

Activities

Alexander Allmendinger

2018-02-14 18:24

developer   ~0008878

Moved the declaration of the arrayWriteValues in the for loop as it is not needed outside of it. This resets the value for each iteration.

Paul Hunkar

2019-08-31 14:45

administrator   ~0010858

reviewed in extra CMP call

Issue History

Date Modified Username Field Change
2017-12-06 11:22 Bernd Edlinger New Issue
2017-12-06 11:22 Bernd Edlinger Status new => assigned
2017-12-06 11:22 Bernd Edlinger Assigned To => Alexander Allmendinger
2017-12-07 16:21 Paul Hunkar Target Version => 1.03
2018-02-14 18:24 Alexander Allmendinger Note Added: 0008878
2018-02-14 18:24 Alexander Allmendinger Status assigned => resolved
2018-02-14 18:24 Alexander Allmendinger Fixed in Version => 1.03
2018-02-14 18:24 Alexander Allmendinger Resolution open => fixed
2019-01-28 14:10 Paul Hunkar Category Script Issue => 1 - Script Issue
2019-08-31 14:45 Paul Hunkar Status resolved => closed
2019-08-31 14:45 Paul Hunkar Note Added: 0010858