How to use Set method of data Package

Best K6 code snippet using data.Set

data.go

Source:data.go Github

copy

Full Screen

1package controllers2import (3 "fmt"4 "github.com/astaxie/beego"5 "io/ioutil"6 "solarzoom/models"7 "solarzoom/utils"8 "strconv"9 "strings"10 "time"11 //"solarzoom/utils/simplejson"12)13///////////////////////////////////////////////////////////////////////////////14///////////////////////////////////////////////////////////////////////////////15///////////////////////////////////////////////////////////////////////////////16type DataController struct {17 beego.Controller18}19///////////////////////////////////////////////////////////////////////////////20///////////////////////////////////////////////////////////////////////////////21///////////////////////////////////////////////////////////////////////////////22const STR_FAULT string = "Fault"23const STR_OFF string = "Off"24// TRNGY Data25//var sData string = "5630312e30322e34534254524e4759535030303154523030314e4f563030303030303150434c313330305231353831323030320025000043370001aa55000101001182320083000005b90000000000000000089b138e000000020000000000000000000000000000ffff000000000000000000020200064fdeb2"26//var sData string = "5630312e30322e34534254524e4759535030303154523030314e4f5630303030303031303030303030303050434c31333030523135383132303032000a0000192901aa550001010011823200e2002204c200000005000000020883138e002b00000000000500000007000100000000ffff000000000000000000000000006f99151"27//var sData string = "5602300231022e02300233022e02310253024202540252024e024702590253025002300230023102540252023002300231024e024f0256023002300230023002300230023102500243024c023102330230023002520231023502380231023202300230023602002102560271023902f02102aa025502002102102002110282023202002d802002002d02402002002002102002002002002002002002002002002002002002002002002002002002002002202002002002002ff02ff02002002002002002002002002002002202002402b2026b02e102"28//var sData string = "5633102e30332e31534254524e4759535030303154523030314e4f5630303030303031303030303030303050434c3133303052313538313230303100035680d0c601aa5500010100118232011a012905570000002f0000001b088b138c026500000000001f00000005000100000000ffff000000000000000000000000066d23b5"29//var sData string = "5630312e30332e33534254524e4759535030303154523030314e4f5630303030303031303030303030303050434c3133303052313538313230303100025697138c01aa5500010100118232011700a6058d0000003d0000002108a3138902f10000000001d400000092000100000000ffff0000000000000000000000000914b0e9"30//var sData string = "5630312e30332e34534254524e4759535030303154523030314e4f5630303030303031303030303030303050434c3133303052313538313230303500a456d91f4b03aa55000301001182320141013404b60000002a0000001308ca138e01ba00000000023900000072000100000000ffff00000000000000000000000008106ba10000"31//var sData string = "5630312e30332e32534253554e47524b544c30314b544c30314e4f56303030303030313030303030303030000100000a3b010104e60001009500700000006c0000015c000000001cf50006ffffffff0000000001d7000008f208f408db0007000700070000000000000000000000000159000000000000000001f402dc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013300000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000219000200000000580e8f250000"32//var sData string = "5630312e30332e32534253554e47524b544c30314b544c30310104E60001009500700000006C0000015E000000001CCD0006FFFFFFFF0000000001F6000008EE08FA08D50008000800080000000000000000000000000178000000000000000001F402ED00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000134000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002160002000000003602"33//var sData string = "5630312e30332e32534253554e47524b544c30314b544c30314e4f56303030303030313030303030303030000100000a3b010104e60001009500700000006c0000015c000000001cf50006ffffffff0000000001d7000008f208f408db0007000700070000000000000000000000000159000000000000000001f402dc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013300000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000219000200000000580e8f25"34var sData string = "5630312e30332e36534253554e47524b544c30314b544c303130303a34643a31303a30363a31383a30323a413136303432373335343800000000000000000000a05827f917171704e60001015f5927000006ea0000015dffffffff1c99002e1cae002d1ca4002c2cf4000009300928092800a300a600a70000000000000000000000002c0d0000000d000003e801f303d90000000000000000000000000000000000000000000000fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000028fffff0000000000000000d6d8000000000000000100020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000192000e1ca000167ff07a1d"35///////////////////////////////////////////////////////////////////////////////36///////////////////////////////////////////////////////////////////////////////37///////////////////////////////////////////////////////////////////////////////38func setBatchOrder(m *models.PvInverterRunData, dataMap map[string]interface{}) {39 if order, ok := dataMap["BatchOrder"].(uint64); ok {40 m.BatchOrder = int32(order)41 }42}43func setSampleTime(m *models.PvInverterRunData, dataMap map[string]interface{}) {44 if sTime, ok := dataMap["SmplTime"].(uint64); ok {45 m.SmplTime = int64(sTime)46 hour, min, _ := time.Unix(m.SmplTime, 0).Clock()47 m.BatchOrder = int32(hour*12 + min/5 + 1)48 //fmt.Printf("SampleTime ---> BatchOrder:hour=%d, min=%d, batchOrder=%d\n", hour, min, m.BatchOrder)49 }50}51///////////////////////////////////////////////////////////////////////////////52func setWorkStatus(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {53 var workStatus = "Normal"54 if v, err := utils.RunCalcUnit(fname, utils.Cmd_WorkStatus, dataMap); err == nil {55 if s, ok := v.(string); ok {56 m.WorkStatus = s57 if b := strings.Contains(s, STR_FAULT); !b {58 if b = strings.Contains(s, STR_OFF); !b {59 m.WorkStatus = workStatus60 }61 }62 } else {63 m.WorkStatus = workStatus64 }65 }66}67func setRunTimeTotal(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {68 if v, err := utils.RunCalcUnit(fname, utils.Cmd_RunTimeTotal, dataMap); err == nil {69 if time, ok := v.(float64); ok {70 m.RunTimeTotal = time71 }72 }73}74func setEnergyTotal(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {75 if v, err := utils.RunCalcUnit(fname, utils.Cmd_EnergyTotal, dataMap); err == nil {76 if energy, ok := v.(float64); ok {77 s := fmt.Sprintf("%.02f", energy)78 m.EnergyTotal, _ = strconv.ParseFloat(s, 64)79 }80 }81}82func setEnergyDay(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {83 if v, err := utils.RunCalcUnit(fname, utils.Cmd_EnergyDay, dataMap); err == nil {84 if energy, ok := v.(float64); ok {85 s := fmt.Sprintf("%.02f", energy)86 m.EnergyDay, _ = strconv.ParseFloat(s, 64)87 }88 }89}90func setInterTemperature(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {91 if v, err := utils.RunCalcUnit(fname, utils.Cmd_ITemp, dataMap); err == nil {92 if t, ok := v.(float64); ok {93 s := fmt.Sprintf("%.02f", t)94 m.InternalTemperature, _ = strconv.ParseFloat(s, 64)95 }96 }97}98func setVdcPV1(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {99 if v, err := utils.RunCalcUnit(fname, utils.Cmd_VdcPV1, dataMap); err == nil {100 if vdc, ok := v.(float64); ok {101 s := fmt.Sprintf("%.02f", vdc)102 m.VdcPv1, _ = strconv.ParseFloat(s, 64)103 }104 }105}106func setIdcPV1(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {107 if v, err := utils.RunCalcUnit(fname, utils.Cmd_IdcPV1, dataMap); err == nil {108 if idc, ok := v.(float64); ok {109 s := fmt.Sprintf("%.02f", idc)110 m.IdcPv1, _ = strconv.ParseFloat(s, 64)111 }112 }113}114func setDCPowerPV1(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {115 if v, err := utils.RunCalcUnit(fname, utils.Cmd_DCPowerPV1, dataMap); err == nil {116 if power, ok := v.(float64); ok {117 s := fmt.Sprintf("%.02f", power)118 m.DcpowerPv1, _ = strconv.ParseFloat(s, 64)119 }120 }121}122func setVdcPV2(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {123 if v, err := utils.RunCalcUnit(fname, utils.Cmd_VdcPV2, dataMap); err == nil {124 if vdc, ok := v.(float64); ok {125 s := fmt.Sprintf("%.02f", vdc)126 m.VdcPv2, _ = strconv.ParseFloat(s, 64)127 }128 }129}130func setIdcPV2(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {131 if v, err := utils.RunCalcUnit(fname, utils.Cmd_IdcPV2, dataMap); err == nil {132 if idc, ok := v.(float64); ok {133 s := fmt.Sprintf("%.02f", idc)134 m.IdcPv2, _ = strconv.ParseFloat(s, 64)135 }136 }137}138func setDCPowerPV2(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {139 if v, err := utils.RunCalcUnit(fname, utils.Cmd_DCPowerPV2, dataMap); err == nil {140 if power, ok := v.(float64); ok {141 s := fmt.Sprintf("%.02f", power)142 m.DcpowerPv2, _ = strconv.ParseFloat(s, 64)143 }144 }145}146func setVdcPV3(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {147 if v, err := utils.RunCalcUnit(fname, utils.Cmd_VdcPV3, dataMap); err == nil {148 if vdc, ok := v.(float64); ok {149 s := fmt.Sprintf("%.02f", vdc)150 m.VdcPv3, _ = strconv.ParseFloat(s, 64)151 }152 }153}154func setIdcPV3(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {155 if v, err := utils.RunCalcUnit(fname, utils.Cmd_IdcPV3, dataMap); err == nil {156 if idc, ok := v.(float64); ok {157 s := fmt.Sprintf("%.02f", idc)158 m.IdcPv3, _ = strconv.ParseFloat(s, 64)159 }160 }161}162func setDCPowerPV3(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {163 if v, err := utils.RunCalcUnit(fname, utils.Cmd_DCPowerPV3, dataMap); err == nil {164 if power, ok := v.(float64); ok {165 s := fmt.Sprintf("%.02f", power)166 m.DcpowerPv3, _ = strconv.ParseFloat(s, 64)167 }168 }169}170func setVdcPV4(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {171 if v, err := utils.RunCalcUnit(fname, utils.Cmd_VdcPV4, dataMap); err == nil {172 if vdc, ok := v.(float64); ok {173 s := fmt.Sprintf("%.02f", vdc)174 m.VdcPv4, _ = strconv.ParseFloat(s, 64)175 }176 }177}178func setIdcPV4(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {179 if v, err := utils.RunCalcUnit(fname, utils.Cmd_IdcPV4, dataMap); err == nil {180 if idc, ok := v.(float64); ok {181 s := fmt.Sprintf("%.02f", idc)182 m.IdcPv4, _ = strconv.ParseFloat(s, 64)183 }184 }185}186func setDCPowerPV4(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {187 if v, err := utils.RunCalcUnit(fname, utils.Cmd_DCPowerPV4, dataMap); err == nil {188 if power, ok := v.(float64); ok {189 s := fmt.Sprintf("%.02f", power)190 m.DcpowerPv4, _ = strconv.ParseFloat(s, 64)191 }192 }193}194func setGFCIResistorPV1(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {195 if v, err := utils.RunCalcUnit(fname, utils.Cmd_GFCIResistorPV1, dataMap); err == nil {196 if r, ok := v.(float64); ok {197 s := fmt.Sprintf("%.02f", r)198 m.Pv1Resistor, _ = strconv.ParseFloat(s, 64)199 }200 }201}202func setGFCIResistorPV2(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {203 if v, err := utils.RunCalcUnit(fname, utils.Cmd_GFCIResistorPV2, dataMap); err == nil {204 if r, ok := v.(float64); ok {205 s := fmt.Sprintf("%.02f", r)206 m.Pv2Resistor, _ = strconv.ParseFloat(s, 64)207 }208 }209}210func setGFCIResistorPV3(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {211 if v, err := utils.RunCalcUnit(fname, utils.Cmd_GFCIResistorPV3, dataMap); err == nil {212 if r, ok := v.(float64); ok {213 s := fmt.Sprintf("%.02f", r)214 m.Pv3Resistor, _ = strconv.ParseFloat(s, 64)215 }216 }217}218func setGFCIResistorPV4(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {219 if v, err := utils.RunCalcUnit(fname, utils.Cmd_GFCIResistorPV4, dataMap); err == nil {220 if r, ok := v.(float64); ok {221 s := fmt.Sprintf("%.02f", r)222 m.Pv4Resistor, _ = strconv.ParseFloat(s, 64)223 }224 }225}226func setAverVdcPV(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {227 if v, err := utils.RunCalcUnit(fname, utils.Cmd_AverVdcPV, dataMap); err == nil {228 if avgVdc, ok := v.(float64); ok {229 s := fmt.Sprintf("%.02f", avgVdc)230 m.AverVdcPv, _ = strconv.ParseFloat(s, 64)231 }232 }233}234func setIdcTotal(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {235 if v, err := utils.RunCalcUnit(fname, utils.Cmd_IdcTotal, dataMap); err == nil {236 if idcTotal, ok := v.(float64); ok {237 s := fmt.Sprintf("%.02f", idcTotal)238 m.IdcTotal, _ = strconv.ParseFloat(s, 64)239 }240 }241}242func setDCPowerTotal(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {243 if v, err := utils.RunCalcUnit(fname, utils.Cmd_DCPowerTotal, dataMap); err == nil {244 if dcTotal, ok := v.(float64); ok {245 s := fmt.Sprintf("%.02f", dcTotal)246 m.DcpowerTotal, _ = strconv.ParseFloat(s, 64)247 }248 }249}250func setVacR(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {251 if v, err := utils.RunCalcUnit(fname, utils.Cmd_VacR, dataMap); err == nil {252 if vac, ok := v.(float64); ok {253 s := fmt.Sprintf("%.02f", vac)254 m.VacR, _ = strconv.ParseFloat(s, 64)255 }256 }257}258func setIacR(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {259 if v, err := utils.RunCalcUnit(fname, utils.Cmd_IacR, dataMap); err == nil {260 if iac, ok := v.(float64); ok {261 s := fmt.Sprintf("%.02f", iac)262 m.IacR, _ = strconv.ParseFloat(s, 64)263 }264 }265}266func setACPwerR(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {267 if v, err := utils.RunCalcUnit(fname, utils.Cmd_ACPwerR, dataMap); err == nil {268 if power, ok := v.(float64); ok {269 s := fmt.Sprintf("%.02f", power)270 m.AcpowerR, _ = strconv.ParseFloat(s, 64)271 }272 }273}274func setFacR(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {275 if v, err := utils.RunCalcUnit(fname, utils.Cmd_FacR, dataMap); err == nil {276 if f, ok := v.(float64); ok {277 s := fmt.Sprintf("%.02f", f)278 m.FacR, _ = strconv.ParseFloat(s, 64)279 }280 }281}282func setVacS(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {283 if v, err := utils.RunCalcUnit(fname, utils.Cmd_VacS, dataMap); err == nil {284 if vac, ok := v.(float64); ok {285 s := fmt.Sprintf("%.02f", vac)286 m.VacS, _ = strconv.ParseFloat(s, 64)287 }288 }289}290func setIacS(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {291 if v, err := utils.RunCalcUnit(fname, utils.Cmd_IacS, dataMap); err == nil {292 if iac, ok := v.(float64); ok {293 s := fmt.Sprintf("%.02f", iac)294 m.IacS, _ = strconv.ParseFloat(s, 64)295 }296 }297}298func setACPwerS(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {299 if v, err := utils.RunCalcUnit(fname, utils.Cmd_ACPwerS, dataMap); err == nil {300 if power, ok := v.(float64); ok {301 s := fmt.Sprintf("%.02f", power)302 m.AcpowerS, _ = strconv.ParseFloat(s, 64)303 }304 }305}306func setFacS(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {307 if v, err := utils.RunCalcUnit(fname, utils.Cmd_FacS, dataMap); err == nil {308 if f, ok := v.(float64); ok {309 s := fmt.Sprintf("%.02f", f)310 m.FacS, _ = strconv.ParseFloat(s, 64)311 }312 }313}314func setVacT(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {315 if v, err := utils.RunCalcUnit(fname, utils.Cmd_VacT, dataMap); err == nil {316 if vac, ok := v.(float64); ok {317 s := fmt.Sprintf("%.02f", vac)318 m.VacT, _ = strconv.ParseFloat(s, 64)319 }320 }321}322func setIacT(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {323 if v, err := utils.RunCalcUnit(fname, utils.Cmd_IacT, dataMap); err == nil {324 if iac, ok := v.(float64); ok {325 s := fmt.Sprintf("%.02f", iac)326 m.IacT, _ = strconv.ParseFloat(s, 64)327 }328 }329}330func setACPwerT(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {331 if v, err := utils.RunCalcUnit(fname, utils.Cmd_ACPwerT, dataMap); err == nil {332 if power, ok := v.(float64); ok {333 s := fmt.Sprintf("%.02f", power)334 m.AcpowerT, _ = strconv.ParseFloat(s, 64)335 }336 }337}338func setFacT(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {339 if v, err := utils.RunCalcUnit(fname, utils.Cmd_FacT, dataMap); err == nil {340 if f, ok := v.(float64); ok {341 s := fmt.Sprintf("%.02f", f)342 m.FacT, _ = strconv.ParseFloat(s, 64)343 }344 }345}346func setAverVac(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {347 if v, err := utils.RunCalcUnit(fname, utils.Cmd_AverVac, dataMap); err == nil {348 if avgVac, ok := v.(float64); ok {349 s := fmt.Sprintf("%.02f", avgVac)350 m.AverVac, _ = strconv.ParseFloat(s, 64)351 }352 }353}354func setACActivePowerTotal(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {355 if v, err := utils.RunCalcUnit(fname, utils.Cmd_ACActivePowerTotal, dataMap); err == nil {356 if power, ok := v.(float64); ok {357 s := fmt.Sprintf("%.02f", power)358 m.AcActivePowerTotal, _ = strconv.ParseFloat(s, 64)359 }360 }361}362func setIacTotal(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {363 if v, err := utils.RunCalcUnit(fname, utils.Cmd_IacTotal, dataMap); err == nil {364 if iac, ok := v.(float64); ok {365 s := fmt.Sprintf("%.02f", iac)366 //fmt.Printf("iac=%v, siac=%v\n", iac, s)367 m.IacTotal, _ = strconv.ParseFloat(s, 64)368 }369 }370}371func setVacBalance(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {372 if v, err := utils.RunCalcUnit(fname, utils.Cmd_VacBalance, dataMap); err == nil {373 if vBlc, ok := v.(float64); ok {374 s := fmt.Sprintf("%.02f", vBlc)375 m.VacBalance, _ = strconv.ParseFloat(s, 64)376 }377 }378}379func setIacBalance(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {380 if v, err := utils.RunCalcUnit(fname, utils.Cmd_IacBalance, dataMap); err == nil {381 if iBlc, ok := v.(float64); ok {382 s := fmt.Sprintf("%.02f", iBlc)383 m.IacBalance, _ = strconv.ParseFloat(s, 64)384 }385 }386}387func setFgrid(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {388 if v, err := utils.RunCalcUnit(fname, utils.Cmd_Fgrid, dataMap); err == nil {389 if grid, ok := v.(float64); ok {390 m.Fgrid = grid391 }392 }393}394func setEfficiency(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {395 if v, err := utils.RunCalcUnit(fname, utils.Cmd_Efficiency, dataMap); err == nil {396 if ef, ok := v.(float64); ok {397 s := fmt.Sprintf("%.1f", ef*100)398 m.Efficiency, _ = strconv.ParseFloat(s, 64)399 }400 }401}402func setSPLPEnergy(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {403 if v, err := utils.RunCalcUnit(fname, utils.Cmd_SPLPEnergy, dataMap); err == nil {404 if simu, ok := v.(float64); ok {405 s := fmt.Sprintf("%.02f", simu)406 //fmt.Printf("simu=%v, s=%s\n", simu, s)407 m.SimuKwh5Min, _ = strconv.ParseFloat(s, 64)408 }409 }410}411///////////////////////////////////////////////////////////////////////////////412func getInverterSN(dataMap map[string]interface{}) string {413 if sn, ok := dataMap["DVCSN_Len"].(string); ok {414 return sn415 }416 return ""417}418func getGWSN(dataMap map[string]interface{}) string {419 if sn, ok := dataMap["GWSN"].(string); ok {420 return sn421 }422 return ""423}424func getDAddr(dataMap map[string]interface{}) uint64 {425 if addr, ok := dataMap["DAddr"].(uint64); ok {426 return addr427 }428 return 0429}430func getErrorMessage(m *models.PvInverterRunData, fname string, dataMap map[string]interface{}) string {431 if v, err := utils.RunCalcUnit(fname, utils.Cmd_ErrorMessage, dataMap); err == nil {432 if msg, ok := v.(string); ok {433 //s := fmt.Sprintf("%.02f", simu)434 //fmt.Printf("simu=%v, s=%s\n", simu, s)435 return msg436 }437 }438 return ""439}440///////////////////////////////////////////////////////////////////////////////441func genIvtRunDataDBItem(item *models.PvInverterRunData, fname string, dataMap map[string]interface{}) {442 //setBatchOrder(item, dataMap)443 setSampleTime(item, dataMap)444 setWorkStatus(item, fname, dataMap)445 //fmt.Println("ErrorMessage:", getErrorMessage(item, fname, dataMap))446 setRunTimeTotal(item, fname, dataMap)447 setEnergyTotal(item, fname, dataMap)448 setEnergyDay(item, fname, dataMap)449 setInterTemperature(item, fname, dataMap)450 setVdcPV1(item, fname, dataMap)451 setIdcPV1(item, fname, dataMap)452 setDCPowerPV1(item, fname, dataMap)453 setVdcPV2(item, fname, dataMap)454 setIdcPV2(item, fname, dataMap)455 setDCPowerPV2(item, fname, dataMap)456 setVdcPV3(item, fname, dataMap)457 setIdcPV3(item, fname, dataMap)458 setDCPowerPV3(item, fname, dataMap)459 setVdcPV4(item, fname, dataMap)460 setIdcPV4(item, fname, dataMap)461 setDCPowerPV4(item, fname, dataMap)462 setGFCIResistorPV1(item, fname, dataMap)463 setGFCIResistorPV2(item, fname, dataMap)464 setGFCIResistorPV3(item, fname, dataMap)465 setGFCIResistorPV4(item, fname, dataMap)466 setAverVdcPV(item, fname, dataMap)467 setIdcTotal(item, fname, dataMap)468 setDCPowerTotal(item, fname, dataMap)469 setVacR(item, fname, dataMap)470 setIacR(item, fname, dataMap)471 setACPwerR(item, fname, dataMap)472 setFacR(item, fname, dataMap)473 setVacS(item, fname, dataMap)474 setIacS(item, fname, dataMap)475 setACPwerS(item, fname, dataMap)476 setFacS(item, fname, dataMap)477 setVacT(item, fname, dataMap)478 setIacT(item, fname, dataMap)479 setACPwerT(item, fname, dataMap)480 setFacT(item, fname, dataMap)481 setAverVac(item, fname, dataMap)482 setACActivePowerTotal(item, fname, dataMap)483 setIacTotal(item, fname, dataMap)484 setVacBalance(item, fname, dataMap)485 setIacBalance(item, fname, dataMap)486 setFgrid(item, fname, dataMap)487 setEfficiency(item, fname, dataMap)488 setSPLPEnergy(item, fname, dataMap)489}490func handleDataRequest(ctrl *DataController) {491 data := ctrl.GetString("data")492 // send back the json file493 ctrl.Data["command1"] = "cmd"494 ctrl.Data["value1"] = "data"495 ctrl.Data["command2"] = "errcode"496 ctrl.Data["value2"] = 2497 ctrl.TplNames = "cmd2.tpl"498 if data != "" {499 //var s []byte = []byte(sData)500 var s []byte = []byte(data)501 fmt.Println("data=", data)502 utils.WriteDebugLog("Handle Data: data=%v", data)503 stylecode := utils.PeekStyleCode(s)504 fmt.Printf("stylecode=%v\n", stylecode)505 fname := FILE_STYLE_PATH + "SD" + stylecode[1] + stylecode[2] + ".json"506 _, err := ioutil.ReadFile(fname)507 if err != nil {508 fmt.Println("ReadJSONFile:", err.Error())509 } else {510 fmt.Println("ReadJSONFile SUCCESS!")511 }512 item := models.NewPvInverterRunData()513 dataMap := utils.HandleSDData(fname, s)514 genIvtRunDataDBItem(item, fname, dataMap)515 // get the inverter sn516 sn := getInverterSN(dataMap)517 if len(sn) != 0 && sn[0] != 0 {518 item.IvtId, _ = models.GetIvtIdByIvtSN(sn)519 //fmt.Println("item.IvtId=", item.IvtId)520 } else {521 gw := strings.Split(getGWSN(dataMap), ":")522 var gwsn string = ""523 for _, v := range gw {524 gwsn += v525 } 526 addr := fmt.Sprintf("%v", getDAddr(dataMap))527 //fmt.Printf("gwsn=%v, addr=%s\n", gwsn, addr)528 utils.WriteDebugLog("Can't get ivt_sn, use gw_sn & ivt_address")529 utils.WriteDebugLog(" gwsn=%s, addr=%s", gwsn, addr)530 item.IvtId, _ = models.GetIvtIdByGWInfo(gwsn, addr)531 } 532 utils.WriteDebugLog("Parse Data: ivt_id=%v, batch_order=%v, smpl_time=%v, ", item.IvtId, item.BatchOrder, item.SmplTime)533 utils.WriteDebugLog(" input_time=%v, work_status=%v, run_time_total=%v, ", item.InputTime, item.WorkStatus, item.RunTimeTotal)534 utils.WriteDebugLog(" energy_total=%v, energy_day=%v, internal_temperature=%v, ", item.EnergyTotal, item.EnergyDay, item.InternalTemperature)535 utils.WriteDebugLog(" vdc_pv1=%v, idc_pv1=%v, dcpower_pv1=%v, ", item.VdcPv1, item.IdcPv1, item.DcpowerPv1)536 utils.WriteDebugLog(" vdc_pv2=%v, idc_pv2=%v, dcpower_pv2=%v, ", item.VdcPv2, item.IdcPv2, item.DcpowerPv2)537 utils.WriteDebugLog(" vdc_pv3=%v, idc_pv3=%v, dcpower_pv3=%v, ", item.VdcPv3, item.IdcPv3, item.DcpowerPv3)538 utils.WriteDebugLog(" vdc_pv4=%v, idc_pv4=%v, dcpower_pv4=%v, ", item.VdcPv4, item.IdcPv4, item.DcpowerPv4)539 utils.WriteDebugLog(" pv1_resistor=%v, pv2_resistor=%v, pv3_resistor=%v, pv4_resistor=%v, ", item.Pv1Resistor, item.Pv2Resistor, item.Pv3Resistor, item.Pv4Resistor)540 utils.WriteDebugLog(" aver_vdc_pv=%v, idc_total=%v, dcpower_total=%v, ", item.AverVdcPv, item.IdcTotal, item.DcpowerTotal)541 utils.WriteDebugLog(" vac_r=%v, iac_r=%v, acpower_r=%v, fac_r=%v ", item.VacR, item.IacR, item.AcpowerR, item.FacR)542 utils.WriteDebugLog(" vac_s=%v, iac_s=%v, acpower_s=%v, fac_s=%v ", item.VacS, item.IacS, item.AcpowerS, item.FacS)543 utils.WriteDebugLog(" vac_t=%v, iac_t=%v, acpower_t=%v, fac_t=%v ", item.VacT, item.IacT, item.AcpowerT, item.FacT)544 utils.WriteDebugLog(" aver_vac=%v, ac_active_power_total=%v, iac_total=%v, ", item.AverVac, item.AcActivePowerTotal, item.IacTotal)545 utils.WriteDebugLog(" vac_balance=%v, iac_balance=%v, ", item.VacBalance, item.IacBalance)546 utils.WriteDebugLog(" fgrid=%v, efficiency=%v, simu_kwh5_min=%v", item.Fgrid, item.Efficiency, item.SimuKwh5Min)547 // calculate the day data & update it transfer to Solarzoom548 // so comment the code549 // dayRecord := models.NewPvInverterDayData()550 // dayRecord.IvtId = item.IvtId551 // dayRecord.Day = models.CalcDayTableDayItem(item.SmplTime)552 // dayRecord.AcActivePowerTotal = item.AcActivePowerTotal553 // dayRecord.EnergyTotal = item.EnergyTotal554 // dayRecord.EnergyToday = item.EnergyDay555 // dayRecord.PowerContent, _ = models.GetPowerContentInDayTable(dayRecord)556 // //fmt.Println("1 --- dayRecord.PowerContent=", dayRecord.PowerContent)557 // dayRecord.PowerContent = fmt.Sprintf("%s#%v:%v:%v", dayRecord.PowerContent, item.BatchOrder, item.SmplTime, item.DcpowerTotal)558 //fmt.Println("2 --- dayRecord.PowerContent=", dayRecord.PowerContent)559 // careate the new table560 // item.TableName()561 //models.CreateDayTableBySQL()562 //models.InsertDayTableItemBySQL()563 models.InsertRunDataTableItemBySQL(item)564 // models.UpdateDayTableRecordBySQL(dayRecord)565 //item.WorkStatus = "Error"566 // check the workstatus567 if item.WorkStatus == STR_FAULT {568 // write the fault table569 fault := models.NewPvInverterFaultData()570 fault.IvtId = item.IvtId571 fault.StartTime = item.SmplTime572 fault.FaultMessage = getErrorMessage(item, fname, dataMap)573 models.InsertFaultTableItemBySQL(fault)574 }575 ctrl.Data["value2"] = 0576 }577}578func (ctrl *DataController) Get() {579 sess := ctrl.StartSession()580 state := sess.Get(utils.SessAuth)581 //state := utils.GetSolarMapItem(utils.SessAuth)582 //state = "ok"583 utils.WriteDebugLog("/gw/data GET request")584 if state != "ok" {585 utils.WriteDebugLog("Data: AUTH ERROR!")586 //ctrl.Redirect(URLAuth, 302)587 ctrl.Data["command1"] = "cmd"588 ctrl.Data["value1"] = "data"589 ctrl.Data["command2"] = "errcode"590 ctrl.Data["value2"] = 3591 ctrl.TplNames = "cmd2.tpl"592 } else {593 handleDataRequest(ctrl)594 }595 //handleDataRequest(ctrl)596}597func (ctrl *DataController) Post() {598 sess := ctrl.StartSession()599 state := sess.Get(utils.SessAuth)600 //state := utils.GetSolarMapItem(utils.SessAuth)601 utils.WriteDebugLog("/gw/data POST request")602 if state != "ok" {603 utils.WriteDebugLog("Data: AUTH ERROR!")604 //ctrl.Redirect(URLAuth, 302)605 ctrl.Data["command1"] = "cmd"606 ctrl.Data["value1"] = "data"607 ctrl.Data["command2"] = "errcode"608 ctrl.Data["value2"] = 3609 ctrl.TplNames = "cmd2.tpl"610 } else {611 handleDataRequest(ctrl)612 }613}614///////////////////////////////////////////////////////////////////////////////615///////////////////////////////////////////////////////////////////////////////616///////////////////////////////////////////////////////////////////////////////617func (ctrl *DataController) Command() {618 sess := ctrl.StartSession()619 state := sess.Get(utils.SessAuth)620 //state := utils.GetSolarMapItem(utils.SessAuth)621 gwsn := ctrl.GetString("cmd")622 //fmt.Println("gwsn=", gwsn)623 if state != "ok" {624 utils.WriteDebugLog("Data: AUTH ERROR!")625 //ctrl.Redirect(URLAuth, 302)626 ctrl.Data["command1"] = "cmd"627 ctrl.Data["value1"] = "data"628 ctrl.Data["command2"] = "errcode"629 ctrl.Data["value2"] = 3630 ctrl.TplNames = "cmd2.tpl"631 } else {632 fmt.Println("Command")633 //fmt.Println("content:=", models.SerialCommands(gwsn))634 utils.WriteDebugLog("/gw/cmd request")635 ctrl.Data["command"] = "commands"636 ctrl.Data["value"] = models.SerialCommands(gwsn)637 ctrl.TplNames = "cmd.tpl"638 }639}...

Full Screen

Full Screen

DragData_gen.go

Source:DragData_gen.go Github

copy

Full Screen

...122// window.123func (d *DragData) GetFileNames(names StringList) int32 {124 return int32(C.gocef_drag_data_get_file_names(d.toNative(), C.cef_string_list_t(names), d.get_file_names))125}126// SetLinkURL (set_link_url)127// Set the link URL that is being dragged.128func (d *DragData) SetLinkURL(uRL string) {129 uRL_ := C.cef_string_userfree_alloc()130 setCEFStr(uRL, uRL_)131 defer func() {132 C.cef_string_userfree_free(uRL_)133 }()134 C.gocef_drag_data_set_link_url(d.toNative(), (*C.cef_string_t)(uRL_), d.set_link_url)135}136// SetLinkTitle (set_link_title)137// Set the title associated with the link being dragged.138func (d *DragData) SetLinkTitle(title string) {139 title_ := C.cef_string_userfree_alloc()140 setCEFStr(title, title_)141 defer func() {142 C.cef_string_userfree_free(title_)143 }()144 C.gocef_drag_data_set_link_title(d.toNative(), (*C.cef_string_t)(title_), d.set_link_title)145}146// SetLinkMetadata (set_link_metadata)147// Set the metadata associated with the link being dragged.148func (d *DragData) SetLinkMetadata(data string) {149 data_ := C.cef_string_userfree_alloc()150 setCEFStr(data, data_)151 defer func() {152 C.cef_string_userfree_free(data_)153 }()154 C.gocef_drag_data_set_link_metadata(d.toNative(), (*C.cef_string_t)(data_), d.set_link_metadata)155}156// SetFragmentText (set_fragment_text)157// Set the plain text fragment that is being dragged.158func (d *DragData) SetFragmentText(text string) {159 text_ := C.cef_string_userfree_alloc()160 setCEFStr(text, text_)161 defer func() {162 C.cef_string_userfree_free(text_)163 }()164 C.gocef_drag_data_set_fragment_text(d.toNative(), (*C.cef_string_t)(text_), d.set_fragment_text)165}166// SetFragmentHTML (set_fragment_html)167// Set the text/html fragment that is being dragged.168func (d *DragData) SetFragmentHTML(hTML string) {169 hTML_ := C.cef_string_userfree_alloc()170 setCEFStr(hTML, hTML_)171 defer func() {172 C.cef_string_userfree_free(hTML_)173 }()174 C.gocef_drag_data_set_fragment_html(d.toNative(), (*C.cef_string_t)(hTML_), d.set_fragment_html)175}176// SetFragmentBaseURL (set_fragment_base_url)177// Set the base URL that the fragment came from.178func (d *DragData) SetFragmentBaseURL(baseURL string) {179 baseURL_ := C.cef_string_userfree_alloc()180 setCEFStr(baseURL, baseURL_)181 defer func() {182 C.cef_string_userfree_free(baseURL_)183 }()184 C.gocef_drag_data_set_fragment_base_url(d.toNative(), (*C.cef_string_t)(baseURL_), d.set_fragment_base_url)185}186// ResetFileContents (reset_file_contents)187// Reset the file contents. You should do this before calling188// cef_browser_host_t::DragTargetDragEnter as the web view does not allow us189// to drag in this kind of data.190func (d *DragData) ResetFileContents() {191 C.gocef_drag_data_reset_file_contents(d.toNative(), d.reset_file_contents)192}...

Full Screen

Full Screen

bitset.go

Source:bitset.go Github

copy

Full Screen

...16 addressBitsPerWord = 617 dataBitsPerWord = 1 << addressBitsPerWord18 bitIndexMask = dataBitsPerWord - 119)20// BitSet contains a set of bits.21type BitSet struct {22 data []uint6423 set int24}25// Clone this BitSet.26func (b *BitSet) Clone() *BitSet {27 bs := &BitSet{data: make([]uint64, len(b.data)), set: b.set}28 copy(bs.data, b.data)29 return bs30}31// Copy the content of 'other' into this BitSet, making them equal.32func (b *BitSet) Copy(other *BitSet) {33 b.set = other.set34 b.data = make([]uint64, len(other.data))35 copy(b.data, other.data)36}37// Equal returns true if this BitSet is equal to 'other'.38func (b *BitSet) Equal(other *BitSet) bool {39 if other == nil {40 return false41 }42 if b.set != other.set {43 return false44 }45 if len(b.data) != len(other.data) {46 return false47 }48 for i := range b.data {49 if b.data[i] != other.data[i] {50 return false51 }52 }53 return true54}55// Count returns the number of set bits.56func (b *BitSet) Count() int {57 return b.set58}59// State returns the state of the bit at 'index'.60func (b *BitSet) State(index int) bool {61 validateBitSetIndex(index)62 i := index >> addressBitsPerWord63 if i >= len(b.data) {64 return false65 }66 mask := wordMask(index)67 return b.data[i]&mask == mask68}69// Set the bit at 'index'.70func (b *BitSet) Set(index int) {71 validateBitSetIndex(index)72 i := index >> addressBitsPerWord73 b.EnsureCapacity(i + 1)74 mask := wordMask(index)75 if b.data[i]&mask == 0 {76 b.data[i] |= mask77 b.set++78 }79}80func countSetBits(x uint64) int {81 x -= (x >> 1) & 0x555555555555555582 x = (x>>2)&0x3333333333333333 + x&0x333333333333333383 x += x >> 484 x &= 0x0f0f0f0f0f0f0f0f85 x *= 0x010101010101010186 return int(x >> 56)87}88// SetRange sets the bits from 'start' to 'end', inclusive.89func (b *BitSet) SetRange(start, end int) {90 validateBitSetIndex(start)91 validateBitSetIndex(end)92 if start > end {93 start, end = end, start94 }95 i1 := start >> addressBitsPerWord96 i2 := end >> addressBitsPerWord97 b.EnsureCapacity(i2 + 1)98 j := bitIndexForMask(wordMask(start))99 for i := i1; i <= i2; i++ {100 if i != i1 && i != i2 {101 b.set += dataBitsPerWord - countSetBits(b.data[i])102 b.data[i] = math.MaxUint64103 } else {104 var last int105 if i == i2 {106 last = bitIndexForMask(wordMask(end)) + 1107 } else {108 last = dataBitsPerWord109 }110 for j < last {111 mask := wordMask(j)112 if b.data[i]&mask == 0 {113 b.data[i] |= mask114 b.set++115 }116 j++117 }118 j = 0119 }120 }121}122// Clear the bit at 'index'.123func (b *BitSet) Clear(index int) {124 validateBitSetIndex(index)125 i := index >> addressBitsPerWord126 if i < len(b.data) {127 mask := wordMask(index)128 if b.data[i]&mask == mask {129 b.data[i] &= ^mask130 b.set--131 }132 }133}134// ClearRange clears the bits from 'start' to 'end', inclusive.135func (b *BitSet) ClearRange(start, end int) {136 validateBitSetIndex(start)137 validateBitSetIndex(end)138 if start > end {139 start, end = end, start140 }141 max := len(b.data) - 1142 i1 := start >> addressBitsPerWord143 if i1 > max {144 return145 }146 i2 := end >> addressBitsPerWord147 if i2 > max {148 i2 = max149 }150 j := bitIndexForMask(wordMask(start))151 for i := i1; i <= i2; i++ {152 if i != i1 && i != i2 {153 b.set -= countSetBits(b.data[i])154 b.data[i] = 0155 } else {156 var last int157 if i == i2 {158 last = bitIndexForMask(wordMask(end)) + 1159 } else {160 last = dataBitsPerWord161 }162 for j < last {163 mask := wordMask(j)164 if b.data[i]&mask == mask {165 b.data[i] &= ^mask166 b.set--167 }168 j++169 }170 j = 0171 }172 }173}174// Flip the bit at 'index'.175func (b *BitSet) Flip(index int) {176 validateBitSetIndex(index)177 i := index >> addressBitsPerWord178 b.EnsureCapacity(i + 1)179 mask := wordMask(index)180 b.data[i] ^= mask181 if b.data[i]&mask == mask {182 b.set++183 } else {184 b.set--185 }186}187// FlipRange flips the bits from 'start' to 'end', inclusive.188func (b *BitSet) FlipRange(start, end int) {189 validateBitSetIndex(start)190 validateBitSetIndex(end)191 if start > end {192 start, end = end, start193 }194 i1 := start >> addressBitsPerWord195 i2 := end >> addressBitsPerWord196 b.EnsureCapacity(i2 + 1)197 j := bitIndexForMask(wordMask(start))198 for i := i1; i <= i2; i++ {199 if i != i1 && i != i2 {200 b.set += dataBitsPerWord - 2*countSetBits(b.data[i])201 b.data[i] ^= math.MaxUint64202 } else {203 var last int204 if i == i2 {205 last = bitIndexForMask(wordMask(end)) + 1206 } else {207 last = dataBitsPerWord208 }209 for j < last {210 mask := wordMask(j)211 b.data[i] ^= mask212 if b.data[i]&mask == mask {213 b.set++214 } else {215 b.set--216 }217 j++218 }219 j = 0220 }221 }222}223// FirstSet returns the first set bit. If no bits are set, then -1 is224// returned.225func (b *BitSet) FirstSet() int {226 return b.NextSet(0)227}228// LastSet returns the last set bit. If no bits are set, then -1 is returned.229func (b *BitSet) LastSet() int {230 return b.PreviousSet(len(b.data) << addressBitsPerWord)231}232// PreviousSet returns the previous set bit starting from 'start'. If no bits233// are set at or before 'start', then -1 is returned.234func (b *BitSet) PreviousSet(start int) int {235 validateBitSetIndex(start)236 i := start >> addressBitsPerWord237 max := len(b.data) - 1238 var firstBit int239 if i > max {240 i = max241 firstBit = 63242 } else {243 firstBit = bitIndexForMask(wordMask(start))244 }245 for i >= 0 {246 word := b.data[i]247 if word != 0 {248 for j := firstBit; j >= 0; j-- {249 mask := wordMask(j)250 if word&mask == mask {251 return i<<addressBitsPerWord + j252 }253 }254 }255 firstBit = 63256 i--257 }258 return -1259}260// NextSet returns the next set bit starting from 'start'. If no bits are set261// at or beyond 'start', then -1 is returned.262func (b *BitSet) NextSet(start int) int {263 validateBitSetIndex(start)264 i := start >> addressBitsPerWord265 firstBit := bitIndexForMask(wordMask(start))266 max := len(b.data)267 for i < max {268 word := b.data[i]269 if word != 0 {270 for j := firstBit; j < dataBitsPerWord; j++ {271 mask := wordMask(j)272 if word&mask == mask {273 return i<<addressBitsPerWord + j274 }275 }276 }277 firstBit = 0278 i++279 }280 return -1281}282// PreviousClear returns the previous clear bit starting from 'start'. If no283// bits are clear at or before 'start', then -1 is returned.284func (b *BitSet) PreviousClear(start int) int {285 validateBitSetIndex(start)286 i := start >> addressBitsPerWord287 max := len(b.data) - 1288 if i > max {289 return start290 }291 firstBit := bitIndexForMask(wordMask(start))292 for i >= 0 {293 word := b.data[i]294 if word != math.MaxUint64 {295 for j := firstBit; j >= 0; j-- {296 mask := wordMask(j)297 if word&mask == 0 {298 return i<<addressBitsPerWord + j299 }300 }301 }302 firstBit = 63303 i--304 }305 return -1306}307// NextClear returns the next clear bit starting from 'start'.308func (b *BitSet) NextClear(start int) int {309 validateBitSetIndex(start)310 i := start >> addressBitsPerWord311 firstBit := bitIndexForMask(wordMask(start))312 max := len(b.data)313 for i < max {314 word := b.data[i]315 if word != math.MaxUint64 {316 for j := firstBit; j < dataBitsPerWord; j++ {317 mask := wordMask(j)318 if word&mask == 0 {319 return i<<addressBitsPerWord + j320 }321 }322 }323 firstBit = 0324 i++325 }326 return MaxInt(max*dataBitsPerWord, start)327}328// Trim the BitSet down to the minimum required to store the set bits.329func (b *BitSet) Trim() {330 size := len(b.data)331 for i := size - 1; i >= 0; i-- {332 if b.data[i] != 0 {333 i++334 if i != size {335 data := make([]uint64, i)336 copy(data, b.data)337 b.data = data338 }339 return340 }341 i--342 }343 b.data = nil344}345// EnsureCapacity ensures that the BitSet has enough underlying storage to346// accommodate setting a bit as high as index position 'words' x 64 - 1347// without needing to allocate more storage.348func (b *BitSet) EnsureCapacity(words int) {349 size := len(b.data)350 if words > size {351 size *= 2352 if size < words {353 size = words354 }355 data := make([]uint64, size)356 copy(data, b.data)357 b.data = data358 }359}360// Data returns a copy of the underlying storage.361func (b *BitSet) Data() []uint64 {362 b.Trim()363 data := make([]uint64, len(b.data))364 copy(data, b.data)365 return data366}367// Load replaces the current data with the bits set in 'data'.368func (b *BitSet) Load(data []uint64) {369 b.data = make([]uint64, len(data))370 copy(b.data, data)371 b.Trim()372 b.set = 0373 for i := len(b.data) - 1; i >= 0; i-- {374 word := data[i]375 if word != 0 {376 for j := 0; j < dataBitsPerWord; j++ {377 mask := wordMask(j)378 if word&mask == mask {379 b.set++380 }381 }382 }383 }384}385// Reset the BitSet back to an empty state.386func (b *BitSet) Reset() {387 b.data = nil388 b.set = 0389}390func wordMask(index int) uint64 {391 return uint64(1) << uint(index&bitIndexMask)392}393func bitIndexForMask(mask uint64) int {394 for i := 0; i < dataBitsPerWord; i++ {395 if mask == wordMask(i) {396 return i397 }398 }399 fmt.Printf("Unable to determine bit index for mask %064b\n", mask)400 atexit.Exit(1)401 return 0402}403func validateBitSetIndex(index int) {404 if index < 0 {405 fmt.Printf("Index must be positive (was %d)\n", index)406 atexit.Exit(1)407 }408}...

