当前位置: 首页>>代码示例>>Golang>>正文


Golang Setting.GetSetting方法代码示例

本文整理汇总了Golang中github.com/grayzone/devicemonitor/conn.Setting.GetSetting方法的典型用法代码示例。如果您正苦于以下问题:Golang Setting.GetSetting方法的具体用法?Golang Setting.GetSetting怎么用?Golang Setting.GetSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/grayzone/devicemonitor/conn.Setting的用法示例。


在下文中一共展示了Setting.GetSetting方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: generator

func generator(t time.Duration) {
	for {
		var s conn.Setting
		s.GetSetting()
		if s.Isconnected {
			var k ftprotocol.KeepAlive
			k.SessionKey = []byte(s.Sessionkey)
			k.Sequence = byte(s.Sequence[0])

			//			log.Printf("session key : %X, sequence : %X\n", k.SessionKey, k.Sequence)

			//		log.Printf("send keepalive : %X", k.Message())

			var m conn.Message
			m.Messagetype = conn.REQUEST
			m.Info = hex.EncodeToString(k.Message())
			m.Status = conn.NONE

			m.InsertMessage()

			//			sequence = IncreaseSeq(sequence)

		}

		time.Sleep(time.Millisecond * time.Duration(t))
		//		time.Sleep(time.Millisecond * time.Duration(s.Writeinterval))

	}

}
开发者ID:grayzone,项目名称:devicemonitor,代码行数:30,代码来源:devicemonitor.go

示例2: IncreaseOneSequence

func IncreaseOneSequence() {
	var s conn.Setting
	s.GetSetting()
	//	log.Printf(" seq  :%x", byte(s.Sequence[0]))
	s.Sequence = string(IncreaseSeq(byte(s.Sequence[0])))
	//	log.Printf("Sequence : %s", s.Sequence)
	s.UpdateSequence()
}
开发者ID:grayzone,项目名称:devicemonitor,代码行数:8,代码来源:devicemonitor.go

示例3: SendPwdKey

func (c *MesssageController) SendPwdKey() {

	messageid := ftprotocol.SCREENPRESS
	var setting conn.Setting
	setting.GetSetting()

	switch messageid {
	case ftprotocol.SCREENPRESS:
		var g ftprotocol.ScreenPress

		g.SessionKey = []byte(strings.ToUpper(setting.Sessionkey))
		g.MessageID = []byte(strings.ToUpper(c.GetString("messageid")))
		g.Sequence = byte(setting.Sequence[0])

		screenid, _ := c.GetInt32("screenid")
		g.ScreenID = uint32(screenid)

		coorx, _ := c.GetInt32("coorx")
		g.X = uint32(coorx)

		coory, _ := c.GetInt32("coory")
		g.Y = uint32(coory)

		//		log.Println(g)

		out := g.Message()

		//		log.Println(out)

		var m conn.Message
		m.Messagetype = conn.REQUEST
		m.Info = hex.EncodeToString(out)
		m.Status = conn.NONE
		log.Println(m.Info)

		m.InsertMessage()

		c.Ctx.WriteString("ok")

	default:
		c.Ctx.WriteString("Invalid Message")

	}

}
开发者ID:grayzone,项目名称:deviceviewer,代码行数:45,代码来源:default.go

示例4: UpdateSetting

func (c *MesssageController) UpdateSetting() {

	var s conn.Setting
	s.GetSetting()
	result := make(map[string]string)

	result["sessionkey"] = string(s.Sessionkey)
	result["sequence"] = string(s.Sequence)

	result["deviceid"] = strconv.Itoa(int(s.Deviceid))
	result["protocolver"] = s.Protocolver
	result["sessionstatus"] = strconv.Itoa(int(s.Sessionstatus))
	result["sessiontimeout"] = strconv.Itoa(int(s.Sessiontimeout))
	result["messagetimeout"] = strconv.Itoa(int(s.Messagetimeout))
	result["maxretrycount"] = strconv.Itoa(int(s.Maxretrycount))
	result["devicename"] = s.Devicename
	result["sensorbroadcastperiod"] = strconv.Itoa(int(s.Sensorbroadcastperiod))

	js, _ := json.Marshal(result)

	c.Ctx.WriteString(string(js))

}
开发者ID:grayzone,项目名称:deviceviewer,代码行数:23,代码来源:default.go

示例5: writer

func writer(t time.Duration) {
	// get one request
	for {
		var s conn.Setting
		s.GetSetting()
		//		time.Sleep(time.Millisecond * time.Duration(s.Writeinterval))
		time.Sleep(time.Millisecond * time.Duration(t))
		if s.Isconnected {
			var m conn.Message
			err := m.GetOneRequest()
			if err != nil {
				//				log.Println("writer:", err.Error())
				continue
			}

			//			log.Printf("get one request :%v", m)

			b, _ := hex.DecodeString(m.Info)
			err = comm.Writer(b)
			if err != nil {
				log.Println(err.Error())
				continue
			}
			log.Printf("Send:%X", b)
			IncreaseOneSequence()

			if bSoftDelete {
				m.Status = conn.DELETED
				m.UpdateStatus()
			} else {
				m.DeleteMessage()
				//		log.Println("the request is deleted.")
			}
		}

	}
}
开发者ID:grayzone,项目名称:devicemonitor,代码行数:37,代码来源:devicemonitor.go

