PythonScanClient / PyScanClient

Python Client for CS-Studio Scan Service
Eclipse Public License 1.0
3 stars 4 forks source link

Split up the scanInfo() method. #12

Closed ksdj closed 9 years ago

ksdj commented 9 years ago

Hi everyone. How do you think of splitting up the scanInfo(self, scanID, infoType) into unit method? At present, the scanInfo() is calling like this:

result = scanInfo(101,'scan')
result = scanInfo(101,'last_serial') ... Comes to 5 different types of 'infoType': scan,commands,data, last_serial,devices, data. Or , split it, as : status = scanstatus(101) devices = scandevices(101) ... Which one do you think would be better?

kasemir commented 9 years ago

Yes.

I've implemented scanInfo(id) for a specific scan and scanInfos() to get the infos for all scans. There's also a ScanInfo class that holds the result, so it's possible to do

id = client.submit(cmds, 'My First Scan')
print id

# Could poll scanInfo until scan is done
info = client.scanInfo(id)
print info

# Shortcut for waiting until it'd done
info = client.waitUntilDone(id)
print info

There should be other methods like scanLog(id) to get the logged data of a scan, lastLogSerial(id) to get the serial for that scan, ..., and finally scanCommands(id) to read the commands.

ksdj commented 9 years ago

The rest of scaninfo part inclues :last_serial, commands, devices ,data. Should all these be implemented in ScanInfo Class? This will give a good encapsulation. But the their request urls are different so that they must be implemented in ScanClient Class. Such that, the use case would be like this: sc = ScanClient('localhost','4810') scinfo = sc.scanInfo(447)

get scan basic info:

scinfo .state scinfo .name ...

get the rest info:

sc.lastSerial(447) sc.scanDevs(447) sc.lastSerial(447) sc.getData(447) We can see that the query for info for a scan lacks integrity.Rookie users may get confused since they have to remember there are 4 infomation are not called through the ScanInfo Object. If all these methods can be called from ScanInfo object that would be perfect in form. What do you think?