05/07/2020
Hello
thank you for the answer
I am new to OPC UA
But I already downloaded the examples available on GitHub and I didn't find what I wanted: I want to be able to create an "ObjectTypeIds.FileType" object on the server in my "CreateAddressSpace" method so that a client can send the file to the server.
private FileState CreateFile(NodeState parent, string path, string name)
{
FileState method = new FileState(parent);
method.SymbolicName = name;
method.ReferenceTypeId = ObjectTypeIds.FileType;
method.NodeId = new NodeId(path, NamespaceIndex);
method.BrowseName = new QualifiedName(path, NamespaceIndex);
method.DisplayName = new LocalizedText(“en”, name);
method.WriteMask = AttributeWriteMask.None;
method.UserWriteMask = AttributeWriteMask.None;
if (parent != null)
{
parent.AddChild(method);
}
return method;
}
This method does not work with a nodefolder parent.
05/07/2020
Hello
Here is my code :
public override void CreateAddressSpace(IDictionary<NodeId, IList<IReference>> externalReferences)
{
lock (Lock)
{
// ensure the process object can be found via the server object.
IList<IReference> references = null;
if (!externalReferences.TryGetValue(ObjectIds.ObjectsFolder, out references))
{
externalReferences[ObjectIds.ObjectsFolder] = references = new List<IReference>();
}
NodeStateCollection predefinedNodes = new NodeStateCollection();
FolderState root = CreateFolder(null, “Application”, “Application”);
root.AddReference(ReferenceTypes.Organizes, true, ObjectIds.ObjectsFolder);
references.Add(new NodeStateReference(ReferenceTypes.Organizes, false, root.NodeId));
root.EventNotifier = EventNotifiers.SubscribeToEvents;
AddRootNotifier(root);
#region File
FolderState FileFolder = CreateFolder(root, “File”, “File”);
FileState _OBJ_File = CreateFile(FileFolder, “File_Test.txt”, “File_Test.txt”);
#endregion
AddPredefinedNode(SystemContext, root);
}
}
private FileState CreateFile(NodeState parent, string path, string name)
{
FileState _OBJ_FileOPC = new FileState(parent);
_OBJ_FileOPC.SymbolicName = name;
_OBJ_FileOPC.ReferenceTypeId = ObjectTypeIds.FileType;
_OBJ_FileOPC.NodeId = new NodeId(path, NamespaceIndex);
_OBJ_FileOPC.BrowseName = new QualifiedName(path, NamespaceIndex);
_OBJ_FileOPC.DisplayName = new LocalizedText(“en”, name);
_OBJ_FileOPC.WriteMask = AttributeWriteMask.None;
_OBJ_FileOPC.UserWriteMask = AttributeWriteMask.None;
if (parent != null)
{
parent.AddChild(_OBJ_FileOPC);
}
return _OBJ_FileOPC;
}
05/30/2017
The FileType Object has Methods (Open, Close, etc):
https://reference.opcfoundatio…../FileType/
You need to provide an implementation for these methods.
The OnStart method is an example of a method implementation:
https://github.com/OPCFoundati…..Manager.cs
When using a typed object like FileState there are typed versions of the Methods defined on the class (e.g. Open).
05/07/2020
Hello
Thanks for your respond
I think I'm going in the wrong direction.
I want to be able to transfer a .txt file from my client to my OPC server and be able to process this file on the server (Open/ Read/ Close)
I understood that one must use the methods but I can't find any concrete example on the Web of coding serveur OPC UA
05/30/2017
The OnStart method is an example of a method implementation:
https://github.com/OPCFoundati…..Manager.cs
Copy that design pattern to implement the Open/Close Methods.
05/30/2017
If you want a client example for calling Methods:
https://github.com/OPCFoundati…..ainForm.cs
The meaning of the various methods and parameters can be found here:
https://reference.opcfoundatio…..rt5/C.2.1/
The Methods work like the ANSI C File API function calls.
1 Guest(s)