示例6: Generate

func (c *MesssageController) Generate() {
	messageid, _ := strconv.ParseInt(c.GetString("messageid"), 16, 64)
	var setting conn.Setting
	setting.GetSetting()

	switch messageid {
	case ftprotocol.REQUESTSESSION:
		var rs ftprotocol.RequestSession
		//	rs.SessionKey, _ = hex.DecodeString(c.GetString("sessionkey"))

		//	rs.SessionKey = []byte(strings.ToUpper(c.GetString("sessionkey")))
		rs.SessionKey = []byte(strings.ToUpper(setting.Sessionkey))

		//	beego.Debug("SessionKey", rs.SessionKey)
		//	rs.MessageID, _ = hex.DecodeString(c.GetString("messageid"))
		rs.MessageID = []byte(strings.ToUpper(c.GetString("messageid")))
		//		beego.Debug("MessageID", rs.MessageID)
		//		rs.Sequence = byte(c.GetString("sequence")[0])
		rs.Sequence = byte(setting.Sequence[0])

		//		beego.Debug("Sequence", c.GetString("sequence"), []byte(c.GetString("sequence")))

		deviceid, _ := strconv.ParseUint(c.GetString("deviceid"), 16, 32)

		rs.DeviceID = uint32(deviceid)

		protocalver, _ := c.GetInt32("protocolver")
		rs.ProtocolVersion = uint32(protocalver)

		rs.NoAck = true

		out := rs.Message()
		//		beego.Debug(out)
		c.Ctx.WriteString(hex.EncodeToString(out))

	case ftprotocol.GETSENSOR:
		var g ftprotocol.GetSensor

		g.SessionKey = []byte(strings.ToUpper(setting.Sessionkey))
		g.MessageID = []byte(strings.ToUpper(c.GetString("messageid")))
		g.Sequence = byte(setting.Sequence[0])

		g.IsBroadcast, _ = c.GetBool("bbroadcastperiod")

		bpvalue, _ := c.GetInt32("broadcastperiodvalue")
		g.Broadcastperiod = uint32(bpvalue)
		g.IsAllSensorData, _ = c.GetBool("isallsensordata")

		//		log.Printf("%v, %d, %v", g.IsBroadcast, g.Broadcastperiod, g.IsAllSensorData)

		out := g.Message()
		c.Ctx.WriteString(hex.EncodeToString(out))

	case ftprotocol.KEEPALIVE:
		var ka ftprotocol.KeepAlive
		/*
			ka.SessionKey = []byte(strings.ToUpper(c.GetString("sessionkey")))
			ka.Sequence = byte(c.GetString("sequence")[0])
			ka.MessageID = []byte(strings.ToUpper(c.GetString("messageid")))
		*/
		ka.SessionKey = []byte(strings.ToUpper(setting.Sessionkey))
		ka.MessageID = []byte(strings.ToUpper(c.GetString("messageid")))
		ka.Sequence = byte(setting.Sequence[0])

		out := ka.Message()
		//      beego.Debug(out)
		c.Ctx.WriteString(hex.EncodeToString(out))

	case ftprotocol.GETRUNTIME:
		var g ftprotocol.GetRunTime
		/*
			g.SessionKey = []byte(strings.ToUpper(c.GetString("sessionkey")))
			g.Sequence = byte(c.GetString("sequence")[0])
			g.MessageID = []byte(strings.ToUpper(c.GetString("messageid")))
		*/
		g.SessionKey = []byte(strings.ToUpper(setting.Sessionkey))
		g.MessageID = []byte(strings.ToUpper(c.GetString("messageid")))
		g.Sequence = byte(setting.Sequence[0])

		out := g.Message()
		//      beego.Debug(out)
		c.Ctx.WriteString(hex.EncodeToString(out))
	case ftprotocol.DEVICENAMEREQUEST:
		var g ftprotocol.DeviceNameRequest
		/*
			g.SessionKey = []byte(strings.ToUpper(c.GetString("sessionkey")))
			g.Sequence = byte(c.GetString("sequence")[0])
			g.MessageID = []byte(strings.ToUpper(c.GetString("messageid")))
		*/
		g.SessionKey = []byte(strings.ToUpper(setting.Sessionkey))
		g.MessageID = []byte(strings.ToUpper(c.GetString("messageid")))
		g.Sequence = byte(setting.Sequence[0])

		out := g.Message()
		//      beego.Debug(out)
		c.Ctx.WriteString(hex.EncodeToString(out))
	case ftprotocol.GETVERSIONSREQUEST:
		var g ftprotocol.GetVersionsRequest
		/*
			g.SessionKey = []byte(strings.ToUpper(c.GetString("sessionkey")))
//.........这里部分代码省略.........
开发者ID:grayzone,项目名称:deviceviewer,代码行数:101,代码来源:default.go


注:本文中的github.com/grayzone/devicemonitor/conn.Setting.GetSetting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。