场景循环次数设置
This commit is contained in:
parent
bace8219ae
commit
d72a3a4700
13
lib/robot.go
13
lib/robot.go
@ -43,7 +43,7 @@ type Robot struct {
|
||||
config *storage.Config //配置
|
||||
resultCh chan *CallResult //请求结果通道
|
||||
sceneResultCh chan *CallResult //场景结果通道
|
||||
ReportMap map[int]map[string]*Statistics //测试报告 key1:场景 key2:协议
|
||||
ReportMap map[int]map[string]*Statistics //测试报告 key1:场景序号 key2:协议
|
||||
elipseTotal time.Duration
|
||||
}
|
||||
|
||||
@ -146,8 +146,15 @@ func (a *Robot) SetScenes(scenes []IScene) {
|
||||
for _, v := range scenes {
|
||||
info := v.Info()
|
||||
if conf.Name == info.Name {
|
||||
a.sceneQueue.Add(v)
|
||||
continue
|
||||
if conf.Loop == 0 || conf.Loop == 1 {
|
||||
a.sceneQueue.Add(v)
|
||||
continue
|
||||
} else if conf.Loop > 1 {
|
||||
for i := int32(0); i < conf.Loop; i++ {
|
||||
a.sceneQueue.Add(v)
|
||||
}
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
main.go
2
main.go
@ -66,7 +66,7 @@ func setupLogger() (err error) {
|
||||
// FullTimestamp: true,
|
||||
})
|
||||
|
||||
logrus.SetLevel(logrus.InfoLevel)
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
logrus.SetOutput(os.Stdout)
|
||||
|
||||
file, err := os.OpenFile("robot.log", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666)
|
||||
|
@ -11,8 +11,8 @@ type Config struct {
|
||||
}
|
||||
|
||||
type Global struct {
|
||||
UserCount uint32 `json:"UserCount,omitempty"` //用户数(每次压入的数量)
|
||||
UserCountTotal uint32 `json:"UserCountTotal,omitempty"` //用户总数(压入的总数)
|
||||
UserCount uint32 `json:"UserCount,omitempty"` //用户数(每次压入的数量)
|
||||
UserCountTotal uint32 `json:"UserCountTotal,omitempty"` //用户总数(压入的总数)
|
||||
SId string `json:"sid,omitempty"` //区服ID
|
||||
WsAddr string `json:"wsAddr,omitempty"` //websocket addr
|
||||
IntervalS int32 `json:"intervalS,omitempty"` //间隔时间s(每次压入用户的间隔时间)
|
||||
@ -26,6 +26,7 @@ type Scene struct {
|
||||
Callers []*Caller `json:"callers,omitempty"` //调用器列表
|
||||
Status uint32 `json:"status,omitempty"` //是否启用 默认0未启用 1是启用
|
||||
Num int `json:"num,omitempty"` //顺序号
|
||||
Loop int32 `json:"loop,omitempty"` //循环次数
|
||||
}
|
||||
|
||||
type Caller struct {
|
||||
|
@ -611,7 +611,7 @@ func (mw *MainWindow) newSceneContainer() {
|
||||
//场景按钮
|
||||
addSceneBtn := widget.NewButtonWithIcon("添加场景", theme.ContentAddIcon(), nil)
|
||||
deleSceneBtn := widget.NewButtonWithIcon("删除场景", theme.DeleteIcon(), nil)
|
||||
setNumBtn := widget.NewButtonWithIcon("设置序号", theme.ListIcon(), nil)
|
||||
setBtn := widget.NewButtonWithIcon("场景配置", theme.ListIcon(), nil)
|
||||
|
||||
//search
|
||||
searchEntry := widget.NewEntry()
|
||||
@ -642,7 +642,7 @@ func (mw *MainWindow) newSceneContainer() {
|
||||
if len(selectedSceneList.CachedList.Items) == 0 {
|
||||
dynamic = container.NewCenter(widget.NewLabel("还没有选择任何场景"))
|
||||
} else {
|
||||
dynamic = container.NewBorder(container.NewHBox(setNumBtn, deleSceneBtn, layout.NewSpacer()), nil, nil, nil, selectedSceneList.ListWidget)
|
||||
dynamic = container.NewBorder(container.NewHBox(setBtn, deleSceneBtn, layout.NewSpacer()), nil, nil, nil, selectedSceneList.ListWidget)
|
||||
}
|
||||
}
|
||||
|
||||
@ -729,8 +729,8 @@ func (mw *MainWindow) newSceneContainer() {
|
||||
}
|
||||
}
|
||||
|
||||
// 设置序号事件
|
||||
setNumBtn.OnTapped = func() {
|
||||
// 场景配置事件
|
||||
setBtn.OnTapped = func() {
|
||||
selId := selectedSceneList.SelectedId()
|
||||
if selId == "" {
|
||||
ShowTip("请选择一个场景")
|
||||
@ -739,8 +739,12 @@ func (mw *MainWindow) newSceneContainer() {
|
||||
sceneNumEntry := widget.NewEntry()
|
||||
sceneNumEntry.Text = "0"
|
||||
|
||||
sceneLoopEntry := widget.NewEntry()
|
||||
sceneLoopEntry.Text = "1"
|
||||
|
||||
sceneItems := []*widget.FormItem{
|
||||
widget.NewFormItem("顺序号", sceneNumEntry),
|
||||
widget.NewFormItem("执行次数", sceneLoopEntry),
|
||||
}
|
||||
|
||||
// 加载
|
||||
@ -752,15 +756,25 @@ func (mw *MainWindow) newSceneContainer() {
|
||||
}
|
||||
if sceneConf != nil {
|
||||
sceneNumEntry.Text = cast.ToString(sceneConf.Num)
|
||||
if sceneConf.Loop == 0 {
|
||||
sceneLoopEntry.Text = "1"
|
||||
} else {
|
||||
sceneLoopEntry.Text = cast.ToString(sceneConf.Loop)
|
||||
}
|
||||
}
|
||||
|
||||
editSceneWin := dialog.NewForm("编辑场景序号", "确定", "取消", sceneItems, func(b bool) {
|
||||
if !b {
|
||||
return
|
||||
}
|
||||
if cast.ToInt(sceneNumEntry.Text) < 0 {
|
||||
ShowTip("顺序号必须大于0")
|
||||
return
|
||||
}
|
||||
for _, item := range mw.config.Scenes {
|
||||
if item.ID == selId {
|
||||
item.Num = cast.ToInt(sceneNumEntry.Text)
|
||||
item.Loop = cast.ToInt32(sceneLoopEntry.Text)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user