| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- package clt_client
- import (
- "encoding/json"
- "github.com/sirupsen/logrus"
- "lc/common/util"
- "os"
- "path"
- )
- var Pvsn Vsn
- var Tvsn TextVsn
- type Programm struct {
- Type string `json:"type"` //节目类型
- Name string `json:"name"` //节目名
- ImageInfo ImageInfo `json:"imageinfo"` //图片,视频资源url
- TextInfo Textinfo `json:"textinfo"` //文本内容
- }
- type Textinfo struct {
- Content string `json:"content"`
- LfFaceName string `json:"lfFaceName"`
- BackColor string `json:"backcolor"`
- TextColor string `json:"textcolor"`
- Duration string `json:"duration"`
- IsScroll string `json:"IsScroll"`
- Speed string `json:"Speed"` //滚动速度pixels/秒
- }
- type ImageInfo struct {
- Urls []string `json:"urls"`
- Duration string `json:"duration"`
- InEffect InEffect `json:"inEffect"`
- }
- // ListResp 查所有节目的响应结构体(只包含当前播放节目)
- type ListResp struct {
- Playing playing `json:"playing"`
- }
- type playing struct {
- Name string `json:"name"`
- Type string `json:"type"`
- }
- // LoadVsn 加载 vsn文件->结构体
- func (c cltclient) LoadVsn() {
- //open, _ := os.ReadFile(util.GetPath(0) + "picturevideo.vsn")
- //json.Unmarshal(open, &Pvsn)
- text, _ := os.ReadFile(util.GetPath(0) + "text.vsn")
- json.Unmarshal(text, &Tvsn)
- }
- func NewPVsn(pro Programm) []byte {
- var marshal []byte
- switch pro.Type {
- case "2":
- var v = NewVsn()
- v.Programs.Program.Pages[0].Regions[0].Items[0].Type = "2"
- v.Programs.Program.Pages[0].Regions[0].Items[0].FileSource.FilePath = ".\\" + pro.Name + ".files\\" + path.Base(pro.ImageInfo.Urls[0])
- v.Programs.Program.Pages[0].Regions[0].Items[0].FileSource.IsRelative = "1"
- items := v.Programs.Program.Pages[0].Regions[0].Items
- for i, va := range pro.ImageInfo.Urls {
- if i > 0 {
- item := Items{}
- item.Type = "2"
- item.FileSource.IsRelative = "1"
- item.FileSource.FilePath = ".\\" + pro.Name + ".files\\" + path.Base(va)
- if pro.ImageInfo.Duration != "" {
- item.Duration = pro.ImageInfo.Duration
- }
- if pro.ImageInfo.InEffect.Type != "" {
- item.InEffect.Type = pro.ImageInfo.InEffect.Type
- }
- if pro.ImageInfo.InEffect.Time != "" {
- item.InEffect.Time = pro.ImageInfo.InEffect.Time
- }
- items = append(items, item)
- v.Programs.Program.Pages[0].Regions[0].Items = items
- }
- }
- marshal, _ = json.Marshal(v)
- case "3":
- var v = NewVsn()
- v.Programs.Program.Pages[0].Regions[0].Items[0].Type = "3"
- v.Programs.Program.Pages[0].Regions[0].Items[0].Volume = "1.000000"
- v.Programs.Program.Pages[0].Regions[0].Items[0].FileSource.IsRelative = "1"
- v.Programs.Program.Pages[0].Regions[0].Items[0].ReserveAS = "0"
- v.Programs.Program.Pages[0].Regions[0].Rect.Width = "256"
- v.Programs.Program.Pages[0].Regions[0].Rect.Height = "256"
- v.Programs.Program.Pages[0].Regions[0].Items[0].FileSource.FilePath = ".\\" + pro.Name + ".files\\" + path.Base(pro.ImageInfo.Urls[0])
- marshal, _ = json.Marshal(v)
- case "4":
- fallthrough
- case "5":
- v := Tvsn
- v.Programs.Program.Pages[0].Regions[0].Items[0].Type = "5"
- if pro.TextInfo.BackColor != "" {
- v.Programs.Program.Pages[0].Regions[0].Items[0].BackColor = pro.TextInfo.BackColor
- }
- if pro.TextInfo.TextColor != "" {
- v.Programs.Program.Pages[0].Regions[0].Items[0].TextColor = pro.TextInfo.TextColor
- }
- if pro.TextInfo.LfFaceName != "" {
- v.Programs.Program.Pages[0].Regions[0].Items[0].LogFont.LfFaceName = pro.TextInfo.LfFaceName
- }
- if pro.TextInfo.Duration != "" {
- v.Programs.Program.Pages[0].Regions[0].Items[0].MultiPicInfo.OnePicDuration = pro.TextInfo.Duration
- }
- if pro.TextInfo.IsScroll != "" {
- v.Programs.Program.Pages[0].Regions[0].Items[0].IsScroll = pro.TextInfo.IsScroll
- }
- if pro.TextInfo.Speed != "" {
- v.Programs.Program.Pages[0].Regions[0].Items[0].Speed = pro.TextInfo.Speed
- }
- v.Programs.Program.Pages[0].Regions[0].Items[0].Text = pro.TextInfo.Content
- marshal, _ = json.Marshal(v)
- case "27":
- //v.Programs.Program.Pages[0].Regions[0].Items[0].Type = "27"
- //v.Programs.Program.Pages[0].Regions[0].Items[0].URL = pro.URL
- //v.Programs.Program.Pages[0].Name = pro.Name + ".vsn"
- //v.Programs.Program.Pages[0].AppointDuration = "3600000"
- //v.Programs.Program.Information.Width = "256"
- //v.Programs.Program.Information.Height = "256"
- //v.Programs.Program.Pages[0].Regions[0].Rect.Width = "128"
- //v.Programs.Program.Pages[0].Regions[0].Rect.Height = "128"
- //v.Programs.Program.Pages[0].LoopType = "1"
- default:
- logrus.Errorf("不支持的类型:%v", pro.Type)
- return nil
- }
- return marshal
- }
- // 图片/视频
- // Vsn vsn文件结构体
- type Vsn struct {
- Programs Programs `json:"Programs"`
- }
- type Rect struct {
- X string `json:"X"`
- Y string `json:"Y"`
- Width string `json:"Width"`
- Height string `json:"Height"`
- BorderWidth string `json:"BorderWidth"`
- BorderColor string `json:"BorderColor"`
- }
- type FileSource struct {
- IsRelative string `json:"IsRelative"`
- FilePath string `json:"FilePath"`
- }
- type InEffect struct {
- Type string `json:"Type"` //0- No transition, 1-Random, 2-Left unveil, 3-Right unveil
- Time string `json:"Time"`
- }
- type Items struct {
- Type string `json:"Type"`
- Volume string `json:"Volume"`
- Duration string `json:"Duration"`
- FileSource FileSource `json:"FileSource"`
- ReserveAS string `json:"ReserveAS"`
- InEffect InEffect `json:"inEffect"`
- URL string `json:"URL"`
- }
- type Regions struct {
- Layer int `json:"Layer"`
- Rect Rect `json:"Rect"`
- Items []Items `json:"Items"`
- }
- type Pages struct {
- Regions []Regions `json:"Regions"`
- }
- type Program struct {
- Pages []Pages `json:"Pages"`
- }
- type Programs struct {
- Program Program `json:"Program"`
- }
- func NewVsn() Vsn {
- return Vsn{Programs: Programs{
- Program: Program{
- Pages: []Pages{
- {Regions: []Regions{
- {Layer: 1,
- Rect: Rect{
- X: "0",
- Y: "0",
- Width: "128",
- Height: "256",
- BorderWidth: "0",
- BorderColor: "0xFFFFFF00",
- },
- Items: []Items{
- {
- Type: "",
- FileSource: FileSource{},
- },
- },
- },
- }},
- },
- },
- }}
- }
- // 文本vsn
- type TextVsn struct {
- Programs struct {
- Program struct {
- Pages []struct {
- Regions []struct {
- Rect struct {
- X string `json:"X"`
- Y string `json:"Y"`
- Width string `json:"Width"`
- Height string `json:"Height"`
- } `json:"Rect"`
- Items []struct {
- Type string `json:"Type"`
- BackColor string `json:"BackColor"`
- TextColor string `json:"TextColor"`
- Alpha string `json:"Alpha"`
- BeGlaring string `json:"BeGlaring"`
- MultiPicInfo struct {
- OnePicDuration string `json:"OnePicDuration"`
- } `json:"MultiPicInfo"`
- VerticalAlign int `json:"VerticalAlign"`
- CenteralAlign int `json:"CenteralAlign"`
- LogFont struct {
- LfHeight string `json:"lfHeight"`
- LfWeight string `json:"lfWeight"`
- LfItalic string `json:"lfItalic"`
- LfUnderline string `json:"lfUnderline"`
- LfStrikeOut string `json:"lfStrikeOut"`
- LfFaceName string `json:"lfFaceName"`
- } `json:"LogFont"`
- RepeatCount string `json:"RepeatCount"`
- Speed string `json:"Speed"`
- IsScrollByTime string `json:"IsScrollByTime"`
- IsScroll string `json:"IsScroll"`
- PlayLenth string `json:"PlayLenth"`
- Text string `json:"Text"`
- } `json:"Items"`
- } `json:"Regions"`
- } `json:"Pages"`
- } `json:"Program"`
- } `json:"Programs"`
- }
- type SSchedule struct {
- Sleep string `json:"sleep"`
- Wakeup string `json:"wakeup"`
- Reboot string `json:"reboot"`
- }
|