48 lines
902 B
Go
48 lines
902 B
Go
package test
|
|
|
|
import (
|
|
"plcopenxmlbuilder/facades"
|
|
"schema"
|
|
"testing"
|
|
)
|
|
|
|
func TestCreatePLCOpenXML(t *testing.T) {
|
|
builder, err := facades.NewBuilder("twincat3", facades.PLC)
|
|
if err != nil {
|
|
t.Log(err)
|
|
}
|
|
|
|
proj := schema.Project{
|
|
ProjectName: "CH_BE_STEFFISBURG_SCHOENAU_SPORTANLAGE_TA03",
|
|
Information: schema.Information{
|
|
CompanyName: "Buehler & Scherler",
|
|
ProductName: "PLCopenXML Builder",
|
|
Version: "0.0.1",
|
|
},
|
|
Devices: []*schema.Device{{
|
|
Name: "SPS001",
|
|
Tasks: []*schema.Task{
|
|
{
|
|
Name: "Main",
|
|
KindOfTask: "Cyclic",
|
|
IntervalUnit: "ms",
|
|
Interval: 100,
|
|
Priority: 10,
|
|
Programs: []*schema.Program{
|
|
{
|
|
Name: "Main",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}},
|
|
}
|
|
|
|
xmlBytes, err := builder.Marshal(&proj)
|
|
if err != nil {
|
|
t.Log(err)
|
|
}
|
|
|
|
t.Log(string(xmlBytes))
|
|
}
|