-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
014bab7
commit 63f93a4
Showing
15 changed files
with
10,825 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0"?> | ||
<ot-sim> | ||
<message-bus> | ||
<pull-endpoint>tcp://127.0.0.1:1234</pull-endpoint> | ||
<pub-endpoint>tcp://127.0.0.1:5678</pub-endpoint> | ||
</message-bus> | ||
<cpu> | ||
<module name="backplane">ot-sim-message-bus {{config_file}}</module> | ||
<module name="2030.5">ot-sim-sep2-module {{config_file}}</module> | ||
</cpu> | ||
<sep2> | ||
<endpoint>:9234</endpoint> | ||
<device>1</device> | ||
</sep2> | ||
</ot-sim> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
"os" | ||
|
||
otsim "github.com/patsec/ot-sim" | ||
"github.com/patsec/ot-sim/util" | ||
"github.com/patsec/ot-sim/util/sigterm" | ||
|
||
// This will cause the SEP2 module to register itself with the otsim package | ||
// so it gets run by the otsim.Start function below. | ||
_ "github.com/patsec/ot-sim/sep2" | ||
) | ||
|
||
func main() { | ||
if len(os.Args) != 2 { | ||
panic("path to config file not provided") | ||
} | ||
|
||
if err := otsim.ParseConfigFile(os.Args[1]); err != nil { | ||
fmt.Printf("Error parsing config file: %v\n", err) | ||
os.Exit(util.ExitNoRestart) | ||
} | ||
|
||
ctx := sigterm.CancelContext(context.Background()) | ||
|
||
if err := otsim.Start(ctx); err != nil { | ||
fmt.Printf("Error starting SEP2 (2030.5) module: %v\n", err) | ||
|
||
var exitErr util.ExitError | ||
if errors.As(err, &exitErr) { | ||
os.Exit(exitErr.ExitCode) | ||
} | ||
|
||
os.Exit(1) | ||
} | ||
|
||
<-ctx.Done() | ||
|
||
if err := ctx.Err(); err != nil && !errors.Is(err, context.Canceled) { | ||
fmt.Printf("Error running SEP2 (2030.5) module: %v\n", err) | ||
|
||
var exitErr util.ExitError | ||
if errors.As(err, &exitErr) { | ||
os.Exit(exitErr.ExitCode) | ||
} | ||
|
||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/beevik/etree" | ||
) | ||
|
||
type SEP2Client struct { | ||
name string | ||
} | ||
|
||
func New(name string) *SEP2Client { | ||
return &SEP2Client{ | ||
name: name, | ||
} | ||
} | ||
|
||
func (this SEP2Client) Name() string { | ||
return this.name | ||
} | ||
|
||
func (this *SEP2Client) Configure(e *etree.Element) error { | ||
return nil | ||
} | ||
|
||
func (this *SEP2Client) Run(ctx context.Context, pubEndpoint, pullEndpoint string) error { | ||
return nil | ||
} |
Oops, something went wrong.