Example for file transfer|OPC UA Standard|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Example for file transfer
Avatar
Xavier POISSON
Member
Members
Forum Posts: 8
Member Since:
05/07/2020
sp_UserOfflineSmall Offline
1
01/28/2022 - 03:58
sp_Permalink sp_Print

Hello,

I Know the File ObjectType and the FileTransfer ObjectType defined in Part 5 but I would like to have an example server (CreateAddressSpace) to perform a file transfer between the OPC Server and a client and vice versa.

thanks in advance

Avatar
Randy Armstrong
Admin
Forum Posts: 1564
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
01/28/2022 - 06:16
sp_Permalink sp_Print

You can try posting on GitHub:

https://github.com/OPCFoundati.....rd-Samples

Avatar
Xavier POISSON
Member
Members
Forum Posts: 8
Member Since:
05/07/2020
sp_UserOfflineSmall Offline
3
01/28/2022 - 06:46
sp_Permalink sp_Print

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.
 
Avatar
Randy Armstrong
Admin
Forum Posts: 1564
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
4
01/28/2022 - 12:45
sp_Permalink sp_Print

You need to add callbacks for all of the methods.

By default the methods do nothing.

Avatar
Xavier POISSON
Member
Members
Forum Posts: 8
Member Since:
05/07/2020
sp_UserOfflineSmall Offline
5
01/30/2022 - 23:13
sp_Permalink sp_Print

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;
}

 

 
Avatar
Randy Armstrong
Admin
Forum Posts: 1564
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
6
01/31/2022 - 02:24
sp_Permalink sp_Print

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).

Avatar
Xavier POISSON
Member
Members
Forum Posts: 8
Member Since:
05/07/2020
sp_UserOfflineSmall Offline
7
01/31/2022 - 02:52
sp_Permalink sp_Print

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
Avatar
Randy Armstrong
Admin
Forum Posts: 1564
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
8
01/31/2022 - 04:00
sp_Permalink sp_Print

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.

Avatar
Xavier POISSON
Member
Members
Forum Posts: 8
Member Since:
05/07/2020
sp_UserOfflineSmall Offline
9
01/31/2022 - 05:53
sp_Permalink sp_Print sp_EditHistory
It doesn't tell me how to retrieve the file from a client via an OPC object
Avatar
Randy Armstrong
Admin
Forum Posts: 1564
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
10
01/31/2022 - 06:55
sp_Permalink sp_Print sp_EditHistory

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.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 34
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1435
Posts: 4855