funcgen 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/README.md +24 -0
- data/bin/funcgen +112 -0
- data/funcgen.gemspec +20 -0
- data/lib/funcgen.rb +5 -0
- data/lib/funcgen/version.rb +3 -0
- metadata +51 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cd378d10cc86eb7ac4aa857d005265ca57e71c0a
|
4
|
+
data.tar.gz: 11da13aefe90f48812eb48204c7e68ea34d90d34
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f3acf452e1cc5bc463d6b9409ee54b9f11405fdb6dba20d90d601da6ff96f3173f5623e4d0019afec8aa82be3efb095cc1f393ca66f410f758539d2a1603d51e
|
7
|
+
data.tar.gz: 1f2b6166dd88bd15637c297a2447885d8d02d533049a83e4460320b09035b17d6670172a6d2e492575f053021a3e5460aac2e6576c60ba1f664ad601780123ab
|
data/.gitignore
ADDED
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Funcgen
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/funcgen`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
$ gem install funcgen
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
TODO: Write usage instructions here
|
14
|
+
|
15
|
+
## Development
|
16
|
+
|
17
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
18
|
+
|
19
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
20
|
+
|
21
|
+
## Contributing
|
22
|
+
|
23
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/szechyjs/funcgen.
|
24
|
+
|
data/bin/funcgen
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'socket'
|
4
|
+
require 'optparse'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
options = {}
|
8
|
+
OptionParser.new do |opts|
|
9
|
+
opts.banner = "Usage: funcgen.rb [options]"
|
10
|
+
|
11
|
+
opts.on("-F", "--func FUNC", [:sin, :squ, :ramp, :puls, :nois, :dc],
|
12
|
+
"Function type",
|
13
|
+
" sin: sinusoid wave",
|
14
|
+
" squ: square wave",
|
15
|
+
" ramp: ramp wave",
|
16
|
+
" puls: pulse wave",
|
17
|
+
" nois: gaussian noise",
|
18
|
+
" dc: DC voltage") do |f|
|
19
|
+
options[:func] = f
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.on("--off", "Turn output off") do
|
23
|
+
options[:output] = 'OFF'
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.on("--on", "Turn output on") do
|
27
|
+
options[:output] = 'ON'
|
28
|
+
end
|
29
|
+
|
30
|
+
opts.separator ""
|
31
|
+
opts.separator "Function Parameters"
|
32
|
+
|
33
|
+
opts.on("-f", "--freq Hz", Float, "Output frequency") do |f|
|
34
|
+
options[:frequency] = f
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on("-v", "--volts V", Float, "Output voltage") do |v|
|
38
|
+
options[:volts] = v
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on("-o", "--offset V", Float, "Output offset") do |v|
|
42
|
+
options[:offset] = v
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.separator ""
|
46
|
+
opts.separator "Global Options"
|
47
|
+
|
48
|
+
opts.on("-c", "--config FILE", "Config file") do |c|
|
49
|
+
options[:config] = c
|
50
|
+
end
|
51
|
+
|
52
|
+
opts.on("-d", "--debug", "Verbose commands") do |v|
|
53
|
+
options[:debug] = v
|
54
|
+
end
|
55
|
+
|
56
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
57
|
+
puts opts
|
58
|
+
exit
|
59
|
+
end
|
60
|
+
|
61
|
+
end.parse!
|
62
|
+
|
63
|
+
if options[:config]
|
64
|
+
config_file = options[:config]
|
65
|
+
else
|
66
|
+
config_file = File.expand_path('~/.funcgen.yml')
|
67
|
+
end
|
68
|
+
|
69
|
+
if File.exist?(config_file)
|
70
|
+
config = YAML.load_file(config_file)
|
71
|
+
else
|
72
|
+
abort "Config file does not exist: #{config_file}"
|
73
|
+
end
|
74
|
+
|
75
|
+
cmds = []
|
76
|
+
|
77
|
+
if options[:func]
|
78
|
+
func = options[:func].to_s.upcase
|
79
|
+
freq = options[:frequency].nil? ? 'DEF' : options[:frequency].to_s
|
80
|
+
|
81
|
+
if options[:func] == :dc
|
82
|
+
if options[:offset]
|
83
|
+
offset = options[:offset].to_s
|
84
|
+
else
|
85
|
+
offset = options[:volts].nil? ? 'DEF' : options[:volts].to_s
|
86
|
+
end
|
87
|
+
volts = 'DEF'
|
88
|
+
else
|
89
|
+
volts = options[:volts].nil? ? 'DEF' : options[:volts].to_s
|
90
|
+
offset = options[:offset].nil? ? 'DEF' : options[:offset].to_s
|
91
|
+
end
|
92
|
+
|
93
|
+
cmds << "OUTput:LOAD INF"
|
94
|
+
cmds << "APPLy:#{func} #{freq}, #{volts}, #{offset}"
|
95
|
+
end
|
96
|
+
|
97
|
+
if options[:output]
|
98
|
+
cmds << "OUTput #{options[:output]}"
|
99
|
+
end
|
100
|
+
|
101
|
+
if cmds.empty?
|
102
|
+
abort("Must specify a function or on/off argument")
|
103
|
+
else
|
104
|
+
s = TCPSocket.open config['host'], config['port']
|
105
|
+
|
106
|
+
cmds.each do |cmd|
|
107
|
+
if options[:debug]
|
108
|
+
puts cmd
|
109
|
+
end
|
110
|
+
s.write "#{cmd}\n"
|
111
|
+
end
|
112
|
+
end
|
data/funcgen.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'funcgen/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "funcgen"
|
8
|
+
spec.version = Funcgen::VERSION
|
9
|
+
spec.authors = ["Jared Szechy"]
|
10
|
+
spec.email = ["jared.szechy@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{CLI tool for Agilent function generators.}
|
13
|
+
spec.homepage = "https://github.com/szechyjs/funcgen"
|
14
|
+
spec.license = "GPLv3"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "bin"
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
end
|
data/lib/funcgen.rb
ADDED
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: funcgen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jared Szechy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-08 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- jared.szechy@gmail.com
|
16
|
+
executables:
|
17
|
+
- funcgen
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".gitignore"
|
22
|
+
- README.md
|
23
|
+
- bin/funcgen
|
24
|
+
- funcgen.gemspec
|
25
|
+
- lib/funcgen.rb
|
26
|
+
- lib/funcgen/version.rb
|
27
|
+
homepage: https://github.com/szechyjs/funcgen
|
28
|
+
licenses:
|
29
|
+
- GPLv3
|
30
|
+
metadata: {}
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
requirements: []
|
46
|
+
rubyforge_project:
|
47
|
+
rubygems_version: 2.4.8
|
48
|
+
signing_key:
|
49
|
+
specification_version: 4
|
50
|
+
summary: CLI tool for Agilent function generators.
|
51
|
+
test_files: []
|