本文整理汇总了C#中Opc.Ua.Client.Session类的典型用法代码示例。如果您正苦于以下问题:C# Session类的具体用法?C# Session怎么用?C# Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Session类属于Opc.Ua.Client命名空间,在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateList
/// <summary>
/// Updates the list of references.
/// </summary>
private void UpdateList(Session session, NodeId nodeId)
{
m_nodeId = nodeId;
ReferencesLV.Items.Clear();
List<ReferenceDescription> references = Browse(session, nodeId);
DisplayReferences(session, references);
}
示例2: ShowDialog
/// <summary>
/// Prompts the user to specify the browse options.
/// </summary>
public bool ShowDialog(Session session, MonitoredItem monitoredItem)
{
if (monitoredItem == null) throw new ArgumentNullException("monitoredItem");
DataChangeFilter filter = monitoredItem.Filter as DataChangeFilter;
if (filter == null)
{
filter = new DataChangeFilter();
filter.Trigger = DataChangeTrigger.StatusValue;
filter.DeadbandValue = 0;
filter.DeadbandType = (uint)(int)DeadbandType.None;
}
TriggerCB.SelectedItem = filter.Trigger;
DeadbandTypeCB.SelectedItem = (DeadbandType)(int)filter.DeadbandType;
DeadbandNC.Value = (decimal)filter.DeadbandValue;
if (ShowDialog() != DialogResult.OK)
{
return false;
}
filter.Trigger = (DataChangeTrigger)TriggerCB.SelectedItem;
filter.DeadbandType = Convert.ToUInt32(DeadbandTypeCB.SelectedItem);
filter.DeadbandValue = (double)DeadbandNC.Value;
monitoredItem.Filter = filter;
return true;
}
示例3: TestBase
/// <summary>
/// Initializes the test with session, configuration and logger.
/// </summary>
public TestBase(
string name,
Session session,
ServerTestConfiguration configuration,
ReportMessageEventHandler reportMessage,
ReportProgressEventHandler reportProgress,
TestBase template)
{
m_name = name;
m_session = session;
m_configuration = configuration;
m_reportMessage = reportMessage;
m_reportProgress = reportProgress;
if (template != null && Object.ReferenceEquals(session, template.m_session))
{
m_blockSize = template.BlockSize;
m_availableNodes = template.m_availableNodes;
m_writeableVariables = template.m_writeableVariables;
}
else
{
m_blockSize = 1000;
m_availableNodes = new NodeIdDictionary<Node>();
m_writeableVariables = new List<VariableNode>();
}
}
示例4: Show
public void Show(Session session, NodeId nodeId)
{
m_session = session;
m_nodeId = nodeId;
Show();
}
示例5: AuditEventForm
/// <summary>
/// Initializes a new instance of the <see cref="AuditEventForm"/> class.
/// </summary>
/// <param name="session">The session.</param>
/// <param name="subscription">The subscription.</param>
public AuditEventForm(Session session, Subscription subscription)
{
InitializeComponent();
m_session = session;
m_subscription = subscription;
// a table used to track event types.
m_eventTypeMappings = new Dictionary<NodeId, NodeId>();
// the filter to use.
m_filter = new FilterDefinition();
m_filter.AreaId = ObjectIds.Server;
m_filter.Severity = EventSeverity.Min;
m_filter.IgnoreSuppressedOrShelved = true;
m_filter.EventTypes = new NodeId[] { ObjectTypeIds.AuditUpdateMethodEventType };
// find the fields of interest.
m_filter.SelectClauses = m_filter.ConstructSelectClauses(m_session, ObjectTypeIds.AuditUpdateMethodEventType);
// declate callback.
m_MonitoredItem_Notification = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);
// create a monitored item based on the current filter settings.
m_monitoredItem = m_filter.CreateMonitoredItem(m_session);
// set up callback for notifications.
m_monitoredItem.Notification += m_MonitoredItem_Notification;
m_subscription.AddItem(m_monitoredItem);
m_subscription.ApplyChanges();
}
示例6: Initialize
/// <summary>
/// Sets the nodes in the control.
/// </summary>
public void Initialize(Session session, NodeIdCollection nodeIds, NodeClass nodeClassMask)
{
if (session == null) throw new ArgumentNullException("session");
Clear();
m_session = session;
m_nodeIds = nodeIds;
m_nodeClassMask = (nodeClassMask == 0)?(NodeClass)Byte.MaxValue:nodeClassMask;
if (nodeIds == null)
{
return;
}
foreach (NodeId nodeId in nodeIds)
{
INode node = m_session.NodeCache.Find(nodeId);
if (node != null && (m_nodeClassMask & node.NodeClass) != 0)
{
AddItem(node, "Property", -1);
}
}
AdjustColumns();
}
示例7: ShowDialog
/// <summary>
/// Displays the available areas in a tree view.
/// </summary>
/// <param name="session">The session.</param>
/// <returns></returns>
public NodeId ShowDialog(Session session)
{
m_session = session;
TreeNode root = new TreeNode(BrowseNames.Server);
root.Nodes.Add(new TreeNode());
BrowseTV.Nodes.Add(root);
root.Expand();
// display the dialog.
if (ShowDialog() != DialogResult.OK)
{
return null;
}
// ensure selection is valid.
if (BrowseTV.SelectedNode == null)
{
return null;
}
// get the selection.
ReferenceDescription reference = (ReferenceDescription)BrowseTV.SelectedNode.Tag;
if (reference == null)
{
return ObjectIds.Server;
}
// return the result.
return (NodeId)reference.NodeId;
}
示例8: Browse
public static ReferenceDescriptionCollection Browse(Session session, BrowseDescription nodeToBrowse, bool throwOnError)
{
try
{
var descriptionCollection = new ReferenceDescriptionCollection();
var nodesToBrowse = new BrowseDescriptionCollection { nodeToBrowse };
BrowseResultCollection results;
DiagnosticInfoCollection diagnosticInfos;
session.Browse(null, null, 0U, nodesToBrowse, out results, out diagnosticInfos);
ClientBase.ValidateResponse(results, nodesToBrowse);
ClientBase.ValidateDiagnosticInfos(diagnosticInfos, nodesToBrowse);
while (!StatusCode.IsBad(results[0].StatusCode))
{
for (var index = 0; index < results[0].References.Count; ++index)
descriptionCollection.Add(results[0].References[index]);
if (results[0].References.Count == 0 || results[0].ContinuationPoint == null)
return descriptionCollection;
var continuationPoints = new ByteStringCollection();
continuationPoints.Add(results[0].ContinuationPoint);
session.BrowseNext(null, false, continuationPoints, out results, out diagnosticInfos);
ClientBase.ValidateResponse(results, continuationPoints);
ClientBase.ValidateDiagnosticInfos(diagnosticInfos, continuationPoints);
}
throw new ServiceResultException(results[0].StatusCode);
}
catch (Exception ex)
{
if (throwOnError)
throw new ServiceResultException(ex, 2147549184U);
return null;
}
}
示例9: ShowDialog
/// <summary>
/// Prompts the user to edit a value.
/// </summary>
public Variant ShowDialog(Session session, NodeId nodeId)
{
m_session = session;
m_nodeId = nodeId;
#region Task #B2 - Write Value
// generate a default value based on the data type.
m_value = Variant.Null;
m_sourceType = GetExpectedType(session, nodeId);
if (m_sourceType != null)
{
m_value = new Variant(TypeInfo.GetDefaultValue(m_sourceType.BuiltInType), m_sourceType);
}
// cast the value to a string.
ValueTB.Text = (string)TypeInfo.Cast(m_value.Value, m_value.TypeInfo, BuiltInType.String);
#endregion
if (ShowDialog() != DialogResult.OK)
{
return Variant.Null;
}
return m_value;
}
示例10: Show
/// <summary>
/// Displays the dialog.
/// </summary>
public void Show(Session session, NodeId objectId, NodeId methodId)
{
if (session == null) throw new ArgumentNullException("session");
if (methodId == null) throw new ArgumentNullException("methodId");
if (m_session != null)
{
m_session.SessionClosing -= m_SessionClosing;
}
m_session = session;
m_session.SessionClosing += m_SessionClosing;
m_objectId = objectId;
m_methodId = methodId;
InputArgumentsCTRL.Update(session, methodId, true);
OutputArgumentsCTRL.Update(session, methodId, false);
Node target = session.NodeCache.Find(objectId) as Node;
Node method = session.NodeCache.Find(methodId) as Node;
if (target != null && method != null)
{
Text = String.Format("Call {0}.{1}", target, method);
}
Show();
BringToFront();
}
示例11: ShowDialog
/// <summary>
/// Prompts the user to specify the browse options.
/// </summary>
public bool ShowDialog(Session session, ReadValueId valueId)
{
if (session == null) throw new ArgumentNullException("session");
if (valueId == null) throw new ArgumentNullException("valueId");
NodeIdCTRL.Browser = new Browser(session);
INode node = session.NodeCache.Find(valueId.NodeId);
if (node != null)
{
DisplayNameTB.Text = node.ToString();
}
NodeIdCTRL.Identifier = valueId.NodeId;
AttributeIdCB.SelectedItem = Attributes.GetBrowseName(valueId.AttributeId);
IndexRangeTB.Text = valueId.IndexRange;
EncodingCB.Text = (valueId.DataEncoding != null)?valueId.DataEncoding.Name:null;
if (ShowDialog() != DialogResult.OK)
{
return false;
}
valueId.NodeId = NodeIdCTRL.Identifier;
valueId.AttributeId = Attributes.GetIdentifier((string)AttributeIdCB.SelectedItem);
valueId.IndexRange = IndexRangeTB.Text;
if (String.IsNullOrEmpty(EncodingCB.Text))
{
valueId.DataEncoding = new QualifiedName(EncodingCB.Text);
}
return true;
}
示例12: UpdateList
/// <summary>
/// Updates the list control.
/// </summary>
private void UpdateList(Session session, Argument[] arguments, string browseName)
{
for (int ii = 0; ii < arguments.Length; ii++)
{
Argument argument = arguments[ii];
Variant defaultValue = new Variant(TypeInfo.GetDefaultValue(argument.DataType, argument.ValueRank));
ListViewItem item = new ListViewItem(arguments[ii].Name);
if (browseName == BrowseNames.InputArguments)
{
item.SubItems.Add("IN");
m_firstOutputArgument++;
}
else
{
item.SubItems.Add("OUT");
}
string dataType = session.NodeCache.GetDisplayText(arguments[ii].DataType);
if (arguments[ii].ValueRank >= 0)
{
dataType += "[]";
}
item.SubItems.Add(defaultValue.ToString());
item.SubItems.Add(dataType);
item.SubItems.Add(Utils.Format("{0}", arguments[ii].Description));
item.Tag = defaultValue;
ArgumentsLV.Items.Add(item);
}
}
示例13: New
/// <summary>
/// Creates a new subscription.
/// </summary>
public Subscription New(Session session)
{
if (session == null) throw new ArgumentNullException("session");
Subscription subscription = new Subscription(session.DefaultSubscription);
if (!new SubscriptionEditDlg().ShowDialog(subscription))
{
return null;
}
session.AddSubscription(subscription);
subscription.Create();
Subscription duplicateSubscription = session.Subscriptions.FirstOrDefault(s => s.Id != 0 && s.Id.Equals(subscription.Id) && s != subscription);
if (duplicateSubscription != null)
{
Utils.Trace("Duplicate subscription was created with the id: {0}", duplicateSubscription.Id);
DialogResult result = MessageBox.Show("Duplicate subscription was created with the id: " + duplicateSubscription.Id + ". Do you want to keep it?", "Warning", MessageBoxButtons.YesNo);
if (result == System.Windows.Forms.DialogResult.No)
{
duplicateSubscription.Delete(false);
session.RemoveSubscription(subscription);
return null;
}
}
Show(subscription);
return subscription;
}
示例14: ShowDialog
/// <summary>
/// Prompts the user to specify the browse options.
/// </summary>
public bool ShowDialog(Session session, WriteValue value)
{
if (session == null) throw new ArgumentNullException("session");
if (value == null) throw new ArgumentNullException("value");
NodeIdCTRL.Browser = new Browser(session);
INode node = session.NodeCache.Find(value.NodeId);
if (node != null)
{
DisplayNameTB.Text = node.ToString();
}
NodeIdCTRL.Identifier = value.NodeId;
AttributeIdCB.SelectedItem = Attributes.GetBrowseName(value.AttributeId);
IndexRangeTB.Text = value.IndexRange;
if (ShowDialog() != DialogResult.OK)
{
return false;
}
value.NodeId = NodeIdCTRL.Identifier;
value.AttributeId = Attributes.GetIdentifier((string)AttributeIdCB.SelectedItem);
value.IndexRange = IndexRangeTB.Text;
return true;
}
示例15: Initialize
/// <summary>
/// Sets the nodes in the control.
/// </summary>
public void Initialize(Session session, ExpandedNodeId nodeId)
{
if (session == null) throw new ArgumentNullException("session");
Clear();
if (nodeId == null)
{
return;
}
m_session = session;
m_nodeId = (NodeId)nodeId;
INode node = m_session.NodeCache.Find(m_nodeId);
if (node != null && (node.NodeClass & (NodeClass.Variable | NodeClass.Object)) != 0)
{
AddReferences(ReferenceTypeIds.HasTypeDefinition, BrowseDirection.Forward);
AddReferences(ReferenceTypeIds.HasModellingRule, BrowseDirection.Forward);
}
AddAttributes();
AddProperties();
}