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

« back to all changes in this revision

Viewing changes to com/sun/electric/tool/simulation/test/Pst3202Channel.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
/* Pst3202Channel.java
 
4
 * 
 
5
 * Copyright (c) 2004,2005 by Sun Microsystems, Inc.
 
6
 *
 
7
 * Created on Jul 19, 2004
 
8
 */
 
9
 
 
10
/**
 
11
 * Class for setting a voltage level supplied by a single channel of an Instek
 
12
 * PST-3202 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 Pst3202Channel extends PowerChannel {
 
20
 
 
21
    /**
 
22
     * The Instek PST-3202 programmable DC power supply that provides the
 
23
     * voltage level in question
 
24
     */
 
25
    private final Pst3202 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 PST-3202 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 Pst3202Channel(String channelName, String supplyName, int channel) {
 
46
        Pst3202.checkChannel(channel);
 
47
        this.name = channelName + " (" + supplyName + " channel " + channel
 
48
                + ")";
 
49
        supply = new Pst3202(supplyName);
 
50
        this.channel = channel;
 
51
        logInit("Initialized Pst3202Channel " + this.name);
 
52
    }
 
53
 
 
54
    /** @return Returns the name of the Pst3202 */
 
55
    public String getSupplyName() {
 
56
        return supply.getName();
 
57
    }
 
58
 
 
59
    /**
 
60
     * @return Returns the channel number within the Pst3202 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("Pst3202Channel setting voltage on " + getName() + " to "
 
91
                + volts + " V");
 
92
        if (this.supply.setVoltage(this.channel, volts) == false) {
 
93
            try { Thread.sleep(1000); } catch (InterruptedException _) { }
 
94
            if (this.supply.setVoltage(this.channel, volts) == false) {
 
95
                Infrastructure.fatal(this.getName()
 
96
                        + " power supply error setting voltage " + volts);
 
97
            }
 
98
        }
 
99
    }
 
100
 
 
101
    public void waitForVoltage(float setVolts) {
 
102
        if (supply.isDisabled())
 
103
            return;
 
104
        super.waitForVoltage(setVolts);
 
105
    }
 
106
 
 
107
    /**
 
108
     * Get the channel's voltage setpoint
 
109
     * 
 
110
     * @return voltage setpoint for the channel, in Volts
 
111
     */
 
112
    public float getVoltageSetpoint() {
 
113
        logOther("Reading voltage setpoint on " + getName());
 
114
        return this.supply.getVoltageSetpoint(this.channel);
 
115
    }
 
116
 
 
117
    /**
 
118
     * Returns voltage resolution of power supply.
 
119
     * 
 
120
     * @return voltage resolution of power supply
 
121
     */
 
122
    public float getVoltageResolution() {
 
123
        logOther("Getting voltage resolution on " + getName());
 
124
        return Pst3202.getVoltageResolution(this.channel);
 
125
    }
 
126
 
 
127
    /**
 
128
     * Reads back the current provided by this channel of the power supply.
 
129
     * 
 
130
     * @return current drawn over this channel, in Amps
 
131
     */
 
132
    public float readCurrent() {
 
133
        logOther("Reading current on " + getName());
 
134
        return this.supply.readCurrent(this.channel);
 
135
    }
 
136
 
 
137
    /**
 
138
     * Set the channel's current limit to the value provided
 
139
     * 
 
140
     * @param amps
 
141
     *            new current limit for the channel, in Amps
 
142
     */
 
143
    public void setCurrent(float amps) {
 
144
        logSet("Setting current limit on " + getName() + " to " + amps);
 
145
        supply.setCurrent(channel, amps);
 
146
    }
 
147
 
 
148
    /**
 
149
     * Get the channel's current setpoint
 
150
     * 
 
151
     * @return current setpoint for the channel, in Amps
 
152
     */
 
153
    public float getCurrentSetpoint() {
 
154
        logOther("Reading current setpoint on " + getName());
 
155
        return supply.getCurrentSetpoint(this.channel);
 
156
    }
 
157
 
 
158
    /**
 
159
     * Unit tests, prints current as function of voltage for channel 1. Should
 
160
     * disconnect supply from any chips before waiting.
 
161
     * 
 
162
     * @param args
 
163
     *            Ignored
 
164
     */
 
165
    public static void main(String[] args) {
 
166
        Infrastructure.gpibControllers = new int[] { 1 };
 
167
        Pst3202Channel channel1 = new Pst3202Channel("chan1", "hPst3202", 1);
 
168
        Pst3202Channel channel2 = new Pst3202Channel("chan2", "hPst3202", 2);
 
169
        Pst3202Channel channel3 = new Pst3202Channel("chan3", "hPst3202", 3);
 
170
 
 
171
        System.out.println("Voltage setpoints: "
 
172
                + channel1.getVoltageSetpoint() + ", "
 
173
                + channel2.getVoltageSetpoint() + ", "
 
174
                + channel3.getVoltageSetpoint());
 
175
        System.out.println("Voltages read: " + channel1.readVoltage() + ", "
 
176
                + channel2.readVoltage() + ", " + channel3.readVoltage());
 
177
        System.out.println("Current limits: " + channel1.getCurrentSetpoint()
 
178
                + ", " + channel2.getCurrentSetpoint() + ", "
 
179
                + channel3.getCurrentSetpoint());
 
180
        System.out.println("Currents read: " + channel1.readCurrent() + ", "
 
181
                + channel2.readCurrent() + ", " + channel3.readCurrent());
 
182
        channel3.setCurrent(2.0f);
 
183
 
 
184
        System.out.println("Chan 1 resolution: "
 
185
                + channel1.getVoltageResolution() + " V");
 
186
        System.out.println("Chan 2 resolution: "
 
187
                + channel2.getVoltageResolution() + " V");
 
188
        System.out.println("Chan 3 resolution: "
 
189
                + channel3.getVoltageResolution() + " V");
 
190
        
 
191
        if (false) {
 
192
            int nsweep = 0;
 
193
            do {
 
194
                for (float volts = 1.0f; volts < 1.85f; volts += 0.01f) {
 
195
                    channel1.setVoltageNoWait(volts);
 
196
                    channel3.setVoltageWait(volts);
 
197
                    channel1.waitForVoltage(volts);
 
198
                    System.out.print(nsweep + ", " + volts + " V; ");
 
199
                    System.out.println(channel1.getState());
 
200
                }
 
201
                nsweep++;
 
202
            } while (true);
 
203
        }
 
204
    }
 
205
}