本文整理汇总了C#中Opc.Ua.StatusCode类的典型用法代码示例。如果您正苦于以下问题:C# StatusCode类的具体用法?C# StatusCode怎么用?C# StatusCode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StatusCode类属于Opc.Ua命名空间,在下文中一共展示了StatusCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ServiceResult
/// <summary>
/// Constructs a object by specifying each property.
/// </summary>
public ServiceResult(
StatusCode code,
ServiceResult innerResult)
:
this(code, null, null, null, null, innerResult)
{
}
示例2: ToCode
/// <summary>
/// Converts a code to a numeric value.
/// </summary>
public static uint ToCode(StatusCode statusCode)
{
if (statusCode == null)
{
return StatusCodes.Good;
}
return statusCode.Code;
}
示例3: IsBad
/// <summary>
/// Checks if the status code is bad.
/// </summary>
public static bool IsBad(StatusCode statusCode)
{
if ((ToCode(statusCode) & 0x80000000) != 0)
{
return true;
}
return false;
}
示例4: OnDataChange
/// <summary>
/// Updates the variable after receiving a notification that it has changed in the underlying system.
/// </summary>
public void OnDataChange(BaseVariableState variable, object value, StatusCode statusCode, DateTime timestamp)
{
lock (Lock)
{
variable.Value = value;
variable.StatusCode = statusCode;
variable.Timestamp = timestamp;
// notifies any monitored items that the value has changed.
variable.ClearChangeMasks(SystemContext, false);
}
}
示例5: OnChangeLockByWrite
public ServiceResult OnChangeLockByWrite(
ISystemContext context,
NodeState node,
NumericRange indexRange,
QualifiedName dataEncoding,
ref object value,
ref StatusCode statusCode,
ref DateTime timestamp)
{
DsatsDemo.LockConditionState condition = null;
BaseInstanceState instance = node as BaseInstanceState;
if (instance.Parent != null)
{
condition = instance.Parent as DsatsDemo.LockConditionState;
}
if (condition == null)
{
return StatusCodes.BadNotWritable;
}
string lockState = value as string;
if (lockState == null)
{
return StatusCodes.BadTypeMismatch;
}
if (lockState == "Locked")
{
ServiceResult result = OnRequestLock(context, condition.Request, condition.NodeId, new object[0], new object[0]);
value = condition.LockStateAsString.Value;
return result;
}
else if (lockState == "Unlocked")
{
ServiceResult result = OnReleaseLock(context, condition.Request, condition.NodeId, new object[0], new object[0]);
value = condition.LockStateAsString.Value;
return result;
}
return StatusCodes.BadTypeMismatch;
}
示例6: AddValue
/// <summary>
/// Adds a value to the grid.
/// </summary>
private void AddValue(DataValue value, ModificationInfo modificationInfo)
{
DataRow row = m_dataset.Tables[0].NewRow();
row[0] = m_nextId++;
row[1] = value.SourceTimestamp.ToLocalTime().ToString("HH:mm:ss.fff");
row[2] = value.WrappedValue;
row[3] = new StatusCode(value.StatusCode.Code);
if (value.WrappedValue.TypeInfo != null)
{
row[4] = value.WrappedValue.TypeInfo.BuiltInType.ToString();
}
else
{
row[4] = String.Empty;
}
m_dataset.Tables[0].Rows.Add(row);
}
示例7: OnUserScalarValue2
private ServiceResult OnUserScalarValue2(
ISystemContext context,
MethodState method,
NodeId objectId,
DateTime dateTimeIn,
Uuid guidIn,
byte[] byteStringIn,
XmlElement xmlElementIn,
NodeId nodeIdIn,
ExpandedNodeId expandedNodeIdIn,
QualifiedName qualifiedNameIn,
LocalizedText localizedTextIn,
StatusCode statusCodeIn,
object variantIn,
ref DateTime dateTimeOut,
ref Uuid guidOut,
ref byte[] byteStringOut,
ref XmlElement xmlElementOut,
ref NodeId nodeIdOut,
ref ExpandedNodeId expandedNodeIdOut,
ref QualifiedName qualifiedNameOut,
ref LocalizedText localizedTextOut,
ref StatusCode statusCodeOut,
ref object variantOut)
{
dateTimeOut = dateTimeIn;
guidOut = guidIn;
byteStringOut = byteStringIn;
xmlElementOut = xmlElementIn;
nodeIdOut = nodeIdIn;
expandedNodeIdOut = expandedNodeIdIn;
qualifiedNameOut = qualifiedNameIn;
localizedTextOut = localizedTextIn;
statusCodeOut = statusCodeIn;
variantOut = variantIn;
return ServiceResult.Good;
}
示例8: OnUserArrayValue2
private ServiceResult OnUserArrayValue2(
ISystemContext context,
MethodState method,
NodeId objectId,
DateTime[] dateTimeIn,
Uuid[] guidIn,
byte[][] byteStringIn,
XmlElement[] xmlElementIn,
NodeId[] nodeIdIn,
ExpandedNodeId[] expandedNodeIdIn,
QualifiedName[] qualifiedNameIn,
LocalizedText[] localizedTextIn,
StatusCode[] statusCodeIn,
Variant[] variantIn,
ref DateTime[] dateTimeOut,
ref Uuid[] guidOut,
ref byte[][] byteStringOut,
ref XmlElement[] xmlElementOut,
ref NodeId[] nodeIdOut,
ref ExpandedNodeId[] expandedNodeIdOut,
ref QualifiedName[] qualifiedNameOut,
ref LocalizedText[] localizedTextOut,
ref StatusCode[] statusCodeOut,
ref Variant[] variantOut)
{
dateTimeOut = dateTimeIn;
guidOut = guidIn;
byteStringOut = byteStringIn;
xmlElementOut = xmlElementIn;
nodeIdOut = nodeIdIn;
expandedNodeIdOut = expandedNodeIdIn;
qualifiedNameOut = qualifiedNameIn;
localizedTextOut = localizedTextIn;
statusCodeOut = statusCodeIn;
variantOut = variantIn;
return ServiceResult.Good;
}
示例9: WriteTagValue
/// <summary>
/// Handles a write operation for an individual tag.
/// </summary>
public ServiceResult WriteTagValue(
ISystemContext context,
NodeState node,
NumericRange indexRange,
QualifiedName dataEncoding,
ref object value,
ref StatusCode statusCode,
ref DateTime timestamp)
{
MemoryTagState tag = node as MemoryTagState;
if (tag == null)
{
return StatusCodes.BadNodeIdUnknown;
}
if (NumericRange.Empty != indexRange)
{
return StatusCodes.BadIndexRangeInvalid;
}
if (!QualifiedName.IsNull(dataEncoding))
{
return StatusCodes.BadDataEncodingInvalid;
}
if (statusCode != StatusCodes.Good)
{
return StatusCodes.BadWriteNotSupported;
}
if (timestamp != DateTime.MinValue)
{
return StatusCodes.BadWriteNotSupported;
}
bool changed = false;
int offset = (int)tag.Offset;
lock (m_dataLock)
{
if (offset < 0 || offset >= m_buffer.Length)
{
return StatusCodes.BadNodeIdUnknown;
}
if (m_buffer == null)
{
return StatusCodes.BadOutOfService;
}
byte[] bytes = null;
switch (m_elementType)
{
case BuiltInType.UInt32:
{
uint? valueToWrite = value as uint?;
if (valueToWrite == null)
{
return StatusCodes.BadTypeMismatch;
}
bytes = BitConverter.GetBytes(valueToWrite.Value);
break;
}
case BuiltInType.Double:
{
double? valueToWrite = value as double?;
if (valueToWrite == null)
{
return StatusCodes.BadTypeMismatch;
}
bytes = BitConverter.GetBytes(valueToWrite.Value);
break;
}
default:
{
return StatusCodes.BadNodeIdUnknown;
}
}
for (int ii = 0; ii < bytes.Length; ii++)
{
if (!changed)
{
if (m_buffer[offset + ii] != bytes[ii])
{
changed = true;
}
}
//.........这里部分代码省略.........
示例10: ReadTagValue
/// <summary>
/// Handles the read operation for an invidual tag.
/// </summary>
public ServiceResult ReadTagValue(
ISystemContext context,
NodeState node,
NumericRange indexRange,
QualifiedName dataEncoding,
ref object value,
ref StatusCode statusCode,
ref DateTime timestamp)
{
MemoryTagState tag = node as MemoryTagState;
if (tag == null)
{
return StatusCodes.BadNodeIdUnknown;
}
if (NumericRange.Empty != indexRange)
{
return StatusCodes.BadIndexRangeInvalid;
}
if (!QualifiedName.IsNull(dataEncoding))
{
return StatusCodes.BadDataEncodingInvalid;
}
int offset = (int)tag.Offset;
lock (m_dataLock)
{
if (offset < 0 || offset >= m_buffer.Length)
{
return StatusCodes.BadNodeIdUnknown;
}
if (m_buffer == null)
{
return StatusCodes.BadOutOfService;
}
value = GetValueAtOffset(offset).Value;
}
statusCode = StatusCodes.Good;
timestamp = m_lastScanTime;
return ServiceResult.Good;
}
示例11: WriteStatusCode
/// <summary>
/// Writes an StatusCode to the stream.
/// </summary>
public void WriteStatusCode(string fieldName, StatusCode value)
{
if (value == StatusCodes.Good)
{
WriteSimpleField(fieldName, null, false);
return;
}
var text = StatusCode.LookupSymbolicId(value.CodeBits);
text += ":0x";
text += value.Code.ToString("X8", CultureInfo.InvariantCulture);
WriteSimpleField(fieldName, text, true);
}
示例12: DoDeviceRead
/// <summary>
/// Generates a new value each time the value is read.
/// </summary>
private ServiceResult DoDeviceRead(
ISystemContext context,
NodeState node,
NumericRange indexRange,
QualifiedName dataEncoding,
ref object value,
ref StatusCode statusCode,
ref DateTime timestamp)
{
BaseVariableState variable = node as BaseVariableState;
if (variable == null)
{
return ServiceResult.Good;
}
if (!SimulationActive.Value)
{
return ServiceResult.Good;
}
TestDataSystem system = context.SystemHandle as TestDataSystem;
if (system == null)
{
return StatusCodes.BadOutOfService;
}
try
{
value = system.ReadValue(variable);
statusCode = StatusCodes.Good;
timestamp = DateTime.UtcNow;
ServiceResult error = BaseVariableState.ApplyIndexRangeAndDataEncoding(
context,
indexRange,
dataEncoding,
ref value);
if (ServiceResult.IsBad(error))
{
statusCode = error.StatusCode;
}
return ServiceResult.Good;
}
catch (Exception e)
{
return new ServiceResult(e);
}
}
示例13: WriteValueAttribute
/// <summary>
/// Write the value for the value attribute.
/// </summary>
protected override ServiceResult WriteValueAttribute(
ISystemContext context,
NumericRange indexRange,
object value,
StatusCode statusCode,
DateTime sourceTimestamp)
{
ServiceResult result = null;
if ((WriteMask & AttributeWriteMask.ValueForVariableType) == 0)
{
return StatusCodes.BadNotWritable;
}
// ensure the source timestamp has a valid value.
if (sourceTimestamp == DateTime.MinValue)
{
sourceTimestamp = DateTime.UtcNow;
}
// index range writes not supported.
if (indexRange != NumericRange.Empty)
{
return StatusCodes.BadIndexRangeInvalid;
}
// verify data type.
TypeInfo typeInfo = TypeInfo.IsInstanceOfDataType(
value,
m_dataType,
m_valueRank,
context.NamespaceUris,
context.TypeTable);
if (typeInfo == null || typeInfo == TypeInfo.Unknown)
{
return StatusCodes.BadTypeMismatch;
}
// check for simple write value handler.
if (OnSimpleWriteValue != null)
{
result = OnSimpleWriteValue(
context,
this,
ref value);
if (ServiceResult.IsBad(result))
{
return result;
}
}
// update cached values.
Value = value;
return ServiceResult.Good;
}
示例14: FormatQuality
/// <summary>
/// Formats a StatusCide as string for serilization or display.
/// </summary>
public static string FormatQuality(StatusCode statusCode)
{
StringBuilder buffer = new StringBuilder();
buffer.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, "{0}", new StatusCode(statusCode.CodeBits));
if ((statusCode.AggregateBits & AggregateBits.Interpolated) != 0)
{
buffer.Append(", Interpolated");
}
if ((statusCode.AggregateBits & AggregateBits.Calculated) != 0)
{
buffer.Append(", Calculated");
}
if ((statusCode.AggregateBits & AggregateBits.Partial) != 0)
{
buffer.Append(", Partial");
}
if ((statusCode.AggregateBits & AggregateBits.MultipleValues) != 0)
{
buffer.Append(", MultipleValues");
}
return buffer.ToString();
}
示例15: OnChangePhaseByWrite
private ServiceResult OnChangePhaseByWrite(
ISystemContext context,
NodeState node,
NumericRange indexRange,
QualifiedName dataEncoding,
ref object value,
ref StatusCode statusCode,
ref DateTime timestamp)
{
string phase = value as string;
if (phase == null)
{
return StatusCodes.BadTypeMismatch;
}
List<IReference> references = new List<IReference>();
m_rig.Phases.GetReferences(context, references, Opc.Ua.ReferenceTypeIds.Organizes, false);
foreach (IReference reference in references)
{
if (reference.TargetId.ToString().Contains(phase))
{
return OnChangePhase(context, m_rig.ChangePhase, m_rig.NodeId, (NodeId)reference.TargetId);
}
}
return StatusCodes.BadTypeMismatch;
}