Skip to content

Commit

Permalink
Merge pull request #17 from bklebel/deepsource-transform-95839859
Browse files Browse the repository at this point in the history
Format code with black
  • Loading branch information
bklebel authored Sep 17, 2020
2 parents 82202c4 + 6b25276 commit ef655ce
Show file tree
Hide file tree
Showing 7 changed files with 1,008 additions and 677 deletions.
207 changes: 131 additions & 76 deletions measureSequences/Dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,44 @@
"""
import numpy as np
from threading import Lock

# import json

from .runSequences import Sequence_runner
from .Sequence_parsing import Sequence_parser


class Dummy_Functions():
class Dummy_Functions:
"""docstring for Functions"""

def setTemperature(self, temperature: float) -> None:
"""
Method to be overridden/injected by a child class
here, all logic which is needed to go to a
certain temperature directly
needs to be implemented.
TODO: override method
Method to be overridden/injected by a child class
here, all logic which is needed to go to a
certain temperature directly
needs to be implemented.
TODO: override method
"""
print('setTemperature :: temp = {}'.format(temperature))
print("setTemperature :: temp = {}".format(temperature))

def setField(self, field: float, EndMode: str) -> None:
"""
Method to be overridden/injected by a child class
here, all logic which is needed to go to a certain field directly
needs to be implemented.
TODO: override method
Method to be overridden/injected by a child class
here, all logic which is needed to go to a certain field directly
needs to be implemented.
TODO: override method
"""
print(f'setField :: field = {field}, EndMode = {EndMode}')
print(f"setField :: field = {field}, EndMode = {EndMode}")

def setPosition(self, position: float, speedindex: float) -> None:
"""
Method to be overridden/injected by a child class
here, all logic which is needed to go to a
certain position directly
needs to be implemented.
TODO: override method
Method to be overridden/injected by a child class
here, all logic which is needed to go to a
certain position directly
needs to be implemented.
TODO: override method
"""
print(f'setPosition :: pos = {position}, speedindex = {speedindex}')
print(f"setPosition :: pos = {position}, speedindex = {speedindex}")

def message_to_user(self, message: str) -> None:
"""deliver a message to a user in some way
Expand All @@ -51,13 +52,13 @@ def message_to_user(self, message: str) -> None:
"""
# super().message_to_user(message)
# print(message)
print(f'message_to_user :: message = {message}')
print(f"message_to_user :: message = {message}")


class Dummy(Sequence_runner, Dummy_Functions):
"""docstring for Dummy"""

def __init__(self, filename='', **kwargs):
def __init__(self, filename="", **kwargs):
if filename:

parser = Sequence_parser(sequence_file=filename)
Expand All @@ -70,35 +71,66 @@ def __init__(self, filename='', **kwargs):
super().__init__(**kwargs)
# self.subrunner_class = Dummy

def scan_T_programSweep(self, start: float, end: float, Nsteps: float, temperatures: list, SweepRate: float, SpacingCode: str = 'uniform'):
def scan_T_programSweep(
self,
start: float,
end: float,
Nsteps: float,
temperatures: list,
SweepRate: float,
SpacingCode: str = "uniform",
):
"""
Method to be overriden by a child class
here, the devices should be programmed to start
the respective Sweep of temperatures
Method to be overriden by a child class
here, the devices should be programmed to start
the respective Sweep of temperatures
"""
print(f'scan_T_programSweep :: start: {start}, end: {end}, Nsteps: {Nsteps}, temps: {temperatures}, Rate: {SweepRate}, SpacingCode: {SpacingCode}')

def scan_H_programSweep(self, start: float, end: float, Nsteps: float, fields: list, SweepRate: float, EndMode: str, SpacingCode: str = 'uniform'):
print(
f"scan_T_programSweep :: start: {start}, end: {end}, Nsteps: {Nsteps}, temps: {temperatures}, Rate: {SweepRate}, SpacingCode: {SpacingCode}"
)

def scan_H_programSweep(
self,
start: float,
end: float,
Nsteps: float,
fields: list,
SweepRate: float,
EndMode: str,
SpacingCode: str = "uniform",
):
"""
Method to be overriden by a child class
here, the devices should be programmed to start
the respective Sweep for field values
Method to be overriden by a child class
here, the devices should be programmed to start
the respective Sweep for field values
"""
print(f'scan_H_programSweep :: start: {start}, end: {end}, Nsteps: {Nsteps}, fields: {fields}, Rate: {SweepRate}, SpacingCode: {SpacingCode}, EndMode: {EndMode}')

def scan_P_programSweep(self, start: float, end: float, Nsteps: float, positions: list, speedindex: float, SpacingCode: str = 'uniform'):
print(
f"scan_H_programSweep :: start: {start}, end: {end}, Nsteps: {Nsteps}, fields: {fields}, Rate: {SweepRate}, SpacingCode: {SpacingCode}, EndMode: {EndMode}"
)

def scan_P_programSweep(
self,
start: float,
end: float,
Nsteps: float,
positions: list,
speedindex: float,
SpacingCode: str = "uniform",
):
"""
Method to be overriden by a child class
here, the devices should be programmed to start
the respective Sweep of positions
Method to be overriden by a child class
here, the devices should be programmed to start
the respective Sweep of positions
"""
print(f'scan_T_programSweep :: start: {start}, end: {end}, Nsteps: {Nsteps}, positions: {positions}, speedindex: {speedindex}, SpacingCode: {SpacingCode}')
print(
f"scan_T_programSweep :: start: {start}, end: {end}, Nsteps: {Nsteps}, positions: {positions}, speedindex: {speedindex}, SpacingCode: {SpacingCode}"
)

def setFieldEndMode(self, EndMode: str) -> bool:
"""Method to be overridden by a child class
return bool stating success or failure (optional)
"""
print(f'setFieldEndMode :: EndMode = {EndMode}')
print(f"setFieldEndMode :: EndMode = {EndMode}")

def getTemperature(self) -> float:
"""Read the temperature
Expand All @@ -108,18 +140,18 @@ def getTemperature(self) -> float:
returns: temperature as a float
"""
val = np.random.rand() * 300
print(f'getTemperature :: returning random value: {val}')
print(f"getTemperature :: returning random value: {val}")
return val

def getPosition(self) -> float:
"""
Method to be overriden by child class
implement checking the position
Method to be overriden by child class
implement checking the position
returns: position as a float
returns: position as a float
"""
val = np.random.rand() * 360
print(f'getPosition :: returning random value: {val}')
print(f"getPosition :: returning random value: {val}")
return val

def getField(self) -> float:
Expand All @@ -130,7 +162,7 @@ def getField(self) -> float:
returns: Field as a float
"""
val = np.random.rand() * 9
print(f'getField :: returning random value: {val}')
print(f"getField :: returning random value: {val}")
return val

def getChamber(self):
Expand All @@ -141,10 +173,12 @@ def getChamber(self):
returns: chamber status
"""
val = np.random.rand() * 4
print(f'getChamber :: returning random value: {val}')
print(f"getChamber :: returning random value: {val}")
return val

def checkStable_Temp(self, temp: float, direction: int = 0, ApproachMode: str = 'Sweep') -> bool:
def checkStable_Temp(
self, temp: float, direction: int = 0, ApproachMode: str = "Sweep"
) -> bool:
"""wait for the temperature to stabilize
param: Temp:
Expand All @@ -165,9 +199,13 @@ def checkStable_Temp(self, temp: float, direction: int = 0, ApproachMode: str =
method should be overriden - possibly some convenience functionality
will be added in the future
"""
print(f'checkstable_Temp :: Temp: {temp} is stable!, ApproachMode = {ApproachMode}, direction = {direction}')
print(
f"checkstable_Temp :: Temp: {temp} is stable!, ApproachMode = {ApproachMode}, direction = {direction}"
)

def checkField(self, Field: float, direction: int = 0, ApproachMode: str = 'Sweep') -> bool:
def checkField(
self, Field: float, direction: int = 0, ApproachMode: str = "Sweep"
) -> bool:
"""check whether the Field has passed a certain value
param: Field:
Expand All @@ -188,9 +226,13 @@ def checkField(self, Field: float, direction: int = 0, ApproachMode: str = 'Swee
method should be overriden - possibly some convenience functionality
will be added in the future
"""
print(f'checkField :: Field: {Field} is stable!, ApproachMode = {ApproachMode}, direction = {direction}')
print(
f"checkField :: Field: {Field} is stable!, ApproachMode = {ApproachMode}, direction = {direction}"
)

def checkPosition(self, position: float, direction: int = 0, ApproachMode: str = 'Sweep') -> bool:
def checkPosition(
self, position: float, direction: int = 0, ApproachMode: str = "Sweep"
) -> bool:
"""check whether the Field has passed a certain value
param: position:
Expand All @@ -211,80 +253,93 @@ def checkPosition(self, position: float, direction: int = 0, ApproachMode: str =
method should be overriden - possibly some convenience functionality
will be added in the future
"""
print(f'checkPosition :: position: {position} is stable!, ApproachMode = {ApproachMode}, direction = {direction}')
print(
f"checkPosition :: position: {position} is stable!, ApproachMode = {ApproachMode}, direction = {direction}"
)

def Shutdown(self):
"""Shut down instruments to a safe standby-configuration"""
print('Shutdown :: going into safe shutdown mode')
print("Shutdown :: going into safe shutdown mode")

def chamber_purge(self):
"""purge the chamber
must block until the chamber is purged
"""
print('chamber_purge :: purging chamber')
print("chamber_purge :: purging chamber")

def chamber_vent(self):
"""vent the chamber
must block until the chamber is vented
"""
print('chamber_vent :: venting chamber')
print("chamber_vent :: venting chamber")

def chamber_seal(self):
"""seal the chamber
must block until the chamber is sealed
"""
print('chamber_seal :: sealing chamber')
print("chamber_seal :: sealing chamber")

def chamber_continuous(self, action):
"""pump or vent the chamber continuously"""
if action == 'pumping':
print('chamber_continuous :: pumping continuously')
if action == 'venting':
print('chamber_continuous :: venting continuously')
if action == "pumping":
print("chamber_continuous :: pumping continuously")
if action == "venting":
print("chamber_continuous :: venting continuously")

def chamber_high_vacuum(self):
"""pump the chamber to high vacuum
must block until the chamber is at high vacuum
"""
print('chamber_high_vacuum :: bringing the chamber to HV')
print("chamber_high_vacuum :: bringing the chamber to HV")

def res_measure(self, dataflags: dict, bridge_conf: dict) -> dict:
"""Measure resistivity
Must be overridden!
return dict with all data according to the set dataflags
Must be overridden!
return dict with all data according to the set dataflags
"""
print(f'res_measure :: measuring the resistivity with the following dataflags: {dataflags} and the following bridge configuration: {bridge_conf}')
print(
f"res_measure :: measuring the resistivity with the following dataflags: {dataflags} and the following bridge configuration: {bridge_conf}"
)
return dict(res1=5, exc1=10, res2=8, exc2=10)

def measuring_store_data(self, data: dict, datafile: str) -> None:
"""Store measured data
Must be overridden!
Must be overridden!
"""
print(f'measuring_store_data :: store the measured data: {data} in the file: {datafile}.')
print(
f"measuring_store_data :: store the measured data: {data} in the file: {datafile}."
)

def res_datafilecomment(self, comment: str, datafile: str) -> None:
"""write a comment to the datafile
Must be overridden!
Must be overridden!
"""
print(f'res_datafilecomment :: write a comment: {comment} in the datafile: {datafile}.')
print(
f"res_datafilecomment :: write a comment: {comment} in the datafile: {datafile}."
)

def res_change_datafile(self, datafile: str, mode: str) -> None:
"""change the datafile (location)
Must be overridden!
mode ('a' or 'w') determines whether data should be
'a': appended
'w': written over
(to) the new datafile
Must be overridden!
mode ('a' or 'w') determines whether data should be
'a': appended
'w': written over
(to) the new datafile
"""
print(f'res_change_datafile :: change the datafile to: {datafile}, with mode {mode}.')
print(
f"res_change_datafile :: change the datafile to: {datafile}, with mode {mode}."
)


if __name__ == '__main__':
dummy = Dummy(lock=Lock(), filename='seqfiles\\beepingsequence.seq',
thresholds_waiting=dict(Temp=0.1, Field=0.1, Position=30))
if __name__ == "__main__":
dummy = Dummy(
lock=Lock(),
filename="seqfiles\\beepingsequence.seq",
thresholds_waiting=dict(Temp=0.1, Field=0.1, Position=30),
)
# QTimer.singleShot(3*1e3, lambda: dummy.stop())
print(dummy.running())
Loading

0 comments on commit ef655ce

Please sign in to comment.