示例#1
0
    def measure(self, sigramp):
        print('Opening Connection')
        ret = self.open_connection()
        self.pstat.SetIERange(8)

        print(ret)
        # push the signal ramp over
        print('Pushing')
        self.pstat.SetSignal(sigramp)

        self.pstat.SetCell(self.GamryCOM.CellOn)
        self.measurement_setup()
        self.connection = client.GetEvents(self.dtaqcpiv, self.dtaqsink)
        try:
            self.dtaqcpiv.Run(True)
        except Exception as e:
            raise gamry_error_decoder(e)
        self.data = collections.defaultdict(list)
        client.PumpEvents(0.001)
        sink_status = self.dtaqsink.status
        while sink_status != "done":
            client.PumpEvents(0.001)
            sink_status = self.dtaqsink.status
            dtaqarr = self.dtaqsink.acquired_points
            self.data = dtaqarr
        self.pstat.SetCell(self.GamryCOM.CellOff)
        self.close_connection()
示例#2
0
    def measure(self, sigramp, gsetup=None):
        print("Opening Connection")
        ret = self.open_connection()
        self.pstat.SetIERange(8)
        # IErange: 0=3 pA, 1=30pA, 2=300pA, 3=3nA, 4=30nA, 5=300nA, 6=3uA, ...
        #TODO: IERange is a parameter and should be placed somewhere else

        print(ret)
        # push the signal ramp over
        print("Pushing")
        self.pstat.SetSignal(sigramp)

        self.pstat.SetCell(self.GamryCOM.CellOn)
        if gsetup == None:
            self.measurement_setup()
        else:
            self.measurement_setup(gsetup)  #TODO: good to add gsetup?
        self.connection = client.GetEvents(self.dtaqcpiv, self.dtaqsink)
        try:
            self.dtaqcpiv.Run(True)
        except Exception as e:
            raise gamry_error_decoder(e)
        self.data = collections.defaultdict(list)
        client.PumpEvents(0.001)
        sink_status = self.dtaqsink.status
        while sink_status != "done":
            client.PumpEvents(0.001)
            sink_status = self.dtaqsink.status
            dtaqarr = self.dtaqsink.acquired_points
            self.data = dtaqarr
        self.pstat.SetCell(self.GamryCOM.CellOff)
        self.close_connection()
示例#3
0
    def ocv(self, start_freq, end_freq, points, pot_offset=0):
        Zreal, Zimag, Zsig, Zphz, Zfreq = [], [], [], [], []
        is_on = False
        self.pstat.Open()
        if offset != 0:
            self.pstat.SetVchOffsetEnable(True)
            if self.pstat.VchOffsetEnable():
                self.poti.pstat.SetVchOffset(pot_offset)
            else:
                print("Have offset but could not enable")
        for f in np.logspace(np.log10(start_freq), np.log10(end_freq), points):

            self.dtaqcpiv = client.CreateObject("GamryCOM.GamryDtaqEis")
            self.dtaqcpiv.Init(self.pstat, f, 0.1, 0.5, 20)
            self.dtaqcpiv.SetCycleMin(100)
            self.dtaqcpiv.SetCycleMax(50000)

            if not is_on:
                self.pstat.SetCell(self.GamryCOM.CellOn)
                is_on = True
            self.dtaqsink = GamryDtaqEvents(self.dtaqcpiv)

            connection = client.GetEvents(self.dtaqcpiv, self.dtaqsink)

            try:
                self.dtaqcpiv.Run(True)
            except Exception as e:
                raise gamry_error_decoder(e)
            if f < 10:
                client.PumpEvents(10)
            else:
                client.PumpEvents(1)

            Zreal.append(self.dtaqsink.dtaq.Zreal())
            Zimag.append(self.dtaqsink.dtaq.Zimag())
            Zsig.append(self.dtaqsink.dtaq.Zsig())
            Zphz.append(self.dtaqsink.dtaq.Zphz())
            Zfreq.append(self.dtaqsink.dtaq.Zfreq())
            print(self.dtaqsink.dtaq.Zfreq())
            del connection
        self.pstat.SetCell(self.GamryCOM.CellOff)
        self.pstat.Close()
        return {
            "measurement_type": "eis",
            "parameters": {
                "tart_freq": start_freq,
                "end_freq": end_freq,
                "points": points,
                "pot_offset": pot_offset,
            },
            "data": [Zreal, Zimag, Zfreq],
        }
