import ch.psi.pshell.epics.CAS as CAS



class ScanDevice(ReadonlyAsyncRegisterBase, ReadonlyRegisterArray):
    def getSize(self):
        global scan_result
        return len(self.take())   

    def append(self, value):
        c = self.take()
        c.append(value)
        self.set(c)
        
    def set(self, value):
        self.onReadout(to_array(value, 'd'))


add_device(ScanDevice("scan_pos"), True)
add_device(ScanDevice("scan_val"), True)
scan_pos.set([])
scan_val.set([])

CAS.setServerPort(12345)
cas1 = CAS("PSHELL:scanpos",scan_pos, "double")
cas2 = CAS("PSHELL:scanval",scan_val, "double")
cas3 = CAS("PSHELL:var",sin)



scan_pos.set([])
scan_val.set([])
#res = lscan(inp, (sin,out), 0, 40, 40, 0.1)
#scan_pos.set(res.getPositions(0))
#scan_val.set(res.getReadable(0))





