001package jmri.jmrix.rfid.swing.tagcarwin;
002
003import jmri.jmrit.operations.locations.Location;
004import jmri.jmrit.operations.rollingstock.RollingStock;
005
006import javax.swing.*;
007import java.time.LocalTime;
008
009
010/**
011 * Element for working with incoming RFID tags
012 *
013 * @author J. Scott Walton Copyright (C) 2022
014 */
015public class TagCarItem {
016    private String tag;
017    private String road;
018    private String carNumber;
019    private String locationName;
020    private Location locationValue;
021    private String trackName;
022    private String train;
023    private Integer trainPosition;
024    protected JComboBox<String> locationCombo;
025    protected JComboBox<String> track;
026    private RollingStock currentCar;
027    private String destination;
028    private LocalTime lastSeen;
029    private JButton action1 = null;
030    private JButton action2 = null;
031    private LocalTime tagTime;
032    private int repeatCount = 0;
033    private boolean locationUpdated = false;
034    private boolean trackUpdated = false;
035    private boolean readyToSetLocation = false;
036
037    private String tempLocation = null;
038    private String tempTrack = null;
039
040    public void setUpdatedLocation(String location, String track) {
041        tempLocation = location;
042        locationUpdated = true;
043        if (track != null) {
044            tempTrack = track;
045            trackUpdated = true;
046            readyToSetLocation = true;
047        } else {
048            readyToSetLocation = trackUpdated;
049        }
050    }
051
052    public void setUpdatedTrack(String thisTrack) {
053        tempTrack = thisTrack;
054        trackUpdated = true;
055        readyToSetLocation = locationUpdated;
056    }
057
058    public String getUpdatedLocation() {
059        return tempLocation;
060    }
061
062    public String getUpdatedTrack() {
063        return tempTrack;
064    }
065
066    public boolean isLocationReady() {
067        return readyToSetLocation;
068    }
069
070    public void resetTempValues() {
071        locationUpdated = false;
072        trackUpdated = false;
073        tempLocation = null;
074        tempTrack = null;
075    }
076
077
078
079    public JComboBox<String> getLocationCombo() {
080        return locationCombo;
081    }
082
083    public void setLocation(JComboBox<String> location) {
084        this.locationCombo = location;
085    }
086
087    public void setTrack(JComboBox<String> track) {
088        this.track = track;
089    }
090
091    public JComboBox<String> getTrackCombo() {
092        return track;
093    }
094
095    public TagCarItem() {
096        tagTime = LocalTime.now();
097    }
098    public RollingStock getCurrentCar() {
099        return currentCar;
100    }
101
102    public void setCurrentCar(RollingStock currentCar) {
103        this.currentCar = currentCar;
104    }
105
106
107    public TagCarItem(String newTag) {
108        this.tag = newTag;
109        tagTime = LocalTime.now();
110        this.lastSeen = tagTime;
111    }
112
113    public TagCarItem(String newTag, LocalTime tagTime) {
114        this.tag = newTag;
115        this.tagTime = tagTime;
116        this.lastSeen = tagTime;
117    }
118
119    public Integer getTrainPosition() {
120        return trainPosition;
121    }
122
123    public void setTrainPosition(Integer trainPosition) {
124        this.trainPosition = trainPosition;
125    }
126
127    public String getDestination() {
128        return destination;
129    }
130
131    public void setDestination(String destination) {
132        this.destination = destination;
133    }
134
135    public JButton getAction1() {
136        return action1;
137    }
138
139    public void setAction1(JButton action1) {
140        this.action1 = action1;
141    }
142
143    public JButton getAction2() {
144        return action2;
145    }
146
147    public void setAction2(JButton action2) {
148        this.action2 = action2;
149    }
150
151
152    public void setLastSeen(LocalTime lastSeen) {
153        this.lastSeen = lastSeen;
154        repeatCount++;
155    }
156
157    public int getRepeatCount() {
158        return repeatCount;
159    }
160
161    public LocalTime getLastSeen() {
162        return lastSeen;
163    }
164
165    public LocalTime getTagTime() { return tagTime; }
166
167    public void setTagTime(LocalTime tagTime) { this.tagTime = tagTime; }
168
169    public String getTag() {
170        return tag;
171    }
172
173    public void setTag(String tag) {
174        this.tag = tag;
175    }
176
177    public String getRoad() {
178        return road;
179    }
180
181    public void setRoad(String road) {
182        this.road = road;
183    }
184
185    public String getCarNumber() {
186        return carNumber;
187    }
188
189    public void setCarNumber(String carNumber) {
190        this.carNumber = carNumber;
191    }
192
193    public Location getLocationValue() {
194        return this.locationValue;
195    }
196
197    public String getLocationName() {
198        return locationName;
199    }
200
201    public void setLocation(Location location) {
202        this.locationValue = location;
203    }
204
205    public void setLocation(String location) {
206        this.locationName = location;
207    }
208
209    public String getTrack() {
210        return trackName;
211    }
212
213    public void setTrack(String track) {
214        this.trackName = track;
215    }
216
217    public String getTrain() {
218        return train;
219    }
220
221    public void setTrain(String train) {
222        this.train = train;
223    }
224
225    public String getTempLocation() {
226        return tempLocation;
227    }
228
229    public String getTempTrack() {
230        return tempTrack;
231    }
232
233
234}