Skip to content

Commit

Permalink
StatusCode now an object
Browse files Browse the repository at this point in the history
  • Loading branch information
erossignon committed Feb 23, 2014
1 parent c8eff27 commit a4e828e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 43 deletions.
16 changes: 8 additions & 8 deletions lib/opcua_node_ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@
HistoryModifiedData: 11217 ,
HistoryUpdateType: 11234 ,
PerformUpdateType: 11293 ,
UpdateStructureDataDetails: 11295 ,
UpdateStructureDataDetails: 11295
};
exports.ReferenceType= {
References: 31 ,
Expand Down Expand Up @@ -311,7 +311,7 @@
AlwaysGeneratesEvent: 3065 ,
HasTrueSubState: 9004 ,
HasFalseSubState: 9005 ,
HasCondition: 9006 ,
HasCondition: 9006
};
exports.ObjectType= {
BaseObjectType: 58 ,
Expand Down Expand Up @@ -416,7 +416,7 @@
AggregateFunctionsType: 11167 ,
AggregateConfigurationType: 11187 ,
ProgressEventType: 11436 ,
SystemStatusChangeEventType: 11446 ,
SystemStatusChangeEventType: 11446
};
exports.VariableType= {
BaseVariableType: 62 ,
Expand Down Expand Up @@ -449,7 +449,7 @@
TwoStateVariableType: 8995 ,
ConditionVariableType: 9002 ,
MultiStateValueDiscreteType: 11238 ,
OptionSetType: 11487 ,
OptionSetType: 11487
};
exports.Object= {
ModellingRule_Mandatory: 78 ,
Expand Down Expand Up @@ -1152,7 +1152,7 @@
AggregateFunction_StandardDeviationSample: 11426 ,
AggregateFunction_StandardDeviationPopulation: 11427 ,
AggregateFunction_VarianceSample: 11428 ,
AggregateFunction_VariancePopulation: 11429 ,
AggregateFunction_VariancePopulation: 11429
};
exports.Variable= {
DataTypeDescriptionType_DataTypeVersion: 104 ,
Expand Down Expand Up @@ -1317,7 +1317,7 @@
Server_ServerStatus_BuildInfo_ProductName: 2261 ,
Server_ServerStatus_BuildInfo_ProductUri: 2262 ,
Server_ServerStatus_BuildInfo_ManufacturerName: 2263 ,
Server_ServerStatus_BuildInfo_SoftwareVersion: 2264 ,
Server_ServerStatus_BuildInfo_SoftwareVersion: 2264 ,
Server_ServerStatus_BuildInfo_BuildNumber: 2265 ,
Server_ServerStatus_BuildInfo_BuildDate: 2266 ,
Server_ServiceLevel: 2267 ,
Expand Down Expand Up @@ -5458,7 +5458,7 @@
Server_GetMonitoredItems_InputArguments: 11493 ,
Server_GetMonitoredItems_OutputArguments: 11494 ,
GetMonitoredItemsMethodType_InputArguments: 11496 ,
GetMonitoredItemsMethodType_OutputArguments: 11497 ,
GetMonitoredItemsMethodType_OutputArguments: 11497
};
exports.Method= {
ProgramStateMachineType_Start: 2426 ,
Expand Down Expand Up @@ -5611,5 +5611,5 @@
TripAlarmType_ShelvingState_TimedShelve: 10861 ,
ServerType_GetMonitoredItems: 11489 ,
Server_GetMonitoredItems: 11492 ,
GetMonitoredItemsMethodType: 11495 ,
GetMonitoredItemsMethodType: 11495
};
47 changes: 12 additions & 35 deletions lib/opcua_status_code.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,35 @@ function StatusCode(options) {
}
StatusCode.prototype.toString = function() {
return this.name +" (0x" + this.highword.toString(16) + "0000)" ;
}
};

exports.StatusCode = StatusCode;


var encodeStatusCode = function(statusCode,stream)
{
var encodeStatusCode = function(statusCode,stream) {
assert(statusCode instanceof StatusCode);
stream.writeUInt16(0);
stream.writeUInt16(statusCode.highword);
}
};

exports.encodeStatusCode = encodeStatusCode;

var decodeStatusCode = function(stream)
{
var decodeStatusCode = function(stream) {

// read low word
var l = stream.readUInt16();
// read high word
var h = stream.readUInt16();
var code = h & 0x3FFF;

var sc = StatusCodes_reverse_map[code];
if (!sc){
console.log("code = ",code);
return StatusCodes_reverse_map[1];
}
assert(sc !== null,"expecting a known StatusCode");
return sc;
};

}
exports.decodeStatusCode = decodeStatusCode;

/*
function makeStatusCode(statusCode, severity) {
if (typeof(statusCode) === "string" && statusCode.substr(0,2) === "0x") {
var a1 = "00000000" + statusCode.substr(2);
a1 = a1.substr(a1.length-8);
high = parseInt("0x"+a1.substr(0,4));
low = parseInt("0x"+a1.substr(4,8));
return [ low.toString(16),high.toString(16)]
} else {
var util = require("util");
assert(isFinite(statusCode.value), "invalid status code provided " + util.inspect(statusCode));
high = (statusCode.value | 0x8000);
low = 0;
//xx var b = new Buffer(8);
//xx b.writeUInt8(low ,0);
//xx b.writeUInt32LE(high,4);
//xx return b.toString("hex");
return [ low.toString(16),high.toString(16)]
}
}
exports.makeStatusCode = makeStatusCode;
*/

/* construct status codes fast search indexes */
var StatusCodes_reverse_map = {};
_.forEach(StatusCodes, function(code) {
code = new StatusCode(code);
Expand Down
Empty file removed lib/status_code.js
Empty file.

0 comments on commit a4e828e

Please sign in to comment.