Full Screen

Full Screen

Set

Using AI Code Generation

copy

Full Screen

1import (2type Data struct {3}4func (d *Data) Set(x int, y int) {5}6func main() {7 d := new(Data)8 d.Set(10, 20)9 fmt.Println(d.X)10 fmt.Println(d.Y)11}12import (13type Data struct {14}15func (d *Data) Set(x int, y int) {16}17func main() {18 d := &Data{}19 d.Set(10, 20)20 fmt.Println(d.X)21 fmt.Println(d.Y)22}23import (24type Data struct {25}26func (d Data) Set(x int, y int) {27}28func main() {29 d := Data{}30 d.Set(10, 20)31 fmt.Println(d.X)32 fmt.Println(d.Y)33}

Full Screen

Full Screen

Set

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 data := Data{1, 2}4 fmt.Println(data)5 data.Set(3, 4)6 fmt.Println(data)7}8import (9func main() {10 data := Data{1, 2}11 fmt.Println(data)12 data.Set(3, 4)13 fmt.Println(data)14}15import (16func main() {17 data := Data{1, 2}18 fmt.Println(data)19 data.Set(3, 4)20 fmt.Println(data)21}22import (23func main() {24 data := Data{1, 2}25 fmt.Println(data)26 data.Set(3, 4)27 fmt.Println(data)28}29import (30func main() {31 data := Data{1, 2}32 fmt.Println(data)33 data.Set(3, 4)34 fmt.Println(data)35}36import (37func main() {38 data := Data{1, 2}39 fmt.Println(data)40 data.Set(3, 4)41 fmt.Println(data)42}43import (44func main() {45 data := Data{1, 2}46 fmt.Println(data)47 data.Set(3, 4)48 fmt.Println(data)49}50import (51func main() {52 data := Data{1, 2}53 fmt.Println(data)54 data.Set(3, 4)55 fmt.Println(data)56}57import (

Full Screen

Full Screen

Set

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 data := Data{value: 10}4 data.Set(20)5}6import "fmt"7func main() {8 data := Data{value: 10}9 data.Set(20)10}11type Data struct {12}13func (data *Data) Set(value int) {14}

Full Screen

Full Screen

Set

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 mydata.Set(5)4 fmt.Println(mydata.Get())5}6import "fmt"7func main() {8 mydata.Set(5)9 fmt.Println(mydata.Get())10}11import "fmt"12func main() {13 mydata.Set(5)14 fmt.Println(mydata.Get())15}16import "fmt"17func main() {18 mydata.Set(5)19 fmt.Println(mydata.Get())20}21import "fmt"22func main() {23 mydata.Set(5)24 fmt.Println(mydata.Get())25}26import "fmt"27func main() {28 mydata.Set(5)29 fmt.Println(mydata.Get())30}31import "fmt"32func main() {33 mydata.Set(5)34 fmt.Println(mydata.Get())35}36import "fmt"37func main() {38 mydata.Set(5)39 fmt.Println(mydata.Get())40}41import "fmt"42func main() {43 mydata.Set(5)44 fmt.Println(mydata.Get())45}46import "fmt"47func main() {48 mydata.Set(5)49 fmt.Println(mydata.Get())50}51import "fmt"

Full Screen

Full Screen

Set

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 data := Data{}4 data.Set(10)5 fmt.Println(data.Get())6}7import "fmt"8func main() {9 data := Data{}10 fmt.Println(data.Get())11}12import "fmt"13func main() {14 data := Data{}15 data.Set(10)16 fmt.Println(data.Get())17}18import "fmt"19func main() {20 data := Data{}21 data.Set(10)22 fmt.Println(data.Get())23}24import "fmt"25func main() {26 data := Data{}27 data.Set(10)28 fmt.Println(data.Get())29}30import "fmt"31func main() {32 data := Data{}33 data.Set(10)34 fmt.Println(data.Get())35}36import "fmt"37func main() {38 data := Data{}39 data.Set(10)40 fmt.Println(data.Get())41}42import "fmt"43func main()

Full Screen

Full Screen

Set

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 data := data.Data{}4 data.Set(10)5 fmt.Println(data.Get())6}7import (8func main() {9 data := data.Data{}10 data.Set(10)11 fmt.Println(data.Get())12}13import (14func main() {15 data := data.Data{}16 data.Set(10)17 fmt.Println(data.Get())18}19./1.go:8: data.Get undefined (type data.Data has no field or method Get)20./2.go:8: data.Get undefined (type data.Data has no field or method Get)21./3.go:8: data.Get undefined (type data.Data has no field or method Get)

Full Screen

Full Screen

Set

Using AI Code Generation

copy

Full Screen

1data.Set(10)2data.Get()3import "fmt"4type Data struct {5}6func (d *Data) Set(data int) {7}8func (d *Data) Get() int {9}10func main() {11 data := &Data{}12 data.Set(10)13 fmt.Println(data.Get())14}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful