001package com.pi4j.io.gpio;
002
003/*
004 * #%L
005 * **********************************************************************
006 * ORGANIZATION  :  Pi4J
007 * PROJECT       :  Pi4J :: Java Library (Core)
008 * FILENAME      :  GpioProviderPinCache.java  
009 * 
010 * This file is part of the Pi4J project. More information about 
011 * this project can be found here:  http://www.pi4j.com/
012 * **********************************************************************
013 * %%
014 * Copyright (C) 2012 - 2013 Pi4J
015 * %%
016 * Licensed under the Apache License, Version 2.0 (the "License");
017 * you may not use this file except in compliance with the License.
018 * You may obtain a copy of the License at
019 * 
020 *      http://www.apache.org/licenses/LICENSE-2.0
021 * 
022 * Unless required by applicable law or agreed to in writing, software
023 * distributed under the License is distributed on an "AS IS" BASIS,
024 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
025 * See the License for the specific language governing permissions and
026 * limitations under the License.
027 * #L%
028 */
029
030/**
031 * This class provides cache for gpio pin instances.
032 *
033 * @author Robert Savage (<a
034 *         href="http://www.savagehomeautomation.com">http://www.savagehomeautomation.com</a>)
035 */
036public class GpioProviderPinCache {
037
038    private final Pin pin;
039    private PinMode mode;
040    private PinState state;
041    private PinPullResistance resistance;
042    private double analogValue = -1;
043    private int pwmValue = -1;
044    private boolean exported = false; 
045    
046    public GpioProviderPinCache(Pin pin) {
047        this.pin = pin;
048    }
049    
050    @Override
051    public String toString() {
052        return "PIN [" + pin.getName() + "] CACHE :: mode=" + mode.getName() + "; state=" + state.getName();
053    }
054
055    public PinMode getMode() {
056        return mode;
057    }
058    
059    public void setMode(PinMode mode) {
060        this.mode = mode;
061    }
062    
063    public PinState getState() {
064        return state;
065    }
066    
067    public void setState(PinState state) {
068        this.state = state;
069    }
070    
071    public PinPullResistance getResistance() {
072        return resistance;
073    }
074    
075    public void setResistance(PinPullResistance resistance) {
076        this.resistance = resistance;
077    }
078    
079    public double getAnalogValue() {
080        return analogValue;
081    }
082    
083    public void setAnalogValue(double value) {
084        this.analogValue = value;
085    }
086    
087    public int getPwmValue() {
088        return pwmValue;
089    }
090    
091    public void setPwmValue(int value) {
092        this.pwmValue = value;
093    }
094    
095    public boolean isExported() {
096        return exported;
097    }
098    
099    public void setExported(boolean exported) {
100        this.exported = exported;
101    }
102}