示例#4
0
    def eis(self, start_freq, end_freq, points, pot_offset=0):
        Zreal, Zimag, Zsig, Zphz, Zfreq = [], [], [], [], []
        is_on = False
        self.pstat.Open()
        for f in np.logspace(np.log10(start_freq), np.log10(end_freq), points):

            self.dtaqcpiv = client.CreateObject('GamryCOM.GamryDtaqEis')
            self.dtaqcpiv.Init(self.pstat, f, 0.05, 0.5, 20)
            self.dtaqcpiv.SetCycleMin(100)
            self.dtaqcpiv.SetCycleMax(50000)

            if not is_on:
                self.pstat.SetCell(self.GamryCOM.CellOn)
                is_on = True
            self.dtaqsink = GamryDtaqEvents(self.dtaqcpiv)

            connection = client.GetEvents(self.dtaqcpiv, self.dtaqsink)

            try:
                self.dtaqcpiv.Run(True)
            except Exception as e:
                raise gamry_error_decoder(e)
            if f < 10:
                client.PumpEvents(10)
            if f > 1000:
                client.PumpEvents(0.1)
            if f < 1000:
                client.PumpEvents(1)

            Zreal.append(self.dtaqsink.dtaq.Zreal())
            Zimag.append(self.dtaqsink.dtaq.Zimag())
            Zsig.append(self.dtaqsink.dtaq.Zsig())
            Zphz.append(self.dtaqsink.dtaq.Zphz())
            Zfreq.append(self.dtaqsink.dtaq.Zfreq())
            print(self.dtaqsink.dtaq.Zfreq())
            del connection
        self.pstat.SetCell(self.GamryCOM.CellOff)
        self.pstat.Close()
        return {
            'measurement_type': 'eis',
            'parameters': {
                'tart_freq': start_freq,
                'end_freq': end_freq,
                'points': points,
                'pot_offset': pot_offset
            },
            'data': [Zreal, Zimag, Zfreq]
        }
示例#5
0
 def perform_single_measurement(self,frequency,amplitude):
     # Start a measurement. For each point alone
     # FIXME (on API level): There is a bug so that the first datapoint is measured(?) and returned twice. 
     pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED)
     self.wait_time_after_each_measurement = 2+self.cycle_max/frequency
     try:
         if self.mode == "Potentiostat":
             print "measuring...",frequency,"Hz ",amplitude,"mV ",self.wait_time_after_each_measurement,"sec sleeptime"
         elif self.mode == "Galvanostat":
             print "measuring...",frequency,"Hz ",amplitude,"mA ",self.wait_time_after_each_measurement,"sec sleeptime"
         self.pstat.SetCell(GamryCOM.CellOn)
         time.sleep(1)
         self.readz.Measure(frequency,amplitude)
         print "Command sent"
         client.PumpEvents(1)
         global current_datapoint_has_been_measured
         while not current_datapoint_has_been_measured:
             time.sleep(2)
         current_datapoint_has_been_measured = False
     except Exception as e:
         raise gamry_error_decoder(e)
     pythoncom.CoUninitialize() # Windows shit
     return
#  create sink class to receive events
sink = TrueDataExternalEventsSink()

#  advise the sink to make it receiving events
advise = cc.GetEvents(truedata, sink)

#  initialize API
truedata.VelocityInitialize()

#  wait while Velocity starts
truedata.VelocityWaitForReadyToProcess()
print("Velocity has been started", datetime.datetime.now())

datefrom = datetime2ole(datetime.datetime.utcnow() -
                        datetime.timedelta(minutes=deltamins))
dateto = datetime2ole(datetime.datetime.utcnow())
RequestIdTicks = truedata.RequestTicks(symbol_list[sindex], datefrom, dateto)

#  Tick  History Data

#  just wait for 5000 seconds before exit
cc.PumpEvents(10000)
#  stop to receive real-time
# truedata.RequestRealTimeStop("NIFTY-I")
#  uninitialize API
truedata.VelocityUninitialize()
#  stop advise (Force python to delete the object & free the memory)
advise = None

# price_type can be referred here
示例#7
0
RequestIdDays = truedata.RequestDaily(history_symbol, datefrom, dateto)
print("Request id for days: ", RequestIdDays)

#  Minute Data (1, 5, 15, 60 mins - replace in RequestMinutes)
datefrom = datetime2ole(datetime.datetime.now() - datetime.timedelta(days=4))
RequestIdMinutes = truedata.RequestMinutes(history_symbol, datefrom, dateto, 1)
print()
print("Request id for minutes: ", RequestIdMinutes)

#  Tick  History Data
# datefrom = datetime2ole(datetime.datetime.utcnow()-datetime.timedelta(hours=12))
# RequestIdTicks = truedata.RequestTicks(history_symbol, datefrom, dateto)
# print("Request id for ticks: ", RequestIdTicks)

#  just wait for 5000 seconds before exit
cc.PumpEvents(5000)
#  stop to receive real-time
truedata.RequestRealTimeStop("NIFTY-I")
#  uninitialize API
truedata.VelocityUninitialize()
#  stop advise (Force python to delete the object & free the memory)
advise = None

# price_type can be referred here

# enum {
#    TrueDataFields_BID = 1,
#     TrueDataFields_ASK = 2,
#     TrueDataFields_HIGH = 3,
#     TrueDataFields_LOW = 4,
#     TrueDataFields_OPEN = 5,
pstat.Init(devices.EnumSections()[0])  # grab first pstat

pstat.Open()

dtaqcpiv = client.CreateObject('GamryCOM.GamryDtaqCpiv')
dtaqcpiv.Init(pstat)

sigramp = client.CreateObject('GamryCOM.GamrySignalRamp')
sigramp.Init(pstat, -0.25, 0.25, 1, 0.01, GamryCOM.PstatMode)

pstat.SetSignal(sigramp)
pstat.SetCell(GamryCOM.CellOn)

dtaqsink = GamryDtaqEvents(dtaqcpiv)

# Use the following code to discover events:
#client.ShowEvents(dtaqcpiv)
connection = client.GetEvents(dtaqcpiv, dtaqsink)

try:
    dtaqcpiv.Run(True)
except Exception as e:
    raise gamry_error_decoder(e)

client.PumpEvents(1)
print len(dtaqsink.acquired_points)

del connection

pstat.Close()
 def __call__(self):
     text = self.text
     events = comcli.ShowEvents(cm15a)
     comcli.PumpEvents(1)

pstat=client.CreateObject('GamryCOM.GamryPstat')
pstat.Init(devices.EnumSections()[0]) # grab first pstat
pstat.Open()
pstat.SetCtrlMode(GamryCOM.PstatMode)
pstat.SetCell(GamryCOM.CellOn)

dtaqchrono=client.CreateObject('GamryCOM.GamryDtaqChrono')
dtaqchrono.Init(pstat, GamryCOM.ChronoAmp)
dtaqsink = GamryDtaqEvents(dtaqchrono)
client.ShowEvents(dtaqcpiv)

#two-part step waveform
sigstep=client.CreateObject('GamryCOM.GamrySignalStep')
sigstep.Init(pstat, 0.5, 15, -0.1, 15, 0.01, GamryCOM.PstatMode)

pstat.SetSignal(sigstep)


try:
    dtaqchrono.Run(True)
except Exception as e:
    print("Big drama show")

client.PumpEvents(60)
print(len(dtaqsink.acquired_points))

del connection

pstat.Close()
示例#11
0
pstat = client.CreateObject('GamryCOM.GamryPC6Pstat')
pstat.Init(devices.EnumSections()[0])  # grab first pstat

################################ OCV

dtaqcpiv = client.CreateObject('GamryCOM.GamryDtaqOcv')
pstat.Open()
dtaqcpiv.Init(pstat)
pstat.SetCell(GamryCOM.CellOn)
dtaqsink = GamryDtaqEvents(dtaqcpiv)
connection = client.GetEvents(dtaqcpiv, dtaqsink)
try:
    dtaqcpiv.Run(True)
except Exception as e:
    raise gamry_error_decoder(e)
client.PumpEvents(3)
pstat.SetCell(GamryCOM.CellOff)
pstat.Close()


################################ EIS
from tqdm import tqdm
Zreal,Zimag,Zsig,Zphz,Zfreq = [],[],[],[],[]
is_on = False
pstat.Open()
for f in tqdm(np.logspace(0,5,60)):

    dtaqcpiv = client.CreateObject('GamryCOM.GamryDtaqEis')
    dtaqcpiv.Init(pstat,f,0.1,0.5,2)
    dtaqcpiv.SetCycleMin(10)
    dtaqcpiv.SetCycleMax(5000)