Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tiqi-js-tutorial
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Matt Grau
tiqi-js-tutorial
Commits
34e7c2d0
Commit
34e7c2d0
authored
3 years ago
by
Matt Grau
Browse files
Options
Downloads
Patches
Plain Diff
update device class to use decorators
parent
d5e50793
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
device/device.py
+23
-1
23 additions, 1 deletion
device/device.py
with
23 additions
and
1 deletion
device/device.py
+
23
−
1
View file @
34e7c2d0
...
...
@@ -20,9 +20,17 @@ class Device:
# write voltage to device
self
.
__voltage
=
new_voltage
@property
def
voltage
(
self
):
return
self
.
_get_voltage
()
@voltage.setter
def
voltage
(
self
,
new_voltage
):
self
.
_set_voltage
(
new_voltage
)
def
_get_current
(
self
):
# read current from device
current
=
self
.
__curent
current
=
self
.
__cur
r
ent
self
.
current
=
current
return
current
...
...
@@ -30,8 +38,22 @@ class Device:
# write current to device
self
.
__current
=
new_current
@property
def
current
(
self
):
return
self
.
_get_current
()
@current.setter
def
current
(
self
,
new_current
):
self
.
_set_current
(
new_current
)
def
_calculate_resistance
(
self
):
if
self
.
current
==
0
:
return
float
(
'
inf
'
)
current
=
self
.
current
voltage
=
self
.
voltage
resistance
=
voltage
/
current
return
resistance
@property
def
resistance
(
self
):
return
self
.
_calculate_resistance
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment