diff --git a/cli/CmdRunner.go b/cli/CmdRunner.go index 0a7855ae..933820f1 100644 --- a/cli/CmdRunner.go +++ b/cli/CmdRunner.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020, The OTNS Authors. +// Copyright (c) 2022, The OTNS Authors. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -215,6 +215,8 @@ func (rt *CmdRunner) execute(cmd *Command, output io.Writer) { rt.executeWeb(cc, cc.Web) } else if cmd.NetInfo != nil { rt.executeNetInfo(cc, cc.NetInfo) + } else if cmd.Energy != nil { + rt.executeEnergy(cc, cc.Energy) } else { simplelogger.Panicf("unimplemented command: %#v", cmd) } @@ -769,6 +771,17 @@ func (rt *CmdRunner) executeCoaps(cc *CommandContext, cmd *CoapsCmd) { } } +func (rt *CmdRunner) executeEnergy(cc *CommandContext, energy *EnergyCmd) { + if energy.Save != nil { + rt.postAsyncWait(func(sim *simulation.Simulation) { + sim.GetEnergyAnalyser().SaveEnergyDataToFile(energy.Name, sim.Dispatcher().CurTime) + }) + } else { + cc.outputf("energy \n") + cc.outputf("\tsave [output name]\n") + } +} + func NewCmdRunner(ctx *progctx.ProgCtx, sim *simulation.Simulation) *CmdRunner { cr := &CmdRunner{ ctx: ctx, diff --git a/cli/ast.go b/cli/ast.go index c928014e..07bd63e6 100644 --- a/cli/ast.go +++ b/cli/ast.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020, The OTNS Authors. +// Copyright (c) 2022, The OTNS Authors. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -60,6 +60,7 @@ type Command struct { Speed *SpeedCmd `| @@` //nolint Title *TitleCmd `| @@` //nolint Web *WebCmd `| @@` //nolint + Energy *EnergyCmd `| @@` //nolint } //noinspection GoStructTag @@ -327,6 +328,18 @@ type WebCmd struct { Cmd struct{} `"web"` //nolint } +//noinspection GoStructTag +type EnergyCmd struct { + Cmd struct{} `"energy"` //nolint + Save *SaveFlag `( @@ )?` //nolint + Name string `@String?` //nolint +} + +//noinspection GoStructTag +type SaveFlag struct { + Dummy struct{} `"save"` //nolint +} + //noinspection GoStructTag type RadioCmd struct { Cmd struct{} `"radio"` //nolint diff --git a/dispatcher/Node.go b/dispatcher/Node.go index a30941b2..9c205192 100644 --- a/dispatcher/Node.go +++ b/dispatcher/Node.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020, The OTNS Authors. +// Copyright (c) 2022, The OTNS Authors. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -40,6 +40,8 @@ import ( const ( maxPingResultCount = 1000 maxJoinResultCount = 1000 + minChannel = 11 + maxChannel = 26 ) type pingRequest struct { @@ -65,15 +67,17 @@ type JoinResult struct { } type Node struct { - D *Dispatcher - Id NodeId - X, Y int - PartitionId uint32 - ExtAddr uint64 - Rloc16 uint16 - CreateTime uint64 - CurTime uint64 - Role OtDeviceRole + D *Dispatcher + Id NodeId + X, Y int + PartitionId uint32 + ExtAddr uint64 + Rloc16 uint16 + CreateTime uint64 + CurTime uint64 + Role OtDeviceRole + RadioState RadioStates + RadioChannel uint8 peerAddr *net.UDPAddr failureCtrl *FailureCtrl @@ -90,18 +94,19 @@ func newNode(d *Dispatcher, nodeid NodeId, x, y int, radioRange int) *Node { simplelogger.AssertTrue(radioRange >= 0) nc := &Node{ - D: d, - Id: nodeid, - CurTime: d.CurTime, - CreateTime: d.CurTime, - X: x, - Y: y, - ExtAddr: InvalidExtAddr, - Rloc16: threadconst.InvalidRloc16, - Role: OtDeviceRoleDisabled, - peerAddr: nil, // peer address will be set when the first event is received - radioRange: radioRange, - joinerState: OtJoinerStateIdle, + D: d, + Id: nodeid, + CurTime: d.CurTime, + CreateTime: d.CurTime, + X: x, + Y: y, + ExtAddr: InvalidExtAddr, + Rloc16: threadconst.InvalidRloc16, + Role: OtDeviceRoleDisabled, + peerAddr: nil, // peer address will be set when the first event is received + radioRange: radioRange, + joinerState: OtJoinerStateIdle, + RadioChannel: minChannel, } nc.failureCtrl = newFailureCtrl(nc, NonFailTime) @@ -300,3 +305,26 @@ func (node *Node) addJoinResult(js *joinerSession) { node.joinResults = node.joinResults[1:] } } + +func (node *Node) SetRadioStateFromString(s string, timestamp uint64) { + radioEnergy := node.D.energyAnalyser.GetNode(node.Id) + + simplelogger.AssertNotNil(radioEnergy) + + var state RadioStates + switch s { + case "off": + state = RadioDisabled + case "sleep": + state = RadioSleep + case "tx": + state = RadioTx + case "rx": + state = RadioRx + default: + simplelogger.Panicf("unknown radio state: %s", s) + } + + node.RadioState = state + radioEnergy.SetRadioState(state, timestamp) +} diff --git a/dispatcher/dispatcher.go b/dispatcher/dispatcher.go index 7ad75145..93e81244 100644 --- a/dispatcher/dispatcher.go +++ b/dispatcher/dispatcher.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020, The OTNS Authors. +// Copyright (c) 2022, The OTNS Authors. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -39,6 +39,7 @@ import ( "github.com/openthread/ot-ns/dissectpkt" "github.com/openthread/ot-ns/dissectpkt/wpan" + "github.com/openthread/ot-ns/energy" "github.com/openthread/ot-ns/pcap" "github.com/openthread/ot-ns/threadconst" "github.com/openthread/ot-ns/visualize" @@ -138,8 +139,9 @@ type Dispatcher struct { DispatchByShortAddrFail uint64 DispatchAllInRange uint64 } - watchingNodes map[NodeId]struct{} - stopped bool + watchingNodes map[NodeId]struct{} + energyAnalyser *energy.EnergyAnalyser + stopped bool } func NewDispatcher(ctx *progctx.ProgCtx, cfg *Config, cbHandler CallbackHandler) *Dispatcher { @@ -718,6 +720,7 @@ func (d *Dispatcher) newNode(nodeid NodeId, x, y int, radioRange int) (node *Nod node = newNode(d, nodeid, x, y, radioRange) d.nodes[nodeid] = node d.alarmMgr.AddNode(nodeid) + d.energyAnalyser.AddNode(nodeid, d.CurTime) d.setAlive(nodeid) d.vis.AddNode(nodeid, x, y, radioRange) @@ -875,7 +878,8 @@ func (d *Dispatcher) handleStatusPush(srcid NodeId, data string) { mode := ParseNodeMode(sp[1]) d.vis.SetNodeMode(srcid, mode) } else if sp[0] == "radio_state" { - // TODO: calculate energy consumption based on radio state changes of each node + params := strings.Split(sp[1], ",") + d.changeNodeRadioState(srcid, params[0], params[1]) } else { simplelogger.Warnf("unknown status push: %s=%s", sp[0], sp[1]) } @@ -1033,6 +1037,10 @@ func (d *Dispatcher) advanceTime(ts uint64) { elapsedRealTime := time.Since(d.speedStartRealTime) / time.Microsecond if elapsedRealTime > 0 && ts/1000000 != oldTime/1000000 { d.vis.AdvanceTime(ts, float64(elapsedTime)/float64(elapsedRealTime)) + + if d.energyAnalyser != nil && ts%energy.ComputePeriod == 0 { + d.energyAnalyser.StoreNetworkEnergy(ts) + } } if d.cfg.Real { @@ -1129,6 +1137,7 @@ func (d *Dispatcher) DeleteNode(id NodeId) { } d.alarmMgr.DeleteNode(id) d.deletedNodes[id] = struct{}{} + d.energyAnalyser.DeleteNode(id) d.vis.DeleteNode(id) } @@ -1319,3 +1328,21 @@ func (d *Dispatcher) CollectCoapMessages() []*CoapMessage { return nil } } + +func (d *Dispatcher) SetEnergyAnalyser(e *energy.EnergyAnalyser) { + d.energyAnalyser = e +} + +func (d *Dispatcher) changeNodeRadioState(nodeid NodeId, state, channel string) { + node := d.nodes[nodeid] + + if d.energyAnalyser != nil { + node.SetRadioStateFromString(state, d.CurTime) + } + + u, err := strconv.ParseUint(channel, 10, 8) + simplelogger.AssertNil(err, "changeNodeRadioState: invalid channel %s", channel) + simplelogger.AssertTrue(u >= minChannel && u <= maxChannel) + + node.RadioChannel = uint8(u) +} diff --git a/energy/core.go b/energy/core.go new file mode 100644 index 00000000..7553ac6c --- /dev/null +++ b/energy/core.go @@ -0,0 +1,201 @@ +// Copyright (c) 2022, The OTNS Authors. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// 3. Neither the name of the copyright holder nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +package energy + +import ( + "fmt" + "os" + "sort" + + pb "github.com/openthread/ot-ns/visualize/grpc/pb" + "github.com/simonlingoogle/go-simplelogger" +) + +type EnergyAnalyser struct { + nodes map[int]*NodeEnergy + networkHistory []NetworkConsumption + energyHistoryByNodes [][]*pb.NodeEnergy + title string +} + +func (e *EnergyAnalyser) AddNode(nodeID int, timestamp uint64) { + if _, ok := e.nodes[nodeID]; ok { + return + } + e.nodes[nodeID] = newNode(nodeID, timestamp) +} + +func (e *EnergyAnalyser) DeleteNode(nodeID int) { + delete(e.nodes, nodeID) + + if len(e.nodes) == 0 { + e.ClearEnergyData() + } +} + +func (e *EnergyAnalyser) GetNode(nodeID int) *NodeEnergy { + return e.nodes[nodeID] +} + +func (e *EnergyAnalyser) GetNetworkEnergyHistory() []NetworkConsumption { + return e.networkHistory +} + +func (e *EnergyAnalyser) GetEnergyHistoryByNodes() [][]*pb.NodeEnergy { + return e.energyHistoryByNodes +} + +func (e *EnergyAnalyser) GetLatestEnergyOfNodes() []*pb.NodeEnergy { + return e.energyHistoryByNodes[len(e.energyHistoryByNodes)-1] +} + +func (e *EnergyAnalyser) StoreNetworkEnergy(timestamp uint64) { + nodesEnergySnapshot := make([]*pb.NodeEnergy, 0, len(e.nodes)) + networkSnapshot := NetworkConsumption{ + Timestamp: timestamp, + } + + netSize := float64(len(e.nodes)) + for _, node := range e.nodes { + node.ComputeRadioState(timestamp) + + e := &pb.NodeEnergy{ + NodeId: int32(node.nodeId), + Disabled: float64(node.radio.SpentDisabled) * RadioDisabledConsumption, + Sleep: float64(node.radio.SpentSleep) * RadioSleepConsumption, + Tx: float64(node.radio.SpentTx) * RadioTxConsumption, + Rx: float64(node.radio.SpentRx) * RadioRxConsumption, + } + + networkSnapshot.EnergyConsDisabled += e.Disabled / netSize + networkSnapshot.EnergyConsSleep += e.Sleep / netSize + networkSnapshot.EnergyConsTx += e.Tx / netSize + networkSnapshot.EnergyConsRx += e.Rx / netSize + nodesEnergySnapshot = append(nodesEnergySnapshot, e) + } + + e.networkHistory = append(e.networkHistory, networkSnapshot) + e.energyHistoryByNodes = append(e.energyHistoryByNodes, nodesEnergySnapshot) +} + +func (e *EnergyAnalyser) SaveEnergyDataToFile(name string, timestamp uint64) { + if name == "" { + if e.title == "" { + name = "energy" + } else { + name = e.title + } + } + + //Get current directory and add name to the path + dir, _ := os.Getwd() + + //create "energy_results" directory if it does not exist + if _, err := os.Stat(dir + "/energy_results"); os.IsNotExist(err) { + err := os.Mkdir(dir+"/energy_results", 0777) + if err != nil { + simplelogger.Error("Failed to create energy_results directory") + return + } + } + + path := fmt.Sprintf("%s/energy_results/%s", dir, name) + fileNodes, err := os.Create(path + "_nodes.txt") + if err != nil { + simplelogger.Error("Error creating file: %s", err) + return + } + defer fileNodes.Close() + + fileNetwork, err := os.Create(path + ".txt") + if err != nil { + simplelogger.Error("Error creating file: %s", err) + return + } + defer fileNetwork.Close() + + //Save all nodes' energy data to file + e.writeEnergyByNodes(fileNodes, timestamp) + + //Save network energy data to file (timestamp converted to milliseconds) + e.writeNetworkEnergy(fileNetwork, timestamp) +} + +func (e *EnergyAnalyser) writeEnergyByNodes(fileNodes *os.File, timestamp uint64) { + fmt.Fprintf(fileNodes, "Duration of the simulated network (in milliseconds): %d\n", timestamp/1000) + fmt.Fprintf(fileNodes, "ID\tDisabled (mJ)\tIdle (mJ)\tTransmiting (mJ)\tReceiving (mJ)\n") + + sortedNodes := make([]int, 0, len(e.nodes)) + for id := range e.nodes { + sortedNodes = append(sortedNodes, id) + } + sort.Ints(sortedNodes) + + for _, id := range sortedNodes { + node := e.nodes[id] + fmt.Fprintf(fileNodes, "%d\t%f\t%f\t%f\t%f\n", + id, + float64(node.radio.SpentDisabled)*RadioDisabledConsumption, + float64(node.radio.SpentSleep)*RadioSleepConsumption, + float64(node.radio.SpentTx)*RadioTxConsumption, + float64(node.radio.SpentRx)*RadioRxConsumption, + ) + } +} + +func (e *EnergyAnalyser) writeNetworkEnergy(fileNetwork *os.File, timestamp uint64) { + fmt.Fprintf(fileNetwork, "Duration of the simulated network (in milliseconds): %d\n", timestamp/1000) + fmt.Fprintf(fileNetwork, "Time (ms)\tDisabled (mJ)\tIdle (mJ)\tTransmiting (mJ)\tReceiving (mJ)\n") + for _, snapshot := range e.networkHistory { + fmt.Fprintf(fileNetwork, "%d\t%f\t%f\t%f\t%f\n", + snapshot.Timestamp/1000, + snapshot.EnergyConsDisabled, + snapshot.EnergyConsSleep, + snapshot.EnergyConsTx, + snapshot.EnergyConsRx, + ) + } +} + +func (e *EnergyAnalyser) ClearEnergyData() { + simplelogger.Debugf("Node's energy data cleared") + e.networkHistory = make([]NetworkConsumption, 0, 3600) + e.energyHistoryByNodes = make([][]*pb.NodeEnergy, 0, 3600) +} + +func (e *EnergyAnalyser) SetTitle(title string) { + e.title = title +} + +func NewEnergyAnalyser() *EnergyAnalyser { + ea := &EnergyAnalyser{ + nodes: make(map[int]*NodeEnergy), + networkHistory: make([]NetworkConsumption, 0, 3600), //Start with space for 1 sample every 30s for 1 hour = 1*60*60/30 = 3600 samples + energyHistoryByNodes: make([][]*pb.NodeEnergy, 0, 3600), + } + return ea +} diff --git a/energy/node.go b/energy/node.go new file mode 100644 index 00000000..6a9731f0 --- /dev/null +++ b/energy/node.go @@ -0,0 +1,75 @@ +// Copyright (c) 2022, The OTNS Authors. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// 3. Neither the name of the copyright holder nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +package energy + +import ( + . "github.com/openthread/ot-ns/types" + "github.com/simonlingoogle/go-simplelogger" +) + +type NodeEnergy struct { + nodeId int + radio RadioStatus +} + +func (node *NodeEnergy) ComputeRadioState(timestamp uint64) { + delta := timestamp - node.radio.Timestamp + switch node.radio.State { + case RadioDisabled: + node.radio.SpentDisabled += delta + case RadioSleep: + node.radio.SpentSleep += delta + case RadioTx: + node.radio.SpentTx += delta + case RadioRx: + node.radio.SpentRx += delta + default: + simplelogger.Panicf("unknown radio state: %v", node.radio.State) + } + node.radio.Timestamp = timestamp +} + +func (node *NodeEnergy) SetRadioState(state RadioStates, timestamp uint64) { + //Mandatory: compute energy consumed by the radio first. + node.ComputeRadioState(timestamp) + node.radio.State = state +} + +func newNode(nodeID int, timestamp uint64) *NodeEnergy { + node := &NodeEnergy{ + nodeId: nodeID, + radio: RadioStatus{ + State: RadioDisabled, + SpentDisabled: 0.0, + SpentSleep: 0.0, + SpentRx: 0.0, + SpentTx: 0.0, + Timestamp: timestamp, + }, + } + return node +} diff --git a/energy/types.go b/energy/types.go new file mode 100644 index 00000000..31105178 --- /dev/null +++ b/energy/types.go @@ -0,0 +1,63 @@ +// Copyright (c) 2022, The OTNS Authors. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// 3. Neither the name of the copyright holder nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +package energy + +import ( + . "github.com/openthread/ot-ns/types" +) + +/* + * Default consumption values by state of STM32WB55rg at 3.3V. + * Consumption in kilowatts, time in microseconds, resulting energy in mJ. + */ +const ( + RadioDisabledConsumption float64 = 0.00000011 //kilowatts, to be confirmed + RadioTxConsumption float64 = 0.00001716 //kilowatts @ i = 5.2 mA + RadioRxConsumption float64 = 0.00001485 //kilowatts @ i = 4.5 mA + RadioSleepConsumption float64 = 0.00001485 //kilowatts @ i = 4.5 mA +) + +const ( + ComputePeriod uint64 = 30000000 // in seconds +) + +type RadioStatus struct { + State RadioStates + SpentDisabled uint64 + SpentSleep uint64 + SpentTx uint64 + SpentRx uint64 + Timestamp uint64 +} + +type NetworkConsumption struct { + Timestamp uint64 + EnergyConsDisabled float64 + EnergyConsSleep float64 + EnergyConsTx float64 + EnergyConsRx float64 +} diff --git a/go.mod b/go.mod index 8fad496f..c2764bf4 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,6 @@ go 1.17 require ( github.com/alecthomas/participle v0.5.0 github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e - github.com/golang/protobuf v1.5.2 github.com/pkg/errors v0.9.1 github.com/simonlingoogle/go-simplelogger v0.0.0-20191122025812-962af3877d65 github.com/stretchr/testify v1.7.0 @@ -44,6 +43,7 @@ require ( github.com/chzyer/logex v1.1.10 // indirect github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/golang/protobuf v1.5.2 // indirect github.com/kr/text v0.2.0 // indirect github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect github.com/pmezard/go-difflib v1.0.0 // indirect diff --git a/pylibs/otns/proto/visualize_grpc_pb2.py b/pylibs/otns/proto/visualize_grpc_pb2.py index 2731f531..015eba3b 100644 --- a/pylibs/otns/proto/visualize_grpc_pb2.py +++ b/pylibs/otns/proto/visualize_grpc_pb2.py @@ -20,7 +20,7 @@ syntax='proto3', serialized_options=b'Z-github.com/openthread/ot-ns/visualize/grpc/pb', create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x14visualize_grpc.proto\x12\x11visualize_grpc_pb\"\x12\n\x10VisualizeRequest\"\xb7\x0b\n\x0eVisualizeEvent\x12\x33\n\x08\x61\x64\x64_node\x18\x01 \x01(\x0b\x32\x1f.visualize_grpc_pb.AddNodeEventH\x00\x12\x39\n\x0b\x64\x65lete_node\x18\x02 \x01(\x0b\x32\".visualize_grpc_pb.DeleteNodeEventH\x00\x12@\n\x0fset_node_rloc16\x18\x03 \x01(\x0b\x32%.visualize_grpc_pb.SetNodeRloc16EventH\x00\x12<\n\rset_node_role\x18\x04 \x01(\x0b\x32#.visualize_grpc_pb.SetNodeRoleEventH\x00\x12:\n\x0cset_node_pos\x18\x05 \x01(\x0b\x32\".visualize_grpc_pb.SetNodePosEventH\x00\x12K\n\x15set_node_partition_id\x18\x06 \x01(\x0b\x32*.visualize_grpc_pb.SetNodePartitionIdEventH\x00\x12:\n\x0con_node_fail\x18\x07 \x01(\x0b\x32\".visualize_grpc_pb.OnNodeFailEventH\x00\x12@\n\x0fon_node_recover\x18\x08 \x01(\x0b\x32%.visualize_grpc_pb.OnNodeRecoverEventH\x00\x12\x37\n\nset_parent\x18\t \x01(\x0b\x32!.visualize_grpc_pb.SetParentEventH\x00\x12\x37\n\ncount_down\x18\n \x01(\x0b\x32!.visualize_grpc_pb.CountDownEventH\x00\x12\x42\n\x10show_demo_legend\x18\x0b \x01(\x0b\x32&.visualize_grpc_pb.ShowDemoLegendEventH\x00\x12;\n\x0c\x61\x64vance_time\x18\x0c \x01(\x0b\x32#.visualize_grpc_pb.AdvanceTimeEventH\x00\x12\x42\n\x10\x61\x64\x64_router_table\x18\r \x01(\x0b\x32&.visualize_grpc_pb.AddRouterTableEventH\x00\x12H\n\x13remove_router_table\x18\x0e \x01(\x0b\x32).visualize_grpc_pb.RemoveRouterTableEventH\x00\x12@\n\x0f\x61\x64\x64_child_table\x18\x0f \x01(\x0b\x32%.visualize_grpc_pb.AddChildTableEventH\x00\x12\x46\n\x12remove_child_table\x18\x10 \x01(\x0b\x32(.visualize_grpc_pb.RemoveChildTableEventH\x00\x12,\n\x04send\x18\x11 \x01(\x0b\x32\x1c.visualize_grpc_pb.SendEventH\x00\x12\x35\n\tset_speed\x18\x12 \x01(\x0b\x32 .visualize_grpc_pb.SetSpeedEventH\x00\x12\x36\n\theartbeat\x18\x13 \x01(\x0b\x32!.visualize_grpc_pb.HeartbeatEventH\x00\x12\x45\n\x12on_ext_addr_change\x18\x14 \x01(\x0b\x32\'.visualize_grpc_pb.OnExtAddrChangeEventH\x00\x12\x35\n\tset_title\x18\x15 \x01(\x0b\x32 .visualize_grpc_pb.SetTitleEventH\x00\x12<\n\rset_node_mode\x18\x16 \x01(\x0b\x32#.visualize_grpc_pb.SetNodeModeEventH\x00\x12\x42\n\x10set_network_info\x18\x17 \x01(\x0b\x32&.visualize_grpc_pb.SetNetworkInfoEventH\x00\x42\x06\n\x04type\"a\n\tSendEvent\x12\x0e\n\x06src_id\x18\x01 \x01(\x05\x12\x0e\n\x06\x64st_id\x18\x02 \x01(\x05\x12\x34\n\x07mv_info\x18\x03 \x01(\x0b\x32#.visualize_grpc_pb.MsgVisualizeInfo\"z\n\x10MsgVisualizeInfo\x12\x0f\n\x07\x63hannel\x18\x01 \x01(\r\x12\x15\n\rframe_control\x18\x02 \x01(\r\x12\x0b\n\x03seq\x18\x03 \x01(\r\x12\x16\n\x0e\x64st_addr_short\x18\x04 \x01(\r\x12\x19\n\x11\x64st_addr_extended\x18\x05 \x01(\x04\"8\n\x13\x41\x64\x64RouterTableEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\x10\n\x08\x65xt_addr\x18\x02 \x01(\x04\";\n\x16RemoveRouterTableEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\x10\n\x08\x65xt_addr\x18\x02 \x01(\x04\"7\n\x12\x41\x64\x64\x43hildTableEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\x10\n\x08\x65xt_addr\x18\x02 \x01(\x04\":\n\x15RemoveChildTableEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\x10\n\x08\x65xt_addr\x18\x02 \x01(\x04\"\x1e\n\rSetSpeedEvent\x12\r\n\x05speed\x18\x01 \x01(\x01\"\x10\n\x0eHeartbeatEvent\"-\n\x10\x41\x64vanceTimeEvent\x12\n\n\x02ts\x18\x01 \x01(\x04\x12\r\n\x05speed\x18\x02 \x01(\x01\"3\n\x0eSetParentEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\x10\n\x08\x65xt_addr\x18\x02 \x01(\x04\"3\n\x0e\x43ountDownEvent\x12\x13\n\x0b\x64uration_ms\x18\x01 \x01(\x03\x12\x0c\n\x04text\x18\x02 \x01(\t\":\n\x13ShowDemoLegendEvent\x12\t\n\x01x\x18\x01 \x01(\x05\x12\t\n\x01y\x18\x02 \x01(\x05\x12\r\n\x05title\x18\x03 \x01(\t\"8\n\x0fSetNodePosEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\t\n\x01x\x18\x02 \x01(\x05\x12\t\n\x01y\x18\x03 \x01(\x05\"R\n\x10SetNodeRoleEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12-\n\x04role\x18\x02 \x01(\x0e\x32\x1f.visualize_grpc_pb.OtDeviceRole\"@\n\x17SetNodePartitionIdEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\x14\n\x0cpartition_id\x18\x02 \x01(\r\"\"\n\x0fOnNodeFailEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\"%\n\x12OnNodeRecoverEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\"\"\n\x0f\x44\x65leteNodeEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\"J\n\x0c\x41\x64\x64NodeEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\t\n\x01x\x18\x02 \x01(\x05\x12\t\n\x01y\x18\x03 \x01(\x05\x12\x13\n\x0bradio_range\x18\x04 \x01(\x05\"x\n\x08NodeMode\x12\x17\n\x0frx_on_when_idle\x18\x01 \x01(\x08\x12\x1c\n\x14secure_data_requests\x18\x02 \x01(\x08\x12\x1a\n\x12\x66ull_thread_device\x18\x03 \x01(\x08\x12\x19\n\x11\x66ull_network_data\x18\x04 \x01(\x08\"5\n\x12SetNodeRloc16Event\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\x0e\n\x06rloc16\x18\x02 \x01(\r\"9\n\x14OnExtAddrChangeEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\x10\n\x08\x65xt_addr\x18\x02 \x01(\x04\"G\n\rSetTitleEvent\x12\r\n\x05title\x18\x01 \x01(\t\x12\t\n\x01x\x18\x02 \x01(\x05\x12\t\n\x01y\x18\x03 \x01(\x05\x12\x11\n\tfont_size\x18\x04 \x01(\x05\"S\n\x10SetNodeModeEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12.\n\tnode_mode\x18\x02 \x01(\x0b\x32\x1b.visualize_grpc_pb.NodeMode\"D\n\x13SetNetworkInfoEvent\x12\x0c\n\x04real\x18\x01 \x01(\x08\x12\x0f\n\x07version\x18\x02 \x01(\t\x12\x0e\n\x06\x63ommit\x18\x03 \x01(\t\"!\n\x0e\x43ommandRequest\x12\x0f\n\x07\x63ommand\x18\x01 \x01(\t\"!\n\x0f\x43ommandResponse\x12\x0e\n\x06output\x18\x01 \x03(\t\"R\n\x0bReplayEntry\x12\x11\n\ttimestamp\x18\x01 \x01(\x04\x12\x30\n\x05\x65vent\x18\x02 \x01(\x0b\x32!.visualize_grpc_pb.VisualizeEvent\"\x07\n\x05\x45mpty*\x98\x01\n\x0cOtDeviceRole\x12\x1b\n\x17OT_DEVICE_ROLE_DISABLED\x10\x00\x12\x1b\n\x17OT_DEVICE_ROLE_DETACHED\x10\x01\x12\x18\n\x14OT_DEVICE_ROLE_CHILD\x10\x02\x12\x19\n\x15OT_DEVICE_ROLE_ROUTER\x10\x03\x12\x19\n\x15OT_DEVICE_ROLE_LEADER\x10\x04\x32\xbf\x01\n\x14VisualizeGrpcService\x12U\n\tVisualize\x12#.visualize_grpc_pb.VisualizeRequest\x1a!.visualize_grpc_pb.VisualizeEvent0\x01\x12P\n\x07\x43ommand\x12!.visualize_grpc_pb.CommandRequest\x1a\".visualize_grpc_pb.CommandResponseB/Z-github.com/openthread/ot-ns/visualize/grpc/pbb\x06proto3' + serialized_pb=b'\n\x14visualize_grpc.proto\x12\x11visualize_grpc_pb\"\x12\n\x10VisualizeRequest\"\xb7\x0b\n\x0eVisualizeEvent\x12\x33\n\x08\x61\x64\x64_node\x18\x01 \x01(\x0b\x32\x1f.visualize_grpc_pb.AddNodeEventH\x00\x12\x39\n\x0b\x64\x65lete_node\x18\x02 \x01(\x0b\x32\".visualize_grpc_pb.DeleteNodeEventH\x00\x12@\n\x0fset_node_rloc16\x18\x03 \x01(\x0b\x32%.visualize_grpc_pb.SetNodeRloc16EventH\x00\x12<\n\rset_node_role\x18\x04 \x01(\x0b\x32#.visualize_grpc_pb.SetNodeRoleEventH\x00\x12:\n\x0cset_node_pos\x18\x05 \x01(\x0b\x32\".visualize_grpc_pb.SetNodePosEventH\x00\x12K\n\x15set_node_partition_id\x18\x06 \x01(\x0b\x32*.visualize_grpc_pb.SetNodePartitionIdEventH\x00\x12:\n\x0con_node_fail\x18\x07 \x01(\x0b\x32\".visualize_grpc_pb.OnNodeFailEventH\x00\x12@\n\x0fon_node_recover\x18\x08 \x01(\x0b\x32%.visualize_grpc_pb.OnNodeRecoverEventH\x00\x12\x37\n\nset_parent\x18\t \x01(\x0b\x32!.visualize_grpc_pb.SetParentEventH\x00\x12\x37\n\ncount_down\x18\n \x01(\x0b\x32!.visualize_grpc_pb.CountDownEventH\x00\x12\x42\n\x10show_demo_legend\x18\x0b \x01(\x0b\x32&.visualize_grpc_pb.ShowDemoLegendEventH\x00\x12;\n\x0c\x61\x64vance_time\x18\x0c \x01(\x0b\x32#.visualize_grpc_pb.AdvanceTimeEventH\x00\x12\x42\n\x10\x61\x64\x64_router_table\x18\r \x01(\x0b\x32&.visualize_grpc_pb.AddRouterTableEventH\x00\x12H\n\x13remove_router_table\x18\x0e \x01(\x0b\x32).visualize_grpc_pb.RemoveRouterTableEventH\x00\x12@\n\x0f\x61\x64\x64_child_table\x18\x0f \x01(\x0b\x32%.visualize_grpc_pb.AddChildTableEventH\x00\x12\x46\n\x12remove_child_table\x18\x10 \x01(\x0b\x32(.visualize_grpc_pb.RemoveChildTableEventH\x00\x12,\n\x04send\x18\x11 \x01(\x0b\x32\x1c.visualize_grpc_pb.SendEventH\x00\x12\x35\n\tset_speed\x18\x12 \x01(\x0b\x32 .visualize_grpc_pb.SetSpeedEventH\x00\x12\x36\n\theartbeat\x18\x13 \x01(\x0b\x32!.visualize_grpc_pb.HeartbeatEventH\x00\x12\x45\n\x12on_ext_addr_change\x18\x14 \x01(\x0b\x32\'.visualize_grpc_pb.OnExtAddrChangeEventH\x00\x12\x35\n\tset_title\x18\x15 \x01(\x0b\x32 .visualize_grpc_pb.SetTitleEventH\x00\x12<\n\rset_node_mode\x18\x16 \x01(\x0b\x32#.visualize_grpc_pb.SetNodeModeEventH\x00\x12\x42\n\x10set_network_info\x18\x17 \x01(\x0b\x32&.visualize_grpc_pb.SetNetworkInfoEventH\x00\x42\x06\n\x04type\"a\n\tSendEvent\x12\x0e\n\x06src_id\x18\x01 \x01(\x05\x12\x0e\n\x06\x64st_id\x18\x02 \x01(\x05\x12\x34\n\x07mv_info\x18\x03 \x01(\x0b\x32#.visualize_grpc_pb.MsgVisualizeInfo\"z\n\x10MsgVisualizeInfo\x12\x0f\n\x07\x63hannel\x18\x01 \x01(\r\x12\x15\n\rframe_control\x18\x02 \x01(\r\x12\x0b\n\x03seq\x18\x03 \x01(\r\x12\x16\n\x0e\x64st_addr_short\x18\x04 \x01(\r\x12\x19\n\x11\x64st_addr_extended\x18\x05 \x01(\x04\"8\n\x13\x41\x64\x64RouterTableEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\x10\n\x08\x65xt_addr\x18\x02 \x01(\x04\";\n\x16RemoveRouterTableEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\x10\n\x08\x65xt_addr\x18\x02 \x01(\x04\"7\n\x12\x41\x64\x64\x43hildTableEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\x10\n\x08\x65xt_addr\x18\x02 \x01(\x04\":\n\x15RemoveChildTableEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\x10\n\x08\x65xt_addr\x18\x02 \x01(\x04\"\x1e\n\rSetSpeedEvent\x12\r\n\x05speed\x18\x01 \x01(\x01\"\x10\n\x0eHeartbeatEvent\"-\n\x10\x41\x64vanceTimeEvent\x12\n\n\x02ts\x18\x01 \x01(\x04\x12\r\n\x05speed\x18\x02 \x01(\x01\"3\n\x0eSetParentEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\x10\n\x08\x65xt_addr\x18\x02 \x01(\x04\"3\n\x0e\x43ountDownEvent\x12\x13\n\x0b\x64uration_ms\x18\x01 \x01(\x03\x12\x0c\n\x04text\x18\x02 \x01(\t\":\n\x13ShowDemoLegendEvent\x12\t\n\x01x\x18\x01 \x01(\x05\x12\t\n\x01y\x18\x02 \x01(\x05\x12\r\n\x05title\x18\x03 \x01(\t\"8\n\x0fSetNodePosEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\t\n\x01x\x18\x02 \x01(\x05\x12\t\n\x01y\x18\x03 \x01(\x05\"R\n\x10SetNodeRoleEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12-\n\x04role\x18\x02 \x01(\x0e\x32\x1f.visualize_grpc_pb.OtDeviceRole\"@\n\x17SetNodePartitionIdEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\x14\n\x0cpartition_id\x18\x02 \x01(\r\"\"\n\x0fOnNodeFailEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\"%\n\x12OnNodeRecoverEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\"\"\n\x0f\x44\x65leteNodeEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\"J\n\x0c\x41\x64\x64NodeEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\t\n\x01x\x18\x02 \x01(\x05\x12\t\n\x01y\x18\x03 \x01(\x05\x12\x13\n\x0bradio_range\x18\x04 \x01(\x05\"x\n\x08NodeMode\x12\x17\n\x0frx_on_when_idle\x18\x01 \x01(\x08\x12\x1c\n\x14secure_data_requests\x18\x02 \x01(\x08\x12\x1a\n\x12\x66ull_thread_device\x18\x03 \x01(\x08\x12\x19\n\x11\x66ull_network_data\x18\x04 \x01(\x08\"5\n\x12SetNodeRloc16Event\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\x0e\n\x06rloc16\x18\x02 \x01(\r\"9\n\x14OnExtAddrChangeEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\x10\n\x08\x65xt_addr\x18\x02 \x01(\x04\"G\n\rSetTitleEvent\x12\r\n\x05title\x18\x01 \x01(\t\x12\t\n\x01x\x18\x02 \x01(\x05\x12\t\n\x01y\x18\x03 \x01(\x05\x12\x11\n\tfont_size\x18\x04 \x01(\x05\"S\n\x10SetNodeModeEvent\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12.\n\tnode_mode\x18\x02 \x01(\x0b\x32\x1b.visualize_grpc_pb.NodeMode\"D\n\x13SetNetworkInfoEvent\x12\x0c\n\x04real\x18\x01 \x01(\x08\x12\x0f\n\x07version\x18\x02 \x01(\t\x12\x0e\n\x06\x63ommit\x18\x03 \x01(\t\"V\n\nNodeEnergy\x12\x0f\n\x07node_id\x18\x01 \x01(\x05\x12\x10\n\x08\x64isabled\x18\x02 \x01(\x01\x12\r\n\x05sleep\x18\x03 \x01(\x01\x12\n\n\x02tx\x18\x04 \x01(\x01\x12\n\n\x02rx\x18\x05 \x01(\x01\"!\n\x0e\x43ommandRequest\x12\x0f\n\x07\x63ommand\x18\x01 \x01(\t\"!\n\x0f\x43ommandResponse\x12\x0e\n\x06output\x18\x01 \x03(\t\"R\n\x0bReplayEntry\x12\x11\n\ttimestamp\x18\x01 \x01(\x04\x12\x30\n\x05\x65vent\x18\x02 \x01(\x0b\x32!.visualize_grpc_pb.VisualizeEvent\"\x07\n\x05\x45mpty*\x98\x01\n\x0cOtDeviceRole\x12\x1b\n\x17OT_DEVICE_ROLE_DISABLED\x10\x00\x12\x1b\n\x17OT_DEVICE_ROLE_DETACHED\x10\x01\x12\x18\n\x14OT_DEVICE_ROLE_CHILD\x10\x02\x12\x19\n\x15OT_DEVICE_ROLE_ROUTER\x10\x03\x12\x19\n\x15OT_DEVICE_ROLE_LEADER\x10\x04\x32\xbf\x01\n\x14VisualizeGrpcService\x12U\n\tVisualize\x12#.visualize_grpc_pb.VisualizeRequest\x1a!.visualize_grpc_pb.VisualizeEvent0\x01\x12P\n\x07\x43ommand\x12!.visualize_grpc_pb.CommandRequest\x1a\".visualize_grpc_pb.CommandResponseB/Z-github.com/openthread/ot-ns/visualize/grpc/pbb\x06proto3' ) _OTDEVICEROLE = _descriptor.EnumDescriptor( @@ -58,8 +58,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=3274, - serialized_end=3426, + serialized_start=3362, + serialized_end=3514, ) _sym_db.RegisterEnumDescriptor(_OTDEVICEROLE) @@ -1312,6 +1312,66 @@ ) +_NODEENERGY = _descriptor.Descriptor( + name='NodeEnergy', + full_name='visualize_grpc_pb.NodeEnergy', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='node_id', full_name='visualize_grpc_pb.NodeEnergy.node_id', index=0, + number=1, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='disabled', full_name='visualize_grpc_pb.NodeEnergy.disabled', index=1, + number=2, type=1, cpp_type=5, label=1, + has_default_value=False, default_value=float(0), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='sleep', full_name='visualize_grpc_pb.NodeEnergy.sleep', index=2, + number=3, type=1, cpp_type=5, label=1, + has_default_value=False, default_value=float(0), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='tx', full_name='visualize_grpc_pb.NodeEnergy.tx', index=3, + number=4, type=1, cpp_type=5, label=1, + has_default_value=False, default_value=float(0), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='rx', full_name='visualize_grpc_pb.NodeEnergy.rx', index=4, + number=5, type=1, cpp_type=5, label=1, + has_default_value=False, default_value=float(0), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=3110, + serialized_end=3196, +) + + _COMMANDREQUEST = _descriptor.Descriptor( name='CommandRequest', full_name='visualize_grpc_pb.CommandRequest', @@ -1339,8 +1399,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=3110, - serialized_end=3143, + serialized_start=3198, + serialized_end=3231, ) @@ -1371,8 +1431,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=3145, - serialized_end=3178, + serialized_start=3233, + serialized_end=3266, ) @@ -1410,8 +1470,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=3180, - serialized_end=3262, + serialized_start=3268, + serialized_end=3350, ) @@ -1435,8 +1495,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=3264, - serialized_end=3271, + serialized_start=3352, + serialized_end=3359, ) _VISUALIZEEVENT.fields_by_name['add_node'].message_type = _ADDNODEEVENT @@ -1562,6 +1622,7 @@ DESCRIPTOR.message_types_by_name['SetTitleEvent'] = _SETTITLEEVENT DESCRIPTOR.message_types_by_name['SetNodeModeEvent'] = _SETNODEMODEEVENT DESCRIPTOR.message_types_by_name['SetNetworkInfoEvent'] = _SETNETWORKINFOEVENT +DESCRIPTOR.message_types_by_name['NodeEnergy'] = _NODEENERGY DESCRIPTOR.message_types_by_name['CommandRequest'] = _COMMANDREQUEST DESCRIPTOR.message_types_by_name['CommandResponse'] = _COMMANDRESPONSE DESCRIPTOR.message_types_by_name['ReplayEntry'] = _REPLAYENTRY @@ -1758,6 +1819,13 @@ }) _sym_db.RegisterMessage(SetNetworkInfoEvent) +NodeEnergy = _reflection.GeneratedProtocolMessageType('NodeEnergy', (_message.Message,), { + 'DESCRIPTOR' : _NODEENERGY, + '__module__' : 'visualize_grpc_pb2' + # @@protoc_insertion_point(class_scope:visualize_grpc_pb.NodeEnergy) + }) +_sym_db.RegisterMessage(NodeEnergy) + CommandRequest = _reflection.GeneratedProtocolMessageType('CommandRequest', (_message.Message,), { 'DESCRIPTOR' : _COMMANDREQUEST, '__module__' : 'visualize_grpc_pb2' @@ -1796,8 +1864,8 @@ index=0, serialized_options=None, create_key=_descriptor._internal_create_key, - serialized_start=3429, - serialized_end=3620, + serialized_start=3517, + serialized_end=3708, methods=[ _descriptor.MethodDescriptor( name='Visualize', diff --git a/simulation/simulation.go b/simulation/simulation.go index 0c6d6d28..725c1ed1 100644 --- a/simulation/simulation.go +++ b/simulation/simulation.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020, The OTNS Authors. +// Copyright (c) 2022, The OTNS Authors. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -31,6 +31,7 @@ import ( "sort" "time" + "github.com/openthread/ot-ns/energy" "github.com/openthread/ot-ns/progctx" "github.com/openthread/ot-ns/dispatcher" @@ -41,14 +42,15 @@ import ( ) type Simulation struct { - ctx *progctx.ProgCtx - cfg *Config - nodes map[NodeId]*Node - d *dispatcher.Dispatcher - vis visualize.Visualizer - cmdRunner CmdRunner - rawMode bool - networkInfo visualize.NetworkInfo + ctx *progctx.ProgCtx + cfg *Config + nodes map[NodeId]*Node + d *dispatcher.Dispatcher + vis visualize.Visualizer + cmdRunner CmdRunner + rawMode bool + networkInfo visualize.NetworkInfo + energyAnalyser *energy.EnergyAnalyser } func NewSimulation(ctx *progctx.ProgCtx, cfg *Config, dispatcherCfg *dispatcher.Config) (*Simulation, error) { @@ -78,6 +80,10 @@ func NewSimulation(ctx *progctx.ProgCtx, cfg *Config, dispatcherCfg *dispatcher. simplelogger.Panicf("remove tmp directory failed: %+v", err) } + //TODO add a flag to turn on/off the energy analyzer + s.energyAnalyser = energy.NewEnergyAnalyser() + s.d.SetEnergyAnalyser(s.energyAnalyser) + return s, nil } @@ -274,6 +280,7 @@ func (s *Simulation) IsStopped() bool { func (s *Simulation) SetTitleInfo(titleInfo visualize.TitleInfo) { s.vis.SetTitle(titleInfo) + s.energyAnalyser.SetTitle(titleInfo.Title) } func (s *Simulation) SetCmdRunner(cmdRunner CmdRunner) { @@ -289,3 +296,7 @@ func (s *Simulation) SetNetworkInfo(networkInfo visualize.NetworkInfo) { s.networkInfo = networkInfo s.vis.SetNetworkInfo(networkInfo) } + +func (s *Simulation) GetEnergyAnalyser() *energy.EnergyAnalyser { + return s.energyAnalyser +} diff --git a/types/types.go b/types/types.go index 08b2c6e9..ebe881d1 100644 --- a/types/types.go +++ b/types/types.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020, The OTNS Authors. +// Copyright (c) 2022, The OTNS Authors. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -109,3 +109,12 @@ func (r OtDeviceRole) String() string { return "invalid" } } + +type RadioStates byte + +const ( + RadioDisabled RadioStates = 0 + RadioSleep RadioStates = 1 + RadioTx RadioStates = 2 + RadioRx RadioStates = 3 +) diff --git a/visualize/grpc/pb/visualize_grpc.pb.go b/visualize/grpc/pb/visualize_grpc.pb.go index a8dc00ee..5af9d687 100644 --- a/visualize/grpc/pb/visualize_grpc.pb.go +++ b/visualize/grpc/pb/visualize_grpc.pb.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020, The OTNS Authors. +// Copyright (c) 2022, The OTNS Authors. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -26,15 +26,14 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0 -// protoc v3.12.3 +// protoc-gen-go v1.27.1 +// protoc v3.19.4 // source: visualize_grpc.proto -package visualize_grpc_pb +package pb import ( context "context" - proto "github.com/golang/protobuf/proto" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -51,10 +50,6 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - type OtDeviceRole int32 const ( @@ -1952,6 +1947,85 @@ func (x *SetNetworkInfoEvent) GetCommit() string { return "" } +type NodeEnergy struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId int32 `protobuf:"varint,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` + Disabled float64 `protobuf:"fixed64,2,opt,name=disabled,proto3" json:"disabled,omitempty"` + Sleep float64 `protobuf:"fixed64,3,opt,name=sleep,proto3" json:"sleep,omitempty"` + Tx float64 `protobuf:"fixed64,4,opt,name=tx,proto3" json:"tx,omitempty"` + Rx float64 `protobuf:"fixed64,5,opt,name=rx,proto3" json:"rx,omitempty"` +} + +func (x *NodeEnergy) Reset() { + *x = NodeEnergy{} + if protoimpl.UnsafeEnabled { + mi := &file_visualize_grpc_proto_msgTypes[27] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NodeEnergy) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NodeEnergy) ProtoMessage() {} + +func (x *NodeEnergy) ProtoReflect() protoreflect.Message { + mi := &file_visualize_grpc_proto_msgTypes[27] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NodeEnergy.ProtoReflect.Descriptor instead. +func (*NodeEnergy) Descriptor() ([]byte, []int) { + return file_visualize_grpc_proto_rawDescGZIP(), []int{27} +} + +func (x *NodeEnergy) GetNodeId() int32 { + if x != nil { + return x.NodeId + } + return 0 +} + +func (x *NodeEnergy) GetDisabled() float64 { + if x != nil { + return x.Disabled + } + return 0 +} + +func (x *NodeEnergy) GetSleep() float64 { + if x != nil { + return x.Sleep + } + return 0 +} + +func (x *NodeEnergy) GetTx() float64 { + if x != nil { + return x.Tx + } + return 0 +} + +func (x *NodeEnergy) GetRx() float64 { + if x != nil { + return x.Rx + } + return 0 +} + type CommandRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1963,7 +2037,7 @@ type CommandRequest struct { func (x *CommandRequest) Reset() { *x = CommandRequest{} if protoimpl.UnsafeEnabled { - mi := &file_visualize_grpc_proto_msgTypes[27] + mi := &file_visualize_grpc_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1976,7 +2050,7 @@ func (x *CommandRequest) String() string { func (*CommandRequest) ProtoMessage() {} func (x *CommandRequest) ProtoReflect() protoreflect.Message { - mi := &file_visualize_grpc_proto_msgTypes[27] + mi := &file_visualize_grpc_proto_msgTypes[28] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1989,7 +2063,7 @@ func (x *CommandRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CommandRequest.ProtoReflect.Descriptor instead. func (*CommandRequest) Descriptor() ([]byte, []int) { - return file_visualize_grpc_proto_rawDescGZIP(), []int{27} + return file_visualize_grpc_proto_rawDescGZIP(), []int{28} } func (x *CommandRequest) GetCommand() string { @@ -2010,7 +2084,7 @@ type CommandResponse struct { func (x *CommandResponse) Reset() { *x = CommandResponse{} if protoimpl.UnsafeEnabled { - mi := &file_visualize_grpc_proto_msgTypes[28] + mi := &file_visualize_grpc_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2023,7 +2097,7 @@ func (x *CommandResponse) String() string { func (*CommandResponse) ProtoMessage() {} func (x *CommandResponse) ProtoReflect() protoreflect.Message { - mi := &file_visualize_grpc_proto_msgTypes[28] + mi := &file_visualize_grpc_proto_msgTypes[29] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2036,7 +2110,7 @@ func (x *CommandResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CommandResponse.ProtoReflect.Descriptor instead. func (*CommandResponse) Descriptor() ([]byte, []int) { - return file_visualize_grpc_proto_rawDescGZIP(), []int{28} + return file_visualize_grpc_proto_rawDescGZIP(), []int{29} } func (x *CommandResponse) GetOutput() []string { @@ -2058,7 +2132,7 @@ type ReplayEntry struct { func (x *ReplayEntry) Reset() { *x = ReplayEntry{} if protoimpl.UnsafeEnabled { - mi := &file_visualize_grpc_proto_msgTypes[29] + mi := &file_visualize_grpc_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2071,7 +2145,7 @@ func (x *ReplayEntry) String() string { func (*ReplayEntry) ProtoMessage() {} func (x *ReplayEntry) ProtoReflect() protoreflect.Message { - mi := &file_visualize_grpc_proto_msgTypes[29] + mi := &file_visualize_grpc_proto_msgTypes[30] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2084,7 +2158,7 @@ func (x *ReplayEntry) ProtoReflect() protoreflect.Message { // Deprecated: Use ReplayEntry.ProtoReflect.Descriptor instead. func (*ReplayEntry) Descriptor() ([]byte, []int) { - return file_visualize_grpc_proto_rawDescGZIP(), []int{29} + return file_visualize_grpc_proto_rawDescGZIP(), []int{30} } func (x *ReplayEntry) GetTimestamp() uint64 { @@ -2110,7 +2184,7 @@ type Empty struct { func (x *Empty) Reset() { *x = Empty{} if protoimpl.UnsafeEnabled { - mi := &file_visualize_grpc_proto_msgTypes[30] + mi := &file_visualize_grpc_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2123,7 +2197,7 @@ func (x *Empty) String() string { func (*Empty) ProtoMessage() {} func (x *Empty) ProtoReflect() protoreflect.Message { - mi := &file_visualize_grpc_proto_msgTypes[30] + mi := &file_visualize_grpc_proto_msgTypes[31] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2136,7 +2210,7 @@ func (x *Empty) ProtoReflect() protoreflect.Message { // Deprecated: Use Empty.ProtoReflect.Descriptor instead. func (*Empty) Descriptor() ([]byte, []int) { - return file_visualize_grpc_proto_rawDescGZIP(), []int{30} + return file_visualize_grpc_proto_rawDescGZIP(), []int{31} } var File_visualize_grpc_proto protoreflect.FileDescriptor @@ -2385,42 +2459,53 @@ var file_visualize_grpc_proto_rawDesc = []byte{ 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x72, 0x65, 0x61, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x22, 0x2a, 0x0a, 0x0e, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, - 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x22, 0x29, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6f, - 0x75, 0x74, 0x70, 0x75, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x75, 0x74, - 0x70, 0x75, 0x74, 0x22, 0x64, 0x0a, 0x0b, 0x52, 0x65, 0x70, 0x6c, 0x61, 0x79, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x12, 0x37, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x21, 0x2e, 0x76, 0x69, 0x73, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x5f, 0x67, 0x72, 0x70, 0x63, - 0x5f, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x45, 0x76, 0x65, - 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, - 0x74, 0x79, 0x2a, 0x98, 0x01, 0x0a, 0x0c, 0x4f, 0x74, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x52, - 0x6f, 0x6c, 0x65, 0x12, 0x1b, 0x0a, 0x17, 0x4f, 0x54, 0x5f, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, - 0x5f, 0x52, 0x4f, 0x4c, 0x45, 0x5f, 0x44, 0x49, 0x53, 0x41, 0x42, 0x4c, 0x45, 0x44, 0x10, 0x00, - 0x12, 0x1b, 0x0a, 0x17, 0x4f, 0x54, 0x5f, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x52, 0x4f, - 0x4c, 0x45, 0x5f, 0x44, 0x45, 0x54, 0x41, 0x43, 0x48, 0x45, 0x44, 0x10, 0x01, 0x12, 0x18, 0x0a, - 0x14, 0x4f, 0x54, 0x5f, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x52, 0x4f, 0x4c, 0x45, 0x5f, - 0x43, 0x48, 0x49, 0x4c, 0x44, 0x10, 0x02, 0x12, 0x19, 0x0a, 0x15, 0x4f, 0x54, 0x5f, 0x44, 0x45, - 0x56, 0x49, 0x43, 0x45, 0x5f, 0x52, 0x4f, 0x4c, 0x45, 0x5f, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x52, - 0x10, 0x03, 0x12, 0x19, 0x0a, 0x15, 0x4f, 0x54, 0x5f, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, - 0x52, 0x4f, 0x4c, 0x45, 0x5f, 0x4c, 0x45, 0x41, 0x44, 0x45, 0x52, 0x10, 0x04, 0x32, 0xbf, 0x01, - 0x0a, 0x14, 0x56, 0x69, 0x73, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x47, 0x72, 0x70, 0x63, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x55, 0x0a, 0x09, 0x56, 0x69, 0x73, 0x75, 0x61, 0x6c, - 0x69, 0x7a, 0x65, 0x12, 0x23, 0x2e, 0x76, 0x69, 0x73, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x5f, - 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x75, 0x61, 0x6c, 0x69, 0x7a, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x76, 0x69, 0x73, 0x75, 0x61, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x22, 0x77, 0x0a, 0x0a, + 0x4e, 0x6f, 0x64, 0x65, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, + 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6e, 0x6f, 0x64, + 0x65, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x08, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, + 0x14, 0x0a, 0x05, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, + 0x73, 0x6c, 0x65, 0x65, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x01, 0x52, 0x02, 0x74, 0x78, 0x12, 0x0e, 0x0a, 0x02, 0x72, 0x78, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x01, 0x52, 0x02, 0x72, 0x78, 0x22, 0x2a, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x22, 0x29, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x22, 0x64, 0x0a, 0x0b, + 0x52, 0x65, 0x70, 0x6c, 0x61, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, + 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x37, 0x0a, 0x05, 0x65, 0x76, 0x65, + 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x76, 0x69, 0x73, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x5f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, - 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x12, 0x50, 0x0a, - 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x21, 0x2e, 0x76, 0x69, 0x73, 0x75, 0x61, - 0x6c, 0x69, 0x7a, 0x65, 0x5f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x76, 0x69, - 0x73, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x5f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76, 0x65, + 0x6e, 0x74, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x2a, 0x98, 0x01, 0x0a, 0x0c, + 0x4f, 0x74, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x1b, 0x0a, 0x17, + 0x4f, 0x54, 0x5f, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x52, 0x4f, 0x4c, 0x45, 0x5f, 0x44, + 0x49, 0x53, 0x41, 0x42, 0x4c, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1b, 0x0a, 0x17, 0x4f, 0x54, 0x5f, + 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x52, 0x4f, 0x4c, 0x45, 0x5f, 0x44, 0x45, 0x54, 0x41, + 0x43, 0x48, 0x45, 0x44, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x4f, 0x54, 0x5f, 0x44, 0x45, 0x56, + 0x49, 0x43, 0x45, 0x5f, 0x52, 0x4f, 0x4c, 0x45, 0x5f, 0x43, 0x48, 0x49, 0x4c, 0x44, 0x10, 0x02, + 0x12, 0x19, 0x0a, 0x15, 0x4f, 0x54, 0x5f, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x52, 0x4f, + 0x4c, 0x45, 0x5f, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x52, 0x10, 0x03, 0x12, 0x19, 0x0a, 0x15, 0x4f, + 0x54, 0x5f, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x52, 0x4f, 0x4c, 0x45, 0x5f, 0x4c, 0x45, + 0x41, 0x44, 0x45, 0x52, 0x10, 0x04, 0x32, 0xbf, 0x01, 0x0a, 0x14, 0x56, 0x69, 0x73, 0x75, 0x61, + 0x6c, 0x69, 0x7a, 0x65, 0x47, 0x72, 0x70, 0x63, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x55, 0x0a, 0x09, 0x56, 0x69, 0x73, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x12, 0x23, 0x2e, 0x76, + 0x69, 0x73, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x5f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, + 0x2e, 0x56, 0x69, 0x73, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x21, 0x2e, 0x76, 0x69, 0x73, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x5f, 0x67, 0x72, + 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x12, 0x50, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x12, 0x21, 0x2e, 0x76, 0x69, 0x73, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x5f, 0x67, 0x72, + 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x76, 0x69, 0x73, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, + 0x5f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x68, 0x72, 0x65, 0x61, + 0x64, 0x2f, 0x6f, 0x74, 0x2d, 0x6e, 0x73, 0x2f, 0x76, 0x69, 0x73, 0x75, 0x61, 0x6c, 0x69, 0x7a, + 0x65, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -2436,7 +2521,7 @@ func file_visualize_grpc_proto_rawDescGZIP() []byte { } var file_visualize_grpc_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_visualize_grpc_proto_msgTypes = make([]protoimpl.MessageInfo, 31) +var file_visualize_grpc_proto_msgTypes = make([]protoimpl.MessageInfo, 32) var file_visualize_grpc_proto_goTypes = []interface{}{ (OtDeviceRole)(0), // 0: visualize_grpc_pb.OtDeviceRole (*VisualizeRequest)(nil), // 1: visualize_grpc_pb.VisualizeRequest @@ -2466,10 +2551,11 @@ var file_visualize_grpc_proto_goTypes = []interface{}{ (*SetTitleEvent)(nil), // 25: visualize_grpc_pb.SetTitleEvent (*SetNodeModeEvent)(nil), // 26: visualize_grpc_pb.SetNodeModeEvent (*SetNetworkInfoEvent)(nil), // 27: visualize_grpc_pb.SetNetworkInfoEvent - (*CommandRequest)(nil), // 28: visualize_grpc_pb.CommandRequest - (*CommandResponse)(nil), // 29: visualize_grpc_pb.CommandResponse - (*ReplayEntry)(nil), // 30: visualize_grpc_pb.ReplayEntry - (*Empty)(nil), // 31: visualize_grpc_pb.Empty + (*NodeEnergy)(nil), // 28: visualize_grpc_pb.NodeEnergy + (*CommandRequest)(nil), // 29: visualize_grpc_pb.CommandRequest + (*CommandResponse)(nil), // 30: visualize_grpc_pb.CommandResponse + (*ReplayEntry)(nil), // 31: visualize_grpc_pb.ReplayEntry + (*Empty)(nil), // 32: visualize_grpc_pb.Empty } var file_visualize_grpc_proto_depIdxs = []int32{ 21, // 0: visualize_grpc_pb.VisualizeEvent.add_node:type_name -> visualize_grpc_pb.AddNodeEvent @@ -2500,9 +2586,9 @@ var file_visualize_grpc_proto_depIdxs = []int32{ 22, // 25: visualize_grpc_pb.SetNodeModeEvent.node_mode:type_name -> visualize_grpc_pb.NodeMode 2, // 26: visualize_grpc_pb.ReplayEntry.event:type_name -> visualize_grpc_pb.VisualizeEvent 1, // 27: visualize_grpc_pb.VisualizeGrpcService.Visualize:input_type -> visualize_grpc_pb.VisualizeRequest - 28, // 28: visualize_grpc_pb.VisualizeGrpcService.Command:input_type -> visualize_grpc_pb.CommandRequest + 29, // 28: visualize_grpc_pb.VisualizeGrpcService.Command:input_type -> visualize_grpc_pb.CommandRequest 2, // 29: visualize_grpc_pb.VisualizeGrpcService.Visualize:output_type -> visualize_grpc_pb.VisualizeEvent - 29, // 30: visualize_grpc_pb.VisualizeGrpcService.Command:output_type -> visualize_grpc_pb.CommandResponse + 30, // 30: visualize_grpc_pb.VisualizeGrpcService.Command:output_type -> visualize_grpc_pb.CommandResponse 29, // [29:31] is the sub-list for method output_type 27, // [27:29] is the sub-list for method input_type 27, // [27:27] is the sub-list for extension type_name @@ -2841,7 +2927,7 @@ func file_visualize_grpc_proto_init() { } } file_visualize_grpc_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CommandRequest); i { + switch v := v.(*NodeEnergy); i { case 0: return &v.state case 1: @@ -2853,7 +2939,7 @@ func file_visualize_grpc_proto_init() { } } file_visualize_grpc_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CommandResponse); i { + switch v := v.(*CommandRequest); i { case 0: return &v.state case 1: @@ -2865,7 +2951,7 @@ func file_visualize_grpc_proto_init() { } } file_visualize_grpc_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReplayEntry); i { + switch v := v.(*CommandResponse); i { case 0: return &v.state case 1: @@ -2877,6 +2963,18 @@ func file_visualize_grpc_proto_init() { } } file_visualize_grpc_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReplayEntry); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_visualize_grpc_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Empty); i { case 0: return &v.state @@ -2920,7 +3018,7 @@ func file_visualize_grpc_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_visualize_grpc_proto_rawDesc, NumEnums: 1, - NumMessages: 31, + NumMessages: 32, NumExtensions: 0, NumServices: 1, }, diff --git a/visualize/grpc/pb/visualize_grpc.proto b/visualize/grpc/pb/visualize_grpc.proto index e9366834..89ec769d 100644 --- a/visualize/grpc/pb/visualize_grpc.proto +++ b/visualize/grpc/pb/visualize_grpc.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2020, The OTNS Authors. +// Copyright (c) 2022, The OTNS Authors. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -200,6 +200,14 @@ message SetNetworkInfoEvent { string commit = 3; } +message NodeEnergy { + int32 node_id = 1; + double disabled = 2; + double sleep = 3; + double tx = 4; + double rx = 5; +} + message CommandRequest { string command = 1; }