Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
ADC Testing
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
ADC Testing
Commits
d703f490
Commit
d703f490
authored
Sep 01, 2011
by
Federico Asara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Item API and Pyro4 support added.
Added documentation and scale method.
parent
15ecd74a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
10 deletions
+39
-10
SineWaveform.py
PAGE/SineWaveform.py
+39
-10
No files found.
PAGE/SineWaveform.py
View file @
d703f490
import
Waveform
from
Utilities
import
*
from
numpy
import
*
import
Pyro4
import
Pyro4.util
import
sys
class
SineWaveform
(
Waveform
.
Waveform
):
_parameters
=
{
'frequency'
:(
'Frequency'
,
'Frequency of the sinewave, in HZ'
,
1000
,
float
),
'amplitude'
:(
'Amplitude'
,
'Amplitude of the sinewave, in Vpp'
,
1
,
float
),
'dc'
:(
'DC Compoment'
,
'DC component of the sinewave, in Vpp'
,
1
,
float
)}
def
get
(
self
,
what
):
return
self
.
__getattribute__
(
what
)
def
set
(
self
,
what
,
how
):
self
.
__setattr__
(
what
,
how
)
_parameters
=
{
'frequency'
:[
'Frequency'
,
'Frequency of the sinewave, in HZ'
,
1000
,
float
],
'amplitude'
:[
'Amplitude'
,
'Amplitude of the sinewave, in Vpp'
,
1
,
float
],
'dc'
:[
'DC Compoment'
,
'DC component of the sinewave, in Vpp'
,
0
,
float
]}
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
parameters
=
dict
(
self
.
_parameters
)
for
i
in
kwargs
:
if
i
in
self
.
parameters
.
keys
():
self
.
parameters
[
i
][
2
]
=
kwargs
[
i
]
for
i
in
self
.
parameters
.
keys
():
self
.
__setattr__
(
i
,
self
.
parameters
[
i
][
2
])
Waveform
.
Waveform
.
__init__
(
self
,
*
args
,
**
kwargs
)
def
generate
(
self
,
sampleRate
,
samples
,
nbits
,
fsr
):
f
=
self
.
frequency
...
...
@@ -27,3 +30,29 @@ class SineWaveform(Waveform.Waveform):
lsb
=
fsr
/
(
2
**
nbits
)
return
(
s
/
lsb
)
.
astype
(
int
)
def
scale
(
self
,
factor
):
"""Multiply the frequency by factor."""
self
.
frequency
*=
factor
return
self
name
=
'Sine Waveform'
target
=
SineWaveform
import
commands
def
launch
():
g
=
target
()
hn
=
commands
.
getoutput
(
'hostname'
)
daemon
=
Pyro4
.
Daemon
(
host
=
hn
)
myUri
=
daemon
.
register
(
g
)
ns
=
Pyro4
.
locateNS
()
ns
.
register
(
"Sine"
,
myUri
)
daemon
.
requestLoop
()
if
__name__
==
'__main__'
:
launch
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment