~ubuntu-branches/ubuntu/oneiric/electric/oneiric

« back to all changes in this revision

Viewing changes to com/sun/electric/tool/simulation/test/HP6624AChannel.java

  • Committer: Bazaar Package Importer
  • Author(s): Onkar Shinde
  • Date: 2010-01-09 16:26:04 UTC
  • mfrom: (1.1.4 upstream) (3.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100109162604-1ypvmy8ijmlc6oq7
Tags: 8.10-1
* New upstream version.
* debian/control
  - Add libjava3d-java and quilt build dependencies.
  - Update standards version to 3.8.3.
  - Add libjava3d-java as recommends to binary package.
* debian/rules
  - Use quilt patch system instead of simple patchsys.
  - Add java3d related jar files to DEB_JARS.
* debian/patches/*
  - Update as per current upstream source. Convert to quilt.
* debian/ant.properties
  - Do not disable 3D plugin anymore.
  - Use new property to disable compilation of OS X related classes.
* debian/wrappers/electric
  - Add java3d related jar files to runtime classpath.
* debian/README.source
  - Change text to the appropriate one for quilt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package com.sun.electric.tool.simulation.test;
 
2
 
 
3
/* HP6624AChannel.java
 
4
 * 
 
5
 * Copyright (c) 2005 by Sun Microsystems, Inc.
 
6
 *
 
7
 * Created on Jul 21, 2005
 
8
 */
 
9
 
 
10
/**
 
11
 * Class for setting a voltage level supplied by a single channel of an HP 6624A
 
12
 * programmable DC power supply, using the device-independent interface
 
13
 * {@link PowerChannel}.
 
14
 * <P>
 
15
 * This class should now be instantiated from a {@link Model#createPowerChannel(String, String, int, int, String)}
 
16
 *
 
17
 * @author Tom O'Neill (toneill)
 
18
 */
 
19
public class HP6624AChannel extends PowerChannel {
 
20
 
 
21
    /**
 
22
     * The HP 6624A programmable DC power supply that provides the voltage level
 
23
     * in question
 
24
     */
 
25
    private final HP6624A supply;
 
26
 
 
27
    /** Channel of power supply that supplies the voltage */
 
28
    private final int channel;
 
29
 
 
30
    /**
 
31
     * Creates an object to control a HP 6624A power supply using the methods of
 
32
     * the device-independent PowerChannel abstract class.
 
33
     * <P>
 
34
     * Instead of this, you should use
 
35
     * {@link Model#createPowerChannel(String, String, int, int, String)}.
 
36
     * I have left it public for backwards compatability. 
 
37
     * 
 
38
     * @param channelName
 
39
     *            name of signal on this channel of the power supply
 
40
     * @param supplyName
 
41
     *            <code>gpibconf</code> identifier for the power supply
 
42
     * @param channel
 
43
     *            Channel of the supply to control
 
44
     */
 
45
    public HP6624AChannel(String channelName, String supplyName, int channel) {
 
46
        HP6624A.checkChannel(channel);
 
47
        this.name = channelName + " (" + supplyName + " channel " + channel
 
48
                + ")";
 
49
        supply = new HP6624A(supplyName);
 
50
        this.channel = channel;
 
51
        logInit("Initialized HP6624AChannel " + this.name);
 
52
    }
 
53
 
 
54
    /** @return Returns the name of the HP6624A */
 
55
    public String getSupplyName() {
 
56
        return supply.getName();
 
57
    }
 
58
 
 
59
    /**
 
60
     * @return Returns the channel number within the HP6624A device.
 
61
     */
 
62
    public int getChannel() {
 
63
        return channel;
 
64
    }
 
65
 
 
66
    /**
 
67
     * Returns string indicating state of the channels
 
68
     */
 
69
    public String getState() {
 
70
        return supply.getState(channel);
 
71
    }
 
72
 
 
73
    /**
 
74
     * Reads back the voltage provided by this channel of the power supply.
 
75
     * 
 
76
     * @return voltage drawn over this channel, in Volts
 
77
     */
 
78
    public float readVoltage() {
 
79
        logOther("Reading voltage on " + getName());
 
80
        return this.supply.readVoltage(this.channel);
 
81
    }
 
82
 
 
83
    /**
 
84
     * Set the channel's voltage to the value provided
 
85
     * 
 
86
     * @param volts
 
87
     *            new voltage for the channel, in Volts
 
88
     */
 
89
    public void setVoltageNoWait(float volts) {
 
90
        logSet("HP6624AChannel setting voltage on " + getName() + " to "
 
91
                + volts + " V");
 
92
        supply.setVoltage(this.channel, volts);
 
93
    }
 
94
 
 
95
    public void waitForVoltage(float setVolts) {
 
96
        if (supply.isDisabled())
 
97
            return;
 
98
        super.waitForVoltage(setVolts);
 
99
    }
 
100
 
 
101
    /**
 
102
     * Get the channel's voltage setpoint
 
103
     * 
 
104
     * @return voltage setpoint for the channel, in Volts
 
105
     */
 
106
    public float getVoltageSetpoint() {
 
107
        logOther("Reading voltage setpoint on " + getName());
 
108
        return this.supply.getVoltageSetpoint(this.channel);
 
109
    }
 
110
 
 
111
    /**
 
112
     * Returns voltage resolution of power supply.
 
113
     * 
 
114
     * @return voltage resolution of power supply
 
115
     */
 
116
    public float getVoltageResolution() {
 
117
        logOther("Getting voltage resolution on " + getName());
 
118
        return HP6624A.getVoltageResolution(this.channel);
 
119
    }
 
120
 
 
121
    /**
 
122
     * Reads back the current provided by this channel of the power supply.
 
123
     * 
 
124
     * @return current drawn over this channel, in Amps
 
125
     */
 
126
    public float readCurrent() {
 
127
        logOther("Reading current on " + getName());
 
128
        return this.supply.readCurrent(this.channel);
 
129
    }
 
130
 
 
131
    /**
 
132
     * Set the channel's current limit to the value provided
 
133
     * 
 
134
     * @param amps
 
135
     *            new current limit for the channel, in Amps
 
136
     */
 
137
    public void setCurrent(float amps) {
 
138
        logSet("Setting current limit on " + getName() + " to " + amps);
 
139
        supply.setCurrent(channel, amps);
 
140
    }
 
141
 
 
142
    /**
 
143
     * Get the channel's current setpoint
 
144
     * 
 
145
     * @return current setpoint for the channel, in Amps
 
146
     */
 
147
    public float getCurrentSetpoint() {
 
148
        logOther("Reading current setpoint on " + getName());
 
149
        return supply.getCurrentSetpoint(this.channel);
 
150
    }
 
151
    /**
 
152
     * Changes the voltage for the over voltage protection to 
 
153
     * <code>setVolts</code> Volts.
 
154
     * 
 
155
     * @param setVolts the new over-voltage limit
 
156
     * @throws IllegalArgumentException
 
157
     *             if channel not in range 1..4
 
158
     */
 
159
    public void setOverVoltageProtection(float setVolts) {
 
160
        logSet("Setting over voltage protection limit on " + getName() + " to " + setVolts);
 
161
        supply.setOverVoltageProtection(this.channel, setVolts);
 
162
    }
 
163
 
 
164
    /**
 
165
     * Changes the current for the over current protection to
 
166
     * <code>setAmps</code> Amps.
 
167
     * 
 
168
     * @param setAmps the new over-current limit
 
169
     * @throws IllegalArgumentException
 
170
     *             if channel not in range 1..4
 
171
     */
 
172
    public void setOverCurrentProtection(float setAmps) {
 
173
        logSet("Setting over current protection limit on " + getName() + " to " + setAmps);
 
174
        supply.setOverCurrentProtection(this.channel, setAmps);
 
175
    }
 
176
 
 
177
    /**
 
178
     * Unit tests, prints current as function of voltage for channel 1. Should
 
179
     * disconnect supply from any chips before waiting.
 
180
     * 
 
181
     * @param args
 
182
     *            Ignored
 
183
     */
 
184
    public static void main(String[] args) {
 
185
        Infrastructure.gpibControllers = new int[] { 1 };
 
186
        HP6624AChannel[] channels = new HP6624AChannel[HP6624A.NUM_CHANNELS];
 
187
        for (int chan = 1; chan <= HP6624A.NUM_CHANNELS; chan++) {
 
188
            int ichan = chan - 1;
 
189
            channels[ichan] = new HP6624AChannel("chan" + chan, "hHP6624A",
 
190
                    chan);
 
191
            System.out.println(chan + ": " + channels[ichan].getState());
 
192
            System.out.println("res " + channels[ichan].getVoltageResolution()
 
193
                    + "\n");
 
194
        }
 
195
 
 
196
    }
 
197
}