简体   繁体   English

有没有办法在 Ignition 中生成窗口和/或组件?

[英]Is there a way to generate windows and/or components in Ignition?

I was hoping that Ignition had a way to import/export windows to a non-binary format such as JSON or XML, but that seems not to be the case (or is there a way?).我希望 Ignition 有办法将窗口导入/导出为非二进制格式,例如 JSON 或 XML,但情况似乎并非如此(或者有办法吗?)。

Is there a way to use the script console to generate and populate a new window, or to insert components into an existing window?有没有办法使用脚本控制台生成和填充新窗口,或者将组件插入现有窗口?

This would be used for inserting templates and other components, such as navigation buttons etc.这将用于插入模板和其他组件,例如导航按钮等。

Yes, but...对,但是...

I assume here that you're referring to Vision windows.我在这里假设您指的是 Vision 窗口。 The windows are indeed binary serialized, but the underlying structure is XML.窗口确实是二进制序列化的,但底层结构是 XML。 But getting the deserialization done programmatically is a pain and probably not worth it.但是以编程方式完成反序列化是一件痛苦的事情,可能不值得。

You can get a feel for what this looks like by opening a Vision window in the designer, right-clicking its Root Container and choosing Copy, then pasting it into Notepad.您可以通过在设计器中打开 Vision 窗口,右键单击其 Root Container 并选择 Copy,然后将其粘贴到记事本中来感受一下它的外观。 I myself tried to find a way to do this from a module and decided it wasn't worth it.我自己试图从一个模块中找到一种方法来做到这一点,但我认为这不值得。 For more detail, you can view that thread in the Ignition forum here .有关更多详细信息,您可以在此处的 Ignition 论坛中查看该主题。

However, that's not really useful for generating and populating a new window.但是,这对于生成和填充新窗口并不是很有用。

To do that, you need to do some Java programming.为此,您需要进行一些 Java 编程。 Vision is Java Swing under the hood. Vision 是底层的 Java Swing。 There are a couple ways you can dynamically build / populate a Window.有几种方法可以动态构建/填充窗口。

  1. From Python, you can import any Java libraries you need and generate the window dynamically.从 Python 中,您可以导入任何需要的 Java 库并动态生成窗口。 For relatively simple things, you're probably better off working with the Template Canvas component.对于相对简单的事情,您最好使用 Template Canvas 组件。 There's an Ignition forum thread discussing this topic here . 此处有一个讨论此主题的 Ignition 论坛线程。 This would be more of a run-time generation, not from the Script Console.这更像是运行时生成,而不是来自脚本控制台。
  2. You can write your own module to do it.您可以编写自己的模块来完成它。

Module SDK Vision Component Guide Module SDK 视觉组件指南

Vision Component Module Example 视觉组件模块示例

Good luck!祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM