{"id":36837642,"url":"https://github.com/suifei/plcopen-go","last_synced_at":"2026-01-12T14:25:24.235Z","repository":{"id":296507490,"uuid":"993614555","full_name":"suifei/plcopen-go","owner":"suifei","description":"A comprehensive Go library for handling IEC 61131-3 PLCopen XML format with complete structure definitions generated from XSD schema. Supports both XML and JSON serialization for industrial automation projects.","archived":false,"fork":false,"pushed_at":"2025-05-31T07:10:04.000Z","size":513,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-02T23:49:46.057Z","etag":null,"topics":["automation","control-systems","function-block-diagrams","go-library","iec-61131-3","industrial-automation","json-serialization","ladder-diagram","manufacturing","plc-programming","plcopen","structured-text","xml-parser","xml-schema","xsd-validation"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/suifei.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-31T06:13:09.000Z","updated_at":"2025-06-20T05:58:52.000Z","dependencies_parsed_at":"2025-05-31T18:25:31.002Z","dependency_job_id":null,"html_url":"https://github.com/suifei/plcopen-go","commit_stats":null,"previous_names":["suifei/plcopen-go"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/suifei/plcopen-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suifei%2Fplcopen-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suifei%2Fplcopen-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suifei%2Fplcopen-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suifei%2Fplcopen-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/suifei","download_url":"https://codeload.github.com/suifei/plcopen-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suifei%2Fplcopen-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28340395,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T12:22:26.515Z","status":"ssl_error","status_checked_at":"2026-01-12T12:22:10.856Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","control-systems","function-block-diagrams","go-library","iec-61131-3","industrial-automation","json-serialization","ladder-diagram","manufacturing","plc-programming","plcopen","structured-text","xml-parser","xml-schema","xsd-validation"],"created_at":"2026-01-12T14:25:22.232Z","updated_at":"2026-01-12T14:25:24.223Z","avatar_url":"https://github.com/suifei.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PLCopen-Go\n\n一个用于处理 IEC 61131-3 PLCopen XML 格式的 Go 库，支持从 XSD 模式生成的完整结构体定义。\n\n[![Go Version](https://img.shields.io/badge/go-1.22.3+-blue.svg)](https://golang.org/dl/)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)\n[![Go Report Card](https://goreportcard.com/badge/github.com/suifei/plcopen-go)](https://goreportcard.com/report/github.com/suifei/plcopen-go)\n[![Changelog](https://img.shields.io/badge/changelog-available-green.svg)](CHANGELOG.md)\n\n## 功能特性\n\n- 🔧 完整的 PLCopen XML TC6 V1.0B 标准支持\n- 📝 从 XSD 模式自动生成的 Go 结构体\n- ✅ XML 模式验证支持\n- 🛠️ 丰富的工具函数和实用程序\n- 📊 全面的测试覆盖率\n- 🌐 支持多种编程语言（ST、FBD、LD 等）\n- 🔄 支持 XML 和 JSON 双重序列化格式\n\n## 安装\n\n```bash\ngo get github.com/suifei/plcopen-go\n```\n\n## 快速开始\n\n### 创建 PLCopen 项目\n\n```go\npackage main\n\nimport (\n    \"encoding/xml\"\n    \"fmt\"\n    \"time\"\n    \n    \"github.com/suifei/plcopen-go\"\n)\n\nfunc main() {\n    // 创建项目\n    project := \u0026plcopen.Project{\n        FileHeader: \u0026plcopen.ProjectFileHeader{\n            CompanyName:        \"Your Company\",\n            ProductName:        \"Your Product\",\n            ProductVersion:     \"1.0\",\n            ContentDescription: \"PLCopen XML project\",\n            CreationDateTime:   time.Now(),\n        },\n        ContentHeader: \u0026plcopen.ProjectContentHeader{\n            Name:         \"MyProject\",\n            Version:      \"1.0\",\n            Organization: \"Your Organization\",\n            Author:       \"Your Name\",\n            Language:     \"en\",\n        },\n    }\n    \n    // 序列化为 XML\n    xmlData, err := xml.MarshalIndent(project, \"\", \"  \")\n    if err != nil {\n        panic(err)\n    }\n    \n    fmt.Println(string(xmlData))\n}\n```\n\n### 解析 PLCopen XML 文件\n\n```go\npackage main\n\nimport (\n    \"encoding/xml\"\n    \n    \"github.com/suifei/plcopen-go\"\n    \"github.com/suifei/plcopen-go/utils\"\n)\n\nfunc main() {\n    // 读取 XML 文件\n    xmlContent, err := utils.ReadFile(\"project.xml\")\n    if err != nil {\n        panic(err)\n    }\n    \n    // 解析 XML\n    var project plcopen.Project\n    err = xml.Unmarshal([]byte(xmlContent), \u0026project)\n    if err != nil {\n        panic(err)\n    }\n    \n    // 访问项目信息\n    fmt.Printf(\"项目名称: %s\\n\", project.ContentHeader.Name)\n    fmt.Printf(\"公司名称: %s\\n\", project.FileHeader.CompanyName)\n}\n```\n\n### JSON 序列化支持\n\n```go\npackage main\n\nimport (\n    \"encoding/json\"\n    \"fmt\"\n    \"time\"\n    \n    \"github.com/suifei/plcopen-go\"\n)\n\nfunc main() {\n    // 创建项目\n    project := \u0026plcopen.Project{\n        FileHeader: \u0026plcopen.ProjectFileHeader{\n            CompanyName:        \"Your Company\",\n            ProductName:        \"Your Product\",\n            ProductVersion:     \"1.0\",\n            ContentDescription: \"PLCopen JSON project\",\n            CreationDateTime:   time.Now(),\n        },\n        ContentHeader: \u0026plcopen.ProjectContentHeader{\n            Name:         \"MyProject\",\n            Version:      \"1.0\",\n            Organization: \"Your Organization\",\n            Author:       \"Your Name\",\n            Language:     \"en\",\n        },\n    }\n    \n    // 序列化为 JSON\n    jsonData, err := json.MarshalIndent(project, \"\", \"  \")\n    if err != nil {\n        panic(err)\n    }\n    \n    fmt.Println(string(jsonData))\n    \n    // 从 JSON 反序列化\n    var newProject plcopen.Project\n    err = json.Unmarshal(jsonData, \u0026newProject)\n    if err != nil {\n        panic(err)\n    }\n    \n    fmt.Printf(\"反序列化后的项目名称: %s\\n\", newProject.ContentHeader.Name)\n}\n```\n\n## 项目结构\n\n```\nplcopen-go/\n├── tc6_xml_v10_b.go        # 主要的结构体定义\n├── utils/                   # 工具函数\n│   ├── file_utils.go       # 文件操作工具\n│   ├── marshal.go          # 序列化工具\n│   └── validate_types_coverage.go\n├── tests/                   # 测试文件\n│   ├── tc6_xml_v10_b_test.go\n│   ├── xml_validator_test.go\n│   └── ...\n├── docs/                    # 文档和 XSD 文件\n│   ├── TC6_XML_V10_B.xsd\n│   └── TC6_XML_V101.pdf\n└── go.mod\n```\n\n## 支持的 PLCopen 元素\n\n### 项目结构\n- [`Project`](tc6_xml_v10_b.go) - 根项目元素\n- [`ProjectFileHeader`](tc6_xml_v10_b.go) - 文件头信息\n- [`ProjectContentHeader`](tc6_xml_v10_b.go) - 内容头信息\n- [`ProjectTypes`](tc6_xml_v10_b.go) - 类型定义\n- [`ProjectInstances`](tc6_xml_v10_b.go) - 实例配置\n\n### 编程语言支持\n- ST (Structured Text) - 结构化文本\n- FBD (Function Block Diagram) - 功能块图\n- LD (Ladder Diagram) - 梯形图\n- IL (Instruction List) - 指令表\n- SFC (Sequential Function Chart) - 顺序功能图\n\n### 数据类型\n- 基本数据类型 (BOOL, INT, REAL 等)\n- 用户定义的数据类型\n- 数组和结构体\n- 枚举类型\n\n## 工具函数\n\n### 文件操作\n\n```go\nimport \"github.com/suifei/plcopen-go/utils\"\n\n// 读取文件\ncontent, err := utils.ReadFile(\"project.xml\")\n\n// 写入文件\nerr = utils.WriteFile(\"output.xml\", xmlContent)\n\n// 检查文件是否存在\nexists := utils.FileExists(\"project.xml\")\n\n// 读取文件行\nlines, err := utils.ReadFileLines(\"config.txt\")\n```\n\n## 测试\n\n运行所有测试：\n\n```bash\ngo test ./...\n```\n\n运行特定测试：\n\n```bash\ngo test ./tests -v\n```\n\n运行 XML 验证测试：\n\n```bash\ngo test ./tests -run TestXMLSchemaValidation -v\n```\n\n## 验证\n\n该库包含全面的 XML 模式验证功能，确保生成的 XML 符合 PLCopen 标准：\n\n- XML 格式验证\n- 命名空间验证\n- 结构完整性验证\n- 类型覆盖率测试\n\n详见 [`xml_validator_test.go`](tests/xml_validator_test.go) 中的验证测试。\n\n## 示例\n\n查看 [`tests`](tests/) 目录中的各种示例：\n\n- [`tc6_xml_v10_b_test.go`](tests/tc6_xml_v10_b_test.go) - 基本项目创建和序列化\n- [`xml_validator_test.go`](tests/xml_validator_test.go) - XML 验证示例\n- [`data_types_test.go`](tests/data_types_test.go) - 数据类型使用示例\n\n## API 文档\n\n完整的 API 文档请访问：[GoDoc](https://godoc.org/github.com/suifei/plcopen-go)\n\n## 贡献\n\n欢迎贡献代码！请遵循以下步骤：\n\n1. Fork 本项目\n2. 创建功能分支 (`git checkout -b feature/amazing-feature`)\n3. 提交更改 (`git commit -m 'Add some amazing feature'`)\n4. 推送到分支 (`git push origin feature/amazing-feature`)\n5. 创建 Pull Request\n\n## 许可证\n\n本项目采用 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件。\n\n## 相关资源\n\n- [PLCopen 官方网站](https://www.plcopen.org/)\n- [IEC 61131-3 标准](https://en.wikipedia.org/wiki/IEC_61131-3)\n- [PLCopen XML 规范](https://www.plcopen.org/technical-activities/xml-exchange-format)\n\n## 版本历史\n\n查看项目的详细更新历史和版本说明，请参考：[CHANGELOG.md](CHANGELOG.md)\n\n## 致谢\n\n感谢 PLCopen 组织提供的 XML 交换格式标准，使得工业自动化项目之间的互操作性成为可能。\n\n---\n\n如果您觉得这个项目有用，请给它一个 ⭐！","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuifei%2Fplcopen-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuifei%2Fplcopen-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuifei%2Fplcopen-go/lists"}