Skip to content

Commit

Permalink
Prepare for bulk write on Plc4x-client.
Browse files Browse the repository at this point in the history
  • Loading branch information
riclolsen committed Jun 30, 2024
1 parent 2bbe1aa commit 510ab4f
Show file tree
Hide file tree
Showing 3 changed files with 202 additions and 77 deletions.
6 changes: 2 additions & 4 deletions src/plc4x-client/autotag.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,12 @@ func (pc *protocolConnection) AutoCreateTag(rtData *RtDataTag, rtDataCollection
rtData.Id = float64(pc.AutoKeyId)
rtData.Description = rtData.Tag
rtData.UngroupedDescription = rtData.ProtocolSourceObjectAddress
rtData.Type = "analog" // default type
rtData.EventTextFalse = "OFF"
rtData.EventTextTrue = "ON"
rtData.StateTextFalse = "OFF"
rtData.StateTextTrue = "ON"
rtData.Origin = "supervised"
rtData.Unit = "" // default unit
rtData.Unit = ""
rtDataCollection.InsertOne(context.TODO(), rtData)
_ListCreatedTags[rtData.Tag] = "analog"
return
_ListCreatedTags[rtData.Tag] = rtData.Type
}
11 changes: 6 additions & 5 deletions src/plc4x-client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ import (
"go.mongodb.org/mongo-driver/mongo/options"
)

var logLevel = 1

const (
logLevelMin = 0
logLevelBasic = 1
Expand All @@ -48,6 +46,8 @@ const (
//const udpChannelSize = 1000
//const udpReadBufferPackets = 100

var logLevel = logLevelBasic

type configData struct {
NodeName string `json:"nodeName"`
MongoConnectionString string `json:"mongoConnectionString"`
Expand Down Expand Up @@ -121,9 +121,10 @@ func checkFatalError(err error) {
}
}

func readConfigFile() (cfg configData, instanceNumber int, logLevel int) {
func readConfigFile() (cfg configData, instanceNumber int, instLogLevel int) {
var err error
instanceNumber = 1
instLogLevel = logLevelBasic
if os.Getenv("JS_"+DriverName+"_INSTANCE") != "" {
i, err := strconv.Atoi(os.Getenv("JS_PLC4X_INSTANCE"))
if err != nil {
Expand All @@ -147,10 +148,10 @@ func readConfigFile() (cfg configData, instanceNumber int, logLevel int) {
log.Println("JS_" + DriverName + "_LOGLEVEL environment variable should be a number!")
os.Exit(2)
}
logLevel = i
instLogLevel = i
}
if len(os.Args) > 2 {
logLevel, err = strconv.Atoi(os.Args[2])
instLogLevel, err = strconv.Atoi(os.Args[2])
if err != nil {
log.Println("Log Level parameter should be a number!")
os.Exit(2)
Expand Down
Loading

0 comments on commit 510ab4f

Please sign in to comment.