| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587 |
- package protocol
- import "time"
- //数据上报类:
- type QueryType uint8
- const (
- QT_STATUSINFO QueryType = iota //led内存、磁盘上报(平台主动,终端被动,调试用)
- QT_RESOLUTION //led分辨率上报(平台主动,终端被动)
- QT_POWERSTATUS //led开关机状态上报(1、有变化才上报;2、平台查询上报)
- QT_IFSTATUSS //led接口状态上报(平台主动,终端被动)
- QT_NETWORK //led网络状态上报(平台主动,终端被动)
- QT_PLAYINGINFO //led当前播放的节目上报(1、节目有变化才上报;2平台查询上报)
- QT_BRIGHTNESSCOLORTEMP //led音量、色温、亮度上报(平台主动,终端被动)
- QT_VOLUME //led音量、色温、亮度上报(平台主动,终端被动)
- QT_NTP //NTP配置上报(平台主动,终端被动)
- QT_ACCOUNT //led账户信息上报(平台主动,终端被动)
- QT_VSNS //led所有节目上报(平台主动,终端被动)
- QT_SCREENSHOT //led截屏(平台主动,终端被动)
- QT_LOCALE //led系统区域和语言(平台主动,终端被动)
- QT_RTCTIME //ledRTC时间
- QT_PGMS //查询节目
- QT_SCHEDULE //查询排程
- )
- type QType struct {
- Flag QueryType `json:"flag"` //查询类型标识
- State uint8
- }
- type LedState struct {
- Time string `json:"time"`
- State uint8 `json:"state"` //0 在线,1离线
- }
- type Pack_LedState struct {
- Header
- Data LedState `json:"data"`
- }
- func (o Pack_LedState) EnCode(id string, gid string, seq uint64, changetime time.Time, state uint8) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data.Time = changetime.Format("2006-01-02 15:04:05")
- o.Data.State = state
- return json.MarshalToString(o)
- }
- func (o *Pack_LedState) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type Pack_QueryInfo struct {
- Header
- Data QType `json:"data"`
- }
- func (o *Pack_QueryInfo) EnCode(id, gid string, seq uint64, flag QueryType) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data.Flag = flag
- return json.MarshalToString(o)
- }
- func (o *Pack_QueryInfo) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type Pack_StatusInfo struct {
- Header
- Data StatusInfo `json:"data"`
- }
- func (o *Pack_StatusInfo) EnCode(id, gid string, seq uint64, si *StatusInfo) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data = *si
- return json.MarshalToString(o)
- }
- func (o *Pack_StatusInfo) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type Pack_Resolution struct {
- Header
- Data Resolution `json:"data"`
- }
- func (o *Pack_Resolution) EnCode(id, gid string, seq uint64, r *Resolution) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data = *r
- return json.MarshalToString(o)
- }
- func (o *Pack_Resolution) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type PowerstatusData struct {
- Powerstatus uint8 `json:"powerstatus"`
- }
- type Pack_PowerStatus struct {
- Header
- Data PowerstatusData `json:"data"`
- }
- func (o *Pack_PowerStatus) EnCode(id, gid string, seq uint64, powerstatus int) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data.Powerstatus = uint8(powerstatus)
- return json.MarshalToString(o)
- }
- func (o *Pack_PowerStatus) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type Pack_IFStatuss struct {
- Header
- Data IFStatuss `json:"data"`
- }
- func (o *Pack_IFStatuss) EnCode(id, gid string, seq uint64, ifs *IFStatuss) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data = *ifs
- return json.MarshalToString(o)
- }
- func (o *Pack_IFStatuss) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type Pack_PlayingInfo struct {
- Header
- Data PlayingInfo `json:"data"`
- }
- func (o *Pack_PlayingInfo) EnCode(id, gid string, seq uint64, pi *PlayingInfo) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data = *pi
- return json.MarshalToString(o)
- }
- func (o *Pack_PlayingInfo) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type Pack_BrightnessColortemp struct {
- Header
- Data BrightnessColortemp `json:"data"`
- }
- func (o *Pack_BrightnessColortemp) EnCode(id, gid string, seq uint64, bc *BrightnessColortemp) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data = *bc
- return json.MarshalToString(o)
- }
- func (o *Pack_BrightnessColortemp) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type VolumeData struct {
- Volume uint8 `json:"volume"`
- }
- type Pack_VolumeData struct {
- Header
- Data VolumeData `json:"data"`
- }
- func (o *Pack_VolumeData) EnCode(id, gid string, seq uint64, volume int) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data.Volume = uint8(volume)
- return json.MarshalToString(o)
- }
- func (o *Pack_VolumeData) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type Pack_Ntp struct {
- Header
- Data Ntp `json:"data"`
- }
- func (o *Pack_Ntp) EnCode(id, gid string, seq uint64, ntp *Ntp) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data = *ntp
- return json.MarshalToString(o)
- }
- func (o *Pack_Ntp) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type Pack_Account struct {
- Header
- Data Account `json:"data"`
- }
- func (o *Pack_Account) EnCode(id, gid string, seq uint64, acc *Account) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data = *acc
- return json.MarshalToString(o)
- }
- func (o *Pack_Account) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type Pack_VSNS struct {
- Header
- Data VSNS `json:"data"`
- }
- func (o *Pack_VSNS) EnCode(id, gid string, seq uint64, vsns *VSNS) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data = *vsns
- return json.MarshalToString(o)
- }
- func (o *Pack_VSNS) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type Pack_Locale struct {
- Header
- Data Locale `json:"data"`
- }
- func (o *Pack_Locale) EnCode(id, gid string, seq uint64, lc *Locale) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data = *lc
- return json.MarshalToString(o)
- }
- func (o *Pack_Locale) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type Pack_RTCTime struct {
- Header
- Data RTCTime `json:"data"`
- }
- func (o *Pack_RTCTime) EnCode(id, gid string, seq uint64, rtc *RTCTime) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data = *rtc
- return json.MarshalToString(o)
- }
- func (o *Pack_RTCTime) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type BrightnessData struct {
- Brightness uint8 `json:"brightness"`
- }
- type Pack_BrightnessData struct {
- Header
- Data BrightnessData `json:"data"`
- }
- func (o *Pack_BrightnessData) EnCode(id, gid string, seq uint64, brightness int) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data.Brightness = uint8(brightness)
- return json.MarshalToString(o)
- }
- func (o *Pack_BrightnessData) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type ShowtoastData struct {
- Showtoast uint8 `json:"showtoast"`
- }
- type Pack_ShowtoastData struct {
- Header
- Data ShowtoastData `json:"data"`
- }
- func (o *Pack_ShowtoastData) EnCode(id, gid string, seq uint64, showtoast int) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data.Showtoast = uint8(showtoast)
- return json.MarshalToString(o)
- }
- func (o *Pack_ShowtoastData) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type CmdData struct {
- Cmd string `json:"cmd"`
- }
- type Pack_CmdData struct {
- Header
- Data CmdData `json:"data"`
- }
- func (o *Pack_CmdData) EnCode(id, gid string, seq uint64, cmd string) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data.Cmd = cmd
- return json.MarshalToString(o)
- }
- func (o *Pack_CmdData) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type ProgramData struct {
- Flag uint8 `json:"flag"` //flag=4清除缓存;flag=3清除节目缓存;flag=2清除节目;flag=1删除节目;flag=0切换节目
- Source string `json:"source"` //flag = 1或0时有效
- Vsn string `json:"vsn"` //flag = 1或0时有效
- }
- type Pack_ProgramData struct {
- Header
- Data ProgramData `json:"data"`
- }
- func (o *Pack_ProgramData) EnCode(id, gid string, seq uint64, flag uint8, source, vsn string) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data.Flag = flag
- o.Data.Source = source
- o.Data.Vsn = vsn
- return json.MarshalToString(o)
- }
- func (o *Pack_ProgramData) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type Host struct {
- Host string `json:"host"`
- }
- type Pack_Host struct {
- Header
- Data Host `json:"data"`
- }
- func (o *Pack_Host) EnCode(id, gid string, seq uint64, host string) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data.Host = host
- return json.MarshalToString(o)
- }
- func (o *Pack_Host) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type RetHost struct {
- StateError
- Host string `json:"host"`
- TTL float64 `json:"ttl"`
- }
- type Pack_RetHost struct {
- Header
- Data RetHost `json:"data"`
- }
- func (o *Pack_RetHost) EnCode(id, gid string, seq uint64, err error, host string, ttl float64) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data.SetStateErrorData(err)
- o.Data.Host = host
- o.Data.TTL = ttl
- return json.MarshalToString(o)
- }
- func (o *Pack_RetHost) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- type PubGPMS struct {
- Name string `json:"name"`
- Files []string `json:"files"`
- }
- type Pack_PubGPMS struct {
- Header
- Data []PubGPMS `json:"data"`
- }
- func (o *Pack_PubGPMS) EnCode(id, gid string, seq uint64, pgms []PubGPMS) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data = pgms
- return json.MarshalToString(o)
- }
- func (o *Pack_PubGPMS) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- //排程
- type CmdOperation struct {
- AuthorUrl string `json:"author_url,omitempty"`
- Method int `json:"method,omitempty"`
- Content string `json:"content,omitempty"`
- Source string `json:"source,omitempty"`
- Vsn string `json:"vsn,omitempty"`
- }
- type LimitDateTime struct {
- Start string `json:"start,omitempty"`
- End string `json:"end,omitempty"`
- StartTime string `json:"start_time,omitempty"`
- EndTime string `json:"end_time,omitempty"`
- }
- type CommandSchedule struct {
- Operation CmdOperation `json:"operation"`
- OpTime []string `json:"op_time"`
- IfLimitDate bool `json:"if_limit_date"`
- LimitDate LimitDateTime `json:"limit_date"`
- IfLimitWeekday bool `json:"if_limit_weekday"`
- LimitWeekday []bool `json:"limit_weekday"`
- Type string `json:"type"`
- }
- type Pack_CommandSchedule struct {
- Header
- Data []CommandSchedule `json:"data"`
- }
- func (o *Pack_CommandSchedule) EnCode(id, gid string, seq uint64, cmdSchedule []CommandSchedule) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data = cmdSchedule
- return json.MarshalToString(o)
- }
- func (o *Pack_CommandSchedule) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
- //info
- type Storage struct {
- Total uint `json:"total"`
- Free uint `json:"free"`
- }
- type PlayingInfo struct {
- Name string `json:"name"`
- Path string `json:"path"`
- Source string `json:"source"`
- }
- type InfoTag struct {
- Serialno string `json:"serialno"`
- Model string `json:"model"`
- Mem Storage `json:"mem"`
- Storage Storage `json:"storage"`
- Playing PlayingInfo `json:"playing"`
- }
- type StatusInfo struct {
- Info InfoTag `json:"info"`
- }
- //ifstatus
- type Peer struct {
- Ip string `json:"ip,omitempty"`
- Mac string `json:"mac,omitempty"`
- }
- type IPS struct {
- Broadcast string `json:"broadcast,omitempty"`
- Ip string `json:"ip,omitempty"`
- Mask string `json:"mask,omitempty"`
- Dns1 string `json:"dns1,omitempty"`
- Dns2 string `json:"dns2,omitempty"`
- Gateway string `json:"gateway,omitempty"`
- }
- type SSID struct {
- SSID string `json:"SSID,omitempty"`
- Pass string `json:"pass,omitempty"`
- Priority int `json:"priority,omitempty"`
- }
- type IFStatus struct {
- Type string `json:"type,omitempty"`
- Connected int `json:"connected,omitempty"`
- Enabled int `json:"enabled,omitempty"`
- Ips *IPS `json:"ips,omitempty"`
- Peers []Peer `json:"peers,omitempty"`
- SSID string `json:"SSID,omitempty"`
- Ssids []SSID `json:"ssids,omitempty"`
- Operstate string `json:"operstate,omitempty"`
- Pass string `json:"pass,omitempty"`
- Channel int `json:"channel,omitempty"`
- Carrier int `json:"carrier,omitempty"`
- Mode string `json:"mode,omitempty"`
- Mac string `json:"mac,omitempty"`
- Currentap string `json:"currentap,omitempty"`
- State string `json:"state,omitempty"`
- Speed int `json:"speed,omitempty"`
- Strength int `json:"strength,omitempty"`
- Log int `json:"log,omitempty"`
- Isstatic int `json:"isstatic,omitempty"`
- }
- type IFStatuss struct {
- Types []IFStatus `json:"types,omitempty"`
- }
- type RTCTime struct {
- Time string `json:"time"`
- Timezone string `json:"timezone"`
- Isautotimezone int `json:"isautotimezone"`
- Isautotime int `json:"isautotime"`
- }
- type Locale struct {
- Language string `json:"language"`
- Country string `json:"country"`
- }
- type Resolution struct {
- Width int `json:"width"`
- Height int `json:"height"`
- Hsync int `json:"hsync"`
- Dclk int `json:"dclk"`
- RealWidth int `json:"real_width"`
- RealHeight int `json:"real_height"`
- RealDclk int `json:"real_dclk"`
- Fps int `json:"fps"`
- }
- type BrightnessColortemp struct {
- Brightness int `json:"brightness"`
- Colortemp int `json:"colortemperature"`
- }
- type Ntp struct {
- Ntpserver string `json:"ntpserver"`
- Ntpinterval int `json:"ntpinterval"`
- Ntpthreshold int `json:"ntpthreshold"`
- }
- type Account struct {
- Name string `json:"name"`
- Password string `json:"password"`
- Url string `json:"url"`
- Devicestatus string `json:"devicestatus"`
- Internet bool `json:"internet"`
- Login bool `json:"login"`
- Reason string `json:"reason"`
- }
- //vsn
- type ContentTag struct {
- Md5 string `json:"md5,omitempty"`
- Name string `json:"name,omitempty"`
- Publishedmd5 string `json:"publishedmd5,omitempty"`
- Size uint `json:"size,omitempty"`
- }
- type Contents struct {
- Content []ContentTag `json:"content"`
- Ressize uint `json:"ressize,omitempty"`
- Type string `json:"type,omitempty"`
- Unused uint `json:"unused,omitempty"`
- }
- type Playing_Vsn struct {
- Name string `json:"name,omitempty"`
- Type string `json:"type,omitempty"`
- }
- type VSNS struct {
- Contents []Contents `json:"contents,omitempty"`
- Playing Playing_Vsn `json:"playing,omitempty"`
- }
- // CltledData 信息屏 数据
- type CltledData struct {
- Powerstatus int `json:"powerstatus"` //电源状态 1 0
- Musicvolume int `json:"musicvolume"` //音量
- Brightness int `json:"brightness"` //亮度
- Playing string `json:"playing"` //当前播放节目
- Colortemperature int `json:"colortemperature"` //色温
- SleepTime string `json:"sleepTime"` //关机时间
- WakeupTime string `json:"wakeupTime"` //开机时间
- RebootTime string `json:"rebootTime"` //重启时间
- RealWidth int `json:"real_width"` //宽度
- RealHeight int `json:"real_height"` //高度
- }
- type Pack_LedCltledData struct {
- Header
- Data CltledData `json:"data"`
- }
- func (o *Pack_LedCltledData) EnCode(id, gid string, seq uint64, r *CltledData) (string, error) {
- o.SetHeaderData(id, gid, seq)
- o.Data = *r
- return json.MarshalToString(o)
- }
- func (o *Pack_LedCltledData) DeCode(message string) error {
- return json.UnmarshalFromString(message, o)
- }
|