twincat-如何查看贝克霍夫plc目录的内容
我正在尝试在PLC中执行文件管理。目前,NT_StartProcess的工作原理如下,但是在流程产生后,我将没有任何反馈。有没有办法检查PLC目录的内容?有什么方法可以从NT_StartProcess获得反馈?
// File Locations
sTargetFilePath := 'C:\LocalHistory\test.job';
sTargetDirectory := 'C:\\CustomerDir';
// Build Command String
sCommand := '/C '; // Special command indicating command string input
sCommand := CONCAT(sCommand, 'move '); // Add move command
sCommand := CONCAT(sCommand, sTargetFilePath); // Add target file
sCommand := CONCAT(sCommand, ' '); // Required space for command
sCommand := CONCAT(sCommand, sTargetDirectory); // Add target location
// Output -> ‘/C move C:\NET-DRIVE\NewOrders\Original.xml 'C:\NET-DRIVE\OldOrders’
Process(
NETID := '', // Local System
PATHSTR := 'C:\Windows\System32\cmd.exe', // Path to local cmd executable
COMNDLINE := sCommand, // Comnmand to be executed
ERR => bError, // Error Output
ERRID => iErrorId // Error Id Output
);
// Trigger Command
IF bTrigger THEN
bTrigger := FALSE;
Process(START:=TRUE);
Process(START:=FALSE);
END_IF
I am trying to perform file management within the PLC. Currently, NT_StartProcess works as follows, but I will not have any feedback after the process has been spawned. Is there a way to check the contents of a directory from the PLC? Is there any way to get feedback from NT_StartProcess?
// File Locations
sTargetFilePath := 'C:\LocalHistory\test.job';
sTargetDirectory := 'C:\\CustomerDir';
// Build Command String
sCommand := '/C '; // Special command indicating command string input
sCommand := CONCAT(sCommand, 'move '); // Add move command
sCommand := CONCAT(sCommand, sTargetFilePath); // Add target file
sCommand := CONCAT(sCommand, ' '); // Required space for command
sCommand := CONCAT(sCommand, sTargetDirectory); // Add target location
// Output -> ‘/C move C:\NET-DRIVE\NewOrders\Original.xml 'C:\NET-DRIVE\OldOrders’
Process(
NETID := '', // Local System
PATHSTR := 'C:\Windows\System32\cmd.exe', // Path to local cmd executable
COMNDLINE := sCommand, // Comnmand to be executed
ERR => bError, // Error Output
ERRID => iErrorId // Error Id Output
);
// Trigger Command
IF bTrigger THEN
bTrigger := FALSE;
Process(START:=TRUE);
Process(START:=FALSE);
END_IF
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,有一种方法。您正在寻找的是这两个功能块:,
,,,,您无法直接得到它。我一直在使用两个解决方法:
在您的情况下,这将是这样的:
命令之后
&&
仅在先前的成功时才会执行。||
之后的命令仅在以前失败时才能执行。>
操作员将上一个命令的输出写入文件上面的示例应创建一个文件
out.txt
,并写入或fail
内部。目前,我没有带有Twincat的PLC,但它在Windows CMD中起作用。Yes, there is a way. What you are looking for are those two function blocks: FB_EnumFindFileList, FB_EnumFindFileEntry
As for feedback from NT_StartProcess, you can't get it directly. There are two workaround I've been using:
In your case it would be something like this:
Command after
&&
will be executed only, if previous succeded. Command after||
will be executed only if previous failed.>
operator writes output of previous command to a fileExample above should create a file
out.txt
and writeDONE
orFAIL
inside. I don't have a PLC with TwinCAT with me at the moment, but it works in windows cmd.