public PinMapping(string hostPin, BoardInfo targetPlank, string plankPin, PinTypes type) { this.hostPin = hostPin; this.targetPlank = targetPlank; this.plankPin = plankPin; this.type = type; }
public int Read(string pin, PinTypes type) { if (Value == null) Value = new Dictionary<string, int>(); return Value.ContainsKey(pin) ? Value[pin] : 0; }
public void Write(string pin, PinTypes type, int value) { if (Value == null) Value = new Dictionary<string, int>(); if (Value.ContainsKey(pin)) Value.Remove(pin); Value.Add(pin, value); Console.WriteLine("\t--------------------------------------------"); Console.WriteLine("\t{3} Write pin {0} type {1} value {2}", pin, type, value, DateTime.Now.ToLongTimeString()); Console.WriteLine("\t--------------------------------------------"); }
public int Read(string pin, PinTypes type) { var num = Convert.ToByte(pin); //cached read var mask = 1 << num; var value = (byte) (type == PinTypes.Output ? _outputs & mask : _inputs & mask); return value == 0 ? 0 : 1; //direct read //if (num > 7) // throw new ArgumentOutOfRangeException("pin"); //if (type != PinTypes.Output && type != PinTypes.Input) // throw new ArgumentOutOfRangeException("type"); //if (type == PinTypes.Output) //{ // return GetRelay(num) ? 1 : 0; //} //return GetInput(num) ? 1 : 0; }
public PinInfo(int pinNumber, string name, PinTypes type) : this(pinNumber) { this.name = name; this.type = type; }
private void HandlePinClicked(PinTypes pinType, IShapeBase shape) { if (this.LastClickedShape == null) { this.OnInner_ChangeShapeStatus(false); this.LastClickedShape = shape; this.LastConnection = new ConnectionShape(); this.LastPinType = pinType; if (pinType == PinTypes.Input) this.LastConnection.SetInputShape(this.LastClickedShape); else if (pinType == PinTypes.Output) this.LastConnection.SetOutputShape(this.LastClickedShape); this.AddShape(this.LastConnection); } else if (this.LastClickedShape != null && this.LastPinType != pinType && this.LastClickedShape != shape) { if (pinType == PinTypes.Input) this.LastConnection.SetInputShape(shape); else if (pinType == PinTypes.Output) this.LastConnection.SetOutputShape(shape); if (this.ConnectEBCs(this.LastConnection)) { this.SetConnectionShapes(this.LastConnection); } this.CancelConnection(false); this.Out_PaintRequest(); } }
/// <summary> /// Write pin /// </summary> /// <param name="pin">Pin index 0-7</param> /// <param name="type">Type pin (only digital output allowed)</param> /// <param name="value">value 1 = on , 0 = off</param> public void Write(string pin, PinTypes type, int value) { var num = Convert.ToByte(pin); if (num > 7) throw new ArgumentOutOfRangeException("pin"); if (type != PinTypes.Output) throw new ArgumentOutOfRangeException("type"); SetRelay(num, value == 1); }
/// <summary> /// Write pin /// </summary> /// <param name="connectorPin">Connector Pin name</param> /// <param name="type">Type pin (only digital output allowed)</param> /// <param name="value">value 1 = on , 0 = off</param> public void Write(string connectorPin, PinTypes type, int value) { if (!_pins.ContainsKey(connectorPin)) { throw new HardwareException(string.Format("raspberry pin {0} not found", connectorPin)); } var procPin = _pins[connectorPin]; if (type != PinTypes.Output) { throw new HardwareException(string.Format("Pin {0} is not an output", connectorPin)); } _driver.Write(procPin, value == 1); }
public ChangePinStatusMessage(PinTypes pinType, bool status) { this.PinType = pinType; this.Status = status; }
/// <summary> /// Read from input/output pin /// </summary> /// <param name="connectorPin">Connector Pin name</param> /// <param name="type">Pin to be read</param> /// <returns></returns> public int Read(string connectorPin, PinTypes type) { if (!_pins.ContainsKey(connectorPin)) { throw new HardwareException(string.Format("raspberry pin {0} not found", connectorPin)); } if (type != PinTypes.Output && type != PinTypes.Input) { throw new HardwareException(string.Format("Pin {0} is not an input or output", connectorPin)); } var procPin = _pins[connectorPin]; var inputPin = (ProcessorPins)((uint)1 << (int)procPin); var read = (_globalPins & inputPin) != ProcessorPins.None; return read ? 1 : 0; }
public void CancelEdit() { this.Name = this.backup.Name; this.Type = this.backup.Type; this.backup = null; }
public EBCPinClickedMessage(PinTypes pinType, IShapeBase shapeBase) { this.PinType = pinType; this.Shape = shapeBase; }
private Pin GetPin(int index, PinTypes type) { var pin = Pins.FirstOrDefault(p => p.Index == index && p.Type == type); return pin; }
private void ChangePinStatus(PinTypes pinType, bool status) { this.InputPin.IsActive = this.tsmiChangeInputPinStatus.Checked; this.OutputPin.IsActive = this.tsmiChangeOutputPinStatus.Checked; this.tsmiChangeBothPinStatus.Checked = this.tsmiChangeInputPinStatus.Checked && this.tsmiChangeOutputPinStatus.Checked; if (this.Out_ChangePinStatus != null) { this.Out_ChangePinStatus(new ChangePinStatusMessage(pinType, status)); } }