Exemple #1
0
func ExtIFFT_C(samples vlib.VectorC, N int) vlib.VectorC {

	y := vlib.VectorC(fft.IFFT(samples))
	y = y.Scale(math.Sqrt(1.0 / float64(N)))
	return y

}
Exemple #2
0
func main() {

	N := 20 /// 20 samples
	L := 4  /// 5tap channel
	begin := time.Now()

	var cdma core.CDMA
	cdma.InitializeChip()
	cdma.SetSpreadCode(vlib.NewOnesC(L), true)

	samples := vlib.VectorC(sources.RandNCVec(N, 1))
	var data gocomm.SComplex128Obj
	/// METHOD A
	data.Ts = 1
	data.TimeStamp = 0
	data.MaxExpected = N
	data.Message = ""
	for i := 0; i < N; i++ {
		data.Next(samples[i])
		chips := cdma.SpreadFn(data)
		output := cdma.DeSpreadFn(chips)
		fmt.Printf("\nTxSymbol %v ", data)
		// fmt.Printf("\nTx %v ", chips)
		fmt.Printf("\nRxSymbol %v ", output)
	}

	/// METHOD B
	// dataArray.MaxExpected = samples.Size()
	// inCHA := gocomm.NewComplex128Channel()
	// outputPin := filter.PinByID(1)

	// go filter.Filter(inCHA)
	// go chipset.Sink(outputPin)
	// /// Actual data pushing
	// for i := 0; i < N; i++ {
	// 	dataArray.MaxExpected = N
	// 	dataArray.Ch = samples[i]
	// 	inCHA <- dataArray
	// }

	//fmt.Printf("\nFilter Residues %v", filter.FilterMemory)

	//  Of code
	fmt.Printf("\nTime Elapsed : %v\n", time.Since(begin))
}
Exemple #3
0
func CROcomplexAScatter(InCH gocomm.Complex128AChannel, labels ...string) {

	var metric VCMetric
	// metric.Name = fmt.Sprintf("EEEBCCCEEN")
	if len(labels) == 0 {
		// metric.Name = fmt.Sprintf("ZZZZZXXXXX")
		metric.Name = fmt.Sprintf("%s", vlib.RandString(10))
		//	metric.Name = fmt.Sprintf("AAAAABBBBB")
	} else {
		metric.Name = labels[0]
		if labels[0] == "" {
			metric.Name = "PlotCurve1"
		}
		if len(metric.Name) > 10 {
			metric.Name = metric.Name[0:10]
		} else {
			metric.Name = metric.Name + strings.Repeat("*", 10-len(metric.Name))
		}
	}
	conn, cerr := net.Dial("udp", GLOBALADDRESS)
	log.Println(cerr)
	if cerr != nil {
		log.Println("CRO:Unable to Dial localhost:8080 ", cerr)
	}
	var Ts float64 = 0.252
	NextSize := 1
	// packetbuf := new(bytes.Buffer)
	buf := new(bytes.Buffer)
	totalbytes := 0
	for cnt := 0; ; cnt++ {

		data := <-InCH
		NextSize = data.MaxExpected

		// data = temp.Ch
		metric.Time = float64(cnt) * Ts
		metric.Val = vlib.VectorC(data.Ch)
		metric.Ts = Ts
		// str := strconv.FormatFloat(real(data), 'f', 2, 64)

		// databyte := make([]byte, 1024)
		// fmt.Printf("Buffer is :%v ", buf)

		// binary.Write(buf, binary.BigEndian, real(data))
		binary.Write(buf, binary.BigEndian, []byte(metric.Name))       //10bytes
		binary.Write(buf, binary.LittleEndian, metric.Time)            /// 8byte float64
		binary.Write(buf, binary.LittleEndian, metric.Ts)              /// 8byte float64
		binary.Write(buf, binary.LittleEndian, int64(len(metric.Val))) /// x= 8byte LEN Of the following float64 vector
		binary.Write(buf, binary.LittleEndian, metric.Val)             // x*8*2bytes

		// fmt.Printf("\n AFTER  Buffer is :%0 x  ", buf.Bytes())
		// fmt.Printf("\n METRIC  is :%v ", metric)

		// fmt.Fprintf(conn, "%c", str)
		// fmt.Printf("\n%f %v", real(data), buf.Bytes())
		// if 2 == 3 {
		// packetbuf.ReadFrom(buf)

		// if math.Mod(float64(cnt), 20.0) == 0 {

		// if buf.Len() >= 2040 {

		if conn != nil {
			conn.Write(buf.Bytes())
			// conn.Write(packetbuf.Bytes())
			totalbytes += buf.Len()
			fmt.Printf("\r %s : %d Sent %f %v bytes", metric.Name, cnt, metric.Time, buf.Len())
		}
		buf.Reset()
		// }

		if cnt == (NextSize - 1) {
			break
		}
		// packetbuf.Reset()

		// The sleep is only to allow the slow replot in Qt applicaiton
		// time.Sleep(2 * time.Millisecond)

	}
	fmt.Printf("\n Last TimeStamp : %f, TotalBytes = %v bytes", metric.Time, totalbytes)

	// }

}