Exemplo n.º 1
0
func main() {

	af, _ := at.NewAtFrame(nil)
	defer af.Close()
	af.DispName = atj.JS_DEFAULT_NAME
	af.SetId(atj.JS_DEFAULT_NAME)

	af.OnKill = CallbackKill
	af.OnCall = CallbackCall

	ad, _ = atd.NewAtDebugClient(atd.AD_DEFAULT_NAME, af)
	ad.Println("Program Start...")

	js, _ = atj.NewAtJEUServer(af)
	af.OnReset = CallbackReset

	ret, _ := af.MainLoop()

	js.Close()
	ad.Close()

	if ret != 0 {
		os.Exit(ret)
	}

}
Exemplo n.º 2
0
func main() {

	af, _ := at.NewAtFrame(nil)
	defer af.Close()

	af.DispName = atr.AR_DEFAULT_NAME
	af.SetId(atr.AR_DEFAULT_NAME)

	af.OnKill = CallbackKill
	af.OnReset = CallbackReset
	af.OnSet = CallbackSet
	af.OnRxIn = CallbackRxIn
	af.OnCall = CallbackCall

	ad, _ = atd.NewAtDebugClient(atd.AD_DEFAULT_NAME, af)
	ad.Println("Program Start...")

	ar, _ = atr.NewAtReportServer(atr.AR_DEFAULT_NAME, af)

	ret, _ := af.MainLoop()

	ar.Close()
	ad.Close()

	if ret != 0 {
		os.Exit(ret)
	}

}
Exemplo n.º 3
0
func main() {

	af, _ = at.NewAtFrame(nil)

	af.DispName = "jmc"
	af.SetId("jmc")

	//	af.OnPeriod = CallbackPeriod;

	ad, _ = atd.NewAtDebugClient(atd.AD_DEFAULT_NAME, af)
	ad.Reset()
	ad.Println("Program Start...")

	ar, _ = atr.NewAtReportClient(atr.AR_DEFAULT_NAME, af)

	js, _ = atj.NewAtJEUClient(af)
	js.Reset()

	jtl, _ = NewJtlFrame()
	defer jtl.Close()

	if len(os.Args) != 2 {
		ad.Println("fail do not exists script file name on command line argument")
		goto jmc_end
	}

	if err := jtl.LoadScript(os.Args[1]); err != nil {
		ad.Println("fail load script [%s]", err)
		goto jmc_end
	}

	ar.StartReport(jtl.GetTitle())
	ar.SetTotal(jtl.GetTotal())

	if err := jtl.RunScript(); err != nil {
		ad.Println("fail run script [%s]", err)
		goto jmc_end
	}

	ar.SetResultPass()

	//	ret,_ := af.MainLoop()
	//
	//	if ret != 0 {
	//	  ad.Close()
	//	  os.Exit( ret )
	//	}

jmc_end:

	ar.EndReport()
	close()

}
Exemplo n.º 4
0
func main() {

	myJEUId := os.Args[1]
	//	option     = []byte(os.Args[2])

	af, _ = at.NewAtFrame(nil)
	af.DispName = "ck_message"
	af.SetId(myJEUId)

	af.OnKill = CallbackKill

	af.OnPeriod = CallbackPeriod
	af.OnReset = CallbackReset
	af.OnSet = CallbackSet
	af.OnLink = CallbackLink
	af.OnUnlink = CallbackUnlink
	af.OnStart = CallbackStart
	af.OnStop = CallbackStop

	ad, _ = atd.NewAtDebugClient(atd.AD_DEFAULT_NAME, af)
	ad.Println("Program Start...")

	ar, _ = atr.NewAtReportClient(atr.AR_DEFAULT_NAME, af)

	js, _ = atj.NewAtJEUClient(af)

	if err := js.RegisterJEU(af.GetId()); err != nil {
		ad.Println("fail register JEU [%s]", af.GetId())
		reason := fmt.Sprintf("do not register JEU [%s]", af.GetId())
		ar.SetResultError(reason)

		close()
		return
	}

	js.SetJEUStateReady(af.GetId())
	ret, _ := af.MainLoop()

	if ret != 0 {
		close()
		os.Exit(ret)
	}

	close()
}
Exemplo n.º 5
0
func main() {

	myJEUId := os.Args[1]
	option := []byte(os.Args[2])

	af, _ = at.NewAtFrame(nil)
	af.DispName = "if_webconn_relay"
	af.SetId(myJEUId)

	af.OnKill = CallbackKill

	af.OnPeriod = CallbackPeriod

	af.OnReset = CallbackReset
	af.OnSet = CallbackSet
	af.OnLink = CallbackLink
	af.OnUnlink = CallbackUnlink
	af.OnStart = CallbackStart
	af.OnStop = CallbackStop

	ad, _ = atd.NewAtDebugClient(atd.AD_DEFAULT_NAME, af)
	ad.Println("Program Start...")

	ar, _ = atr.NewAtReportClient(atr.AR_DEFAULT_NAME, af)

	js, _ = atj.NewAtJEUClient(af)

	var argv_options map[string]interface{}
	if err := json.Unmarshal(option, &argv_options); err != nil {
		ad.Println("fail option syntex error [%s]", err)
		reason := fmt.Sprintf("option syntex error [%s]", err)
		ar.SetResultError(reason)
		close()
		return
	}

	if err := js.RegisterJEU(af.GetId()); err != nil {
		ad.Println("fail register JEU [%s]", af.GetId())
		reason := fmt.Sprintf("do not register JEU [%s]", af.GetId())
		ar.SetResultError(reason)

		close()
		return
	}

	serverIP = argv_options["ip"].(string)
	serverPort = argv_options["port"].(string)
	ad.Println("Relay Server = [%s:%s]", serverIP, serverPort)

	PairSocket, _ = af.ZmqContext.NewSocket(zmq.PAIR)
	PairSocket.Connect("tcp://" + serverIP + ":" + serverPort)

	//	OpenRS232()

	js.SetJEUStateReady(af.GetId())
	ret, _ := af.MainLoop()

	if ret != 0 {
		close()
		os.Exit(ret)
	}

	close()
}