本文整理汇总了C#中Opc.Ua.MethodState类的典型用法代码示例。如果您正苦于以下问题:C# MethodState类的具体用法?C# MethodState怎么用?C# MethodState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodState类属于Opc.Ua命名空间,在下文中一共展示了MethodState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnGenerateValues
/// <summary>
/// Handles the generate values method.
/// </summary>
protected override ServiceResult OnGenerateValues(
ISystemContext context,
MethodState method,
NodeId objectId,
uint count)
{
TestDataSystem system = context.SystemHandle as TestDataSystem;
if (system == null)
{
return StatusCodes.BadOutOfService;
}
GenerateValue(system, SByteValue);
GenerateValue(system, ByteValue);
GenerateValue(system, Int16Value);
GenerateValue(system, UInt16Value);
GenerateValue(system, Int32Value);
GenerateValue(system, UInt32Value);
GenerateValue(system, UInt32Value);
GenerateValue(system, Int64Value);
GenerateValue(system, UInt64Value);
GenerateValue(system, FloatValue);
GenerateValue(system, DoubleValue);
GenerateValue(system, NumberValue);
GenerateValue(system, IntegerValue);
GenerateValue(system, UIntegerValue);
return base.OnGenerateValues(context, method, objectId, count);
}
示例2: CreateAddressSpace
public override void CreateAddressSpace(IDictionary<NodeId, IList<IReference>> externalReferences)
{
base.CreateAddressSpace(externalReferences);
// hard code a sample branch that has the method added.
NodeId branchId = DaModelUtils.ConstructIdForDaElement("Static/Simple Types", -1, NamespaceIndex);
// create the method.
MethodState method = new MethodState(null);
method.NodeId = GenerateNodeId();
method.BrowseName = new QualifiedName("GenerateRandomValues", NamespaceIndex);
method.DisplayName = method.BrowseName.Name;
method.Executable = true;
method.UserExecutable = true;
method.ReferenceTypeId = ReferenceTypeIds.HasComponent;
method.Handle = "Static/Simple Types";
method.AddReference(ReferenceTypeIds.HasComponent, true, branchId);
m_references[branchId] = new IReference[] { new NodeStateReference(ReferenceTypeIds.HasComponent, false, method) };
// save the node for later lookup (all tightly coupled children are added with this call).
AddPredefinedNode(SystemContext, method);
// register handler.
method.OnCallMethod = new GenericMethodCalledEventHandler(DoGenerateRandomValues);
}
示例3: OnGenerateValues
/// <summary>
/// Handles the generate values method.
/// </summary>
protected override ServiceResult OnGenerateValues(
ISystemContext context,
MethodState method,
NodeId objectId,
uint count)
{
TestDataSystem system = context.SystemHandle as TestDataSystem;
if (system == null)
{
return StatusCodes.BadOutOfService;
}
GenerateValue(system, BooleanValue);
GenerateValue(system, SByteValue);
GenerateValue(system, ByteValue);
GenerateValue(system, Int16Value);
GenerateValue(system, UInt16Value);
GenerateValue(system, Int32Value);
GenerateValue(system, UInt32Value);
GenerateValue(system, UInt32Value);
GenerateValue(system, Int64Value);
GenerateValue(system, UInt64Value);
GenerateValue(system, FloatValue);
GenerateValue(system, DoubleValue);
GenerateValue(system, StringValue);
GenerateValue(system, DateTimeValue);
GenerateValue(system, GuidValue);
GenerateValue(system, ByteStringValue);
GenerateValue(system, XmlElementValue);
GenerateValue(system, NodeIdValue);
GenerateValue(system, ExpandedNodeIdValue);
GenerateValue(system, QualifiedNameValue);
GenerateValue(system, LocalizedTextValue);
GenerateValue(system, StatusCodeValue);
GenerateValue(system, VariantValue);
GenerateValue(system, EnumerationValue);
GenerateValue(system, StructureValue);
GenerateValue(system, NumberValue);
GenerateValue(system, IntegerValue);
GenerateValue(system, UIntegerValue);
return base.OnGenerateValues(context, method, objectId, count);
}
示例4: OnScalarValue1
private ServiceResult OnScalarValue1(
ISystemContext context,
MethodState method,
NodeId objectId,
bool booleanIn,
sbyte sByteIn,
byte byteIn,
short int16In,
ushort uInt16In,
int int32In,
uint uInt32In,
long int64In,
ulong uInt64In,
float floatIn,
double doubleIn,
ref bool booleanOut,
ref sbyte sByteOut,
ref byte byteOut,
ref short int16Out,
ref ushort uInt16Out,
ref int int32Out,
ref uint uInt32Out,
ref long int64Out,
ref ulong uInt64Out,
ref float floatOut,
ref double doubleOut)
{
booleanOut = booleanIn;
sByteOut = sByteIn;
byteOut = byteIn;
int16Out = int16In;
uInt16Out = uInt16In;
int32Out = int32In;
uInt32Out = uInt32In;
int64Out = int64In;
uInt64Out = uInt64In;
floatOut = floatIn;
doubleOut = doubleIn;
return ServiceResult.Good;
}
示例5: OnArrayValue3
private ServiceResult OnArrayValue3(
ISystemContext context,
MethodState method,
NodeId objectId,
Variant[] variantIn,
int[] enumerationIn,
ExtensionObject[] structureIn,
ref Variant[] variantOut,
ref int[] enumerationOut,
ref ExtensionObject[] structureOut)
{
variantOut = variantIn;
enumerationOut = enumerationIn;
structureOut = structureIn;
return ServiceResult.Good;
}
示例6: OnTimedShelve
/// <summary>
/// Handles the TimedShelve method.
/// </summary>
protected virtual ServiceResult OnTimedShelve(
ISystemContext context,
MethodState method,
NodeId objectId,
double shelvingTime)
{
ServiceResult error = null;
try
{
if (!this.EnabledState.Id.Value)
{
return error = StatusCodes.BadConditionDisabled;
}
if (shelvingTime <= 0 || (this.MaxTimeShelved != null && shelvingTime > this.MaxTimeShelved.Value))
{
return error = StatusCodes.BadShelvingTimeOutOfRange;
}
if (!this.ShelvingState.IsCausePermitted(context, Methods.ShelvedStateMachineType_TimedShelve, false))
{
return error = StatusCodes.BadConditionAlreadyShelved;
}
if (OnShelve == null)
{
return error = StatusCodes.BadNotSupported;
}
error = OnShelve(context, this, true, false, shelvingTime);
// report a state change event.
if (ServiceResult.IsGood(error))
{
ReportStateChange(context, false);
}
}
finally
{
if (this.AreEventsMonitored)
{
AuditConditionShelvingEventState e = new AuditConditionShelvingEventState(null);
TranslationInfo info = new TranslationInfo(
"AuditConditionTimedShelve",
"en-US",
"The TimedShelve method was called.");
e.Initialize(
context,
this,
EventSeverity.Low,
new LocalizedText(info),
ServiceResult.IsGood(error),
DateTime.UtcNow);
e.SourceName.Value = "Attribute/Call";
e.MethodId = new PropertyState<NodeId>(e);
e.MethodId.Value = method.NodeId;
e.InputArguments = new PropertyState<object[]>(e);
e.InputArguments.Value = new object[] { shelvingTime };
ReportEvent(context, e);
}
}
return error;
}
示例7: OnUnshelve
/// <summary>
/// Handles the Unshelve method.
/// </summary>
protected virtual ServiceResult OnUnshelve(
ISystemContext context,
MethodState method,
IList<object> inputArguments,
IList<object> outputArguments)
{
ServiceResult error = null;
try
{
if (!this.EnabledState.Id.Value)
{
return error = StatusCodes.BadConditionDisabled;
}
if (!this.ShelvingState.IsCausePermitted(context, Methods.ShelvedStateMachineType_Unshelve, false))
{
return error = StatusCodes.BadConditionNotShelved;
}
if (OnShelve == null)
{
return error = StatusCodes.BadNotSupported;
}
error = OnShelve(context, this, false, false, 0);
// report a state change event.
if (ServiceResult.IsGood(error))
{
ReportStateChange(context, false);
}
}
finally
{
// raise the audit event.
if (this.AreEventsMonitored)
{
AuditConditionShelvingEventState e = new AuditConditionShelvingEventState(null);
TranslationInfo info = new TranslationInfo(
"AuditConditionUnshelve",
"en-US",
"The Unshelve method was called.");
e.Initialize(
context,
this,
EventSeverity.Low,
new LocalizedText(info),
ServiceResult.IsGood(error),
DateTime.UtcNow);
e.SourceName.Value = "Attribute/Call";
e.MethodId = new PropertyState<NodeId>(e);
e.MethodId.Value = method.NodeId;
ReportEvent(context, e);
}
}
return error;
}
示例8: OnCreateController
/// <summary>
/// Creates a new controller file.
/// </summary>
private ServiceResult OnCreateController(
ISystemContext context,
MethodState method,
NodeId objectId,
string name,
ref NodeId nodeId)
{
nodeId = null;
// get the system to use.
FileSystemMonitor system = context.SystemHandle as FileSystemMonitor;
if (system == null)
{
return StatusCodes.BadOutOfService;
}
// get the current dierctory.
DirectoryInfo directory = GetDirectory(context, this.NodeId);
if (directory == null || !directory.Exists)
{
return StatusCodes.BadOutOfService;
}
// build the file path.
StringBuilder filePath = new StringBuilder();
filePath.Append(directory.FullName);
filePath.Append('\\');
filePath.Append(name);
filePath.Append(".csv");
if (File.Exists(filePath.ToString()))
{
return StatusCodes.BadNodeIdExists;
}
// write a dummy configuration file.
try
{
using (StreamWriter writer = new StreamWriter(filePath.ToString()))
{
writer.WriteLine("Temperature, Double, 15");
writer.WriteLine("TemperatureSetPoint, Double, 15");
}
}
catch (Exception e)
{
return new ServiceResult(e, StatusCodes.BadUnexpectedError);
}
// return the node id.
nodeId = system.CreateNodeIdFromFilePath(ObjectTypes.ControllerType, filePath.ToString());
return ServiceResult.Good;
}
示例9: Call
/// <summary>
/// Calls a method on an object.
/// </summary>
protected virtual ServiceResult Call(
ISystemContext context,
CallMethodRequest methodToCall,
MethodState method,
CallMethodResult result)
{
ServerSystemContext systemContext = context as ServerSystemContext;
List<ServiceResult> argumentErrors = new List<ServiceResult>();
VariantCollection outputArguments = new VariantCollection();
ServiceResult error = method.Call(
context,
methodToCall.ObjectId,
methodToCall.InputArguments,
argumentErrors,
outputArguments);
if (ServiceResult.IsBad(error))
{
return error;
}
// check for argument errors.
bool argumentsValid = true;
for (int jj = 0; jj < argumentErrors.Count; jj++)
{
ServiceResult argumentError = argumentErrors[jj];
if (argumentError != null)
{
result.InputArgumentResults.Add(argumentError.StatusCode);
if (ServiceResult.IsBad(argumentError))
{
argumentsValid = false;
}
}
else
{
result.InputArgumentResults.Add(StatusCodes.Good);
}
// only fill in diagnostic info if it is requested.
if (systemContext.OperationContext != null)
{
if ((systemContext.OperationContext.DiagnosticsMask & DiagnosticsMasks.OperationAll) != 0)
{
if (ServiceResult.IsBad(argumentError))
{
argumentsValid = false;
result.InputArgumentDiagnosticInfos.Add(new DiagnosticInfo(argumentError, systemContext.OperationContext.DiagnosticsMask, false, systemContext.OperationContext.StringTable));
}
else
{
result.InputArgumentDiagnosticInfos.Add(null);
}
}
}
}
// check for validation errors.
if (!argumentsValid)
{
result.StatusCode = StatusCodes.BadInvalidArgument;
return result.StatusCode;
}
// do not return diagnostics if there are no errors.
result.InputArgumentDiagnosticInfos.Clear();
// return output arguments.
result.OutputArguments = outputArguments;
return ServiceResult.Good;
}
示例10: 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;
}
示例11: FindChild
//.........这里部分代码省略.........
}
}
}
instance = LockState;
break;
}
case DsatsDemo.BrowseNames.LockStateAsString:
{
if (createOrReplace)
{
if (LockStateAsString == null)
{
if (replacement == null)
{
LockStateAsString = new PropertyState<string>(this);
}
else
{
LockStateAsString = (PropertyState<string>)replacement;
}
}
}
instance = LockStateAsString;
break;
}
case DsatsDemo.BrowseNames.Request:
{
if (createOrReplace)
{
if (Request == null)
{
if (replacement == null)
{
Request = new MethodState(this);
}
else
{
Request = (MethodState)replacement;
}
}
}
instance = Request;
break;
}
case DsatsDemo.BrowseNames.Release:
{
if (createOrReplace)
{
if (Release == null)
{
if (replacement == null)
{
Release = new MethodState(this);
}
else
{
Release = (MethodState)replacement;
}
}
}
instance = Release;
break;
}
case DsatsDemo.BrowseNames.Approve:
{
if (createOrReplace)
{
if (Approve == null)
{
if (replacement == null)
{
Approve = new MethodState(this);
}
else
{
Approve = (MethodState)replacement;
}
}
}
instance = Approve;
break;
}
}
if (instance != null)
{
return instance;
}
return base.FindChild(context, browseName, createOrReplace, replacement);
}
示例12: OnConfirmCalled
/// <summary>
/// Called when the Confirm method is called.
/// </summary>
/// <param name="context">The system context.</param>
/// <param name="method">The method being called.</param>
/// <param name="objectId">The id of the object.</param>
/// <param name="eventId">The identifier for the event which is the target for the comment.</param>
/// <param name="comment">The comment.</param>
/// <returns>Any error.</returns>
protected virtual ServiceResult OnConfirmCalled(
ISystemContext context,
MethodState method,
NodeId objectId,
byte[] eventId,
LocalizedText comment)
{
ServiceResult error = ProcessBeforeConfirm(context, eventId, comment);
if (ServiceResult.IsGood(error))
{
SetConfirmedState(context, true);
SetComment(context, comment, GetCurrentUserId(context));
}
if (this.AreEventsMonitored)
{
// report a state change event.
if (ServiceResult.IsGood(error))
{
ReportStateChange(context, false);
}
// raise the audit event.
AuditConditionConfirmEventState e = new AuditConditionConfirmEventState(null);
TranslationInfo info = new TranslationInfo(
"AuditConditionConfirm",
"en-US",
"The Confirm method was called.");
e.Initialize(
context,
this,
EventSeverity.Low,
new LocalizedText(info),
ServiceResult.IsGood(error),
DateTime.UtcNow);
e.SourceName.Value = "Attribute/Call";
e.MethodId = new PropertyState<NodeId>(e);
e.MethodId.Value = method.NodeId;
e.InputArguments = new PropertyState<object[]>(e);
e.InputArguments.Value = new object[] { eventId, comment };
ReportEvent(context, e);
}
return error;
}
开发者ID:yuriik83,项目名称:UA-.UWP-Universal-Windows-Platform,代码行数:61,代码来源:AcknowledgeableConditionState.cs
示例13: CreateAuditEvent
/// <summary>
/// Creates an instance of an audit event.
/// </summary>
protected override AuditUpdateStateEventState CreateAuditEvent(
ISystemContext context,
MethodState causeMethod,
uint causeId)
{
return new ProgramTransitionAuditEventState(null);
}
示例14: ValidateNode
//.........这里部分代码省略.........
break;
}
case NodeClass.VariableType:
{
BaseVariableTypeState value = new BaseDataVariableTypeState();
value.IsAbstract = ((IVariableType)node).IsAbstract;
value.Value = m_mapper.ToLocalValue(((IVariableType)node).Value);
value.DataType = m_mapper.ToLocalId(((IVariableType)node).DataType);
value.ValueRank = ((IVariableType)node).ValueRank;
value.ArrayDimensions = new ReadOnlyList<uint>(((IVariableType)node).ArrayDimensions);
target = value;
break;
}
case NodeClass.DataType:
{
DataTypeState value = new DataTypeState();
value.IsAbstract = ((IDataType)node).IsAbstract;
target = value;
break;
}
case NodeClass.ReferenceType:
{
ReferenceTypeState value = new ReferenceTypeState();
value.IsAbstract = ((IReferenceType)node).IsAbstract;
value.InverseName = ((IReferenceType)node).InverseName;
value.Symmetric = ((IReferenceType)node).Symmetric;
target = value;
break;
}
case NodeClass.Object:
{
BaseObjectState value = new BaseObjectState(null);
value.EventNotifier = ((IObject)node).EventNotifier;
target = value;
break;
}
case NodeClass.Variable:
{
BaseDataVariableState value = new BaseDataVariableState(null);
value.Value = m_mapper.ToLocalValue(((IVariable)node).Value);
value.DataType = m_mapper.ToLocalId(((IVariable)node).DataType);
value.ValueRank = ((IVariable)node).ValueRank;
value.ArrayDimensions = new ReadOnlyList<uint>(((IVariable)node).ArrayDimensions);
value.AccessLevel = ((IVariable)node).AccessLevel;
value.UserAccessLevel = ((IVariable)node).UserAccessLevel;
value.Historizing = ((IVariable)node).Historizing;
value.MinimumSamplingInterval = ((IVariable)node).MinimumSamplingInterval;
target = value;
break;
}
case NodeClass.Method:
{
MethodState value = new MethodState(null);
value.Executable = ((IMethod)node).Executable;
value.UserExecutable = ((IMethod)node).UserExecutable;
target = value;
break;
}
case NodeClass.View:
{
ViewState value = new ViewState();
value.ContainsNoLoops = ((IView)node).ContainsNoLoops;
target = value;
break;
}
}
target.NodeId = handle.NodeId;
target.BrowseName = m_mapper.ToLocalName(node.BrowseName);
target.DisplayName = node.DisplayName;
target.Description = node.Description;
target.WriteMask = node.WriteMask;
target.UserWriteMask = node.UserWriteMask;
target.Handle = node;
target.OnCreateBrowser = OnCreateBrowser;
}
// ignore errors.
catch
{
return null;
}
// put root into operation cache.
if (cache != null)
{
cache[handle.NodeId] = target;
}
handle.Node = target;
handle.Validated = true;
return handle.Node;
}
示例15: DoCause
/// <summary>
/// Invokes the specified cause.
/// </summary>
public virtual ServiceResult DoCause(
ISystemContext context,
MethodState causeMethod,
uint causeId,
IList<object> inputArguments,
IList<object> outputArguments)
{
ServiceResult result = null;
try
{
// get the transition.
uint transitionId = GetTransitionForCause(context, causeId);
if (transitionId == 0)
{
return StatusCodes.BadNotSupported;
}
// check access rights.
result = InvokeCallback(
OnCheckUserPermission,
context,
this,
transitionId,
causeId,
inputArguments,
outputArguments);
if (ServiceResult.IsBad(result))
{
return result;
}
// do the transition.
result = DoTransition(context, transitionId, causeId, inputArguments, outputArguments);
if (ServiceResult.IsBad(result))
{
return result;
}
// report any changes to state machine.
ClearChangeMasks(context, true);
}
finally
{
// report the event.
if (this.AreEventsMonitored)
{
AuditUpdateStateEventState e = CreateAuditEvent(context, causeMethod, causeId);
UpdateAuditEvent(context, causeMethod, causeId, e, result);
ReportEvent(context, e);
}
}
return result;
}