/// <summary> /// Light app LED and hardware LED (if available). /// </summary> /// <param name="colour"></param> private void LED(LEDcolour colour) { switch (colour) { case LEDcolour.Green: Front.LEDColor = KnownColor.ForestGreen; if (ADC.PortName != null) { ADC.LED_Green(); } break; case LEDcolour.Red: Front.LEDColor = KnownColor.IndianRed; if (ADC.PortName != null) { ADC.LED_Red(); } break; case LEDcolour.Off: Front.LEDColor = null; if (ADC.PortName != null) { ADC.LED_Off(); } break; default: break; } }
/// <summary> /// Costruttore /// </summary> /// <param name="res">Nome del canale analogico</param> /// <param name="scale">Valore di scalatura del valore letto dal canale analogico</param> /// <param name="offset">Offset aggiunto sul valore letto dal canale analogico</param> /// <param name="movingAverageSize">Dimensione del buffer per calcolo media</param> public AnalogIn(ADC res, double scale, double offset, int movingAverageSize) : base((Cpu.AnalogChannel)res) { _avg = new MovingAverageCalculator(movingAverageSize); Scale = scale; Offset = offset; }
/// <summary> /// Costruttore /// </summary> /// <param name="res">Nome del canale analogico</param> /// <param name="scale">Valore di scalatura del valore letto dal canale analogico</param> /// <param name="offset">Offset aggiunto sul valore letto dal canale analogico</param> /// <param name="movingAverageSize">Dimensione del buffer per calcolo media</param> public AnalogIn(ADC res, double scale, double offset, int movingAverageSize) : base((Cpu.AnalogChannel)res) { _avg = new MovingAverageCalculator(movingAverageSize); Scale = scale; Offset = offset; }
/// <summary> /// Costruttore /// </summary> /// <param name="res">Numero del canale analogico su cui è collegata la sonda</param> /// <param name="scale">Valore di scalatura del valore letto dal canale analogico</param> /// <param name="offset">Offset aggiunto sul valore letto dal canale analogico</param> /// <param name="movingAverageSize">Dimensione del buffer per calcolo media</param> /// <param name="r0">Resistenza nominale a 25 gradi centigradi espressa in Ohm</param> /// <param name="rb">Il valore della resistenza utilizzata come partitore di tensione verso massa con l'NTC (in Ohm)</param> /// <param name="beta">Coefficiente specifico della sonda (normalmente quello indicato nell'intervallo di temperatura 25-85 gradi centigradi)</param> /// <param name="vref">Il Vref del convertitore A/D (in Volt)</param> public Ntc(ADC res, double scale, double offset, int movingAverageSize, int r0, double rb, int beta, double vref) : this(r0, rb, beta, vref) { _ai = new AnalogIn(res, movingAverageSize) { Scale = scale, Offset = offset }; }
/// <summary> /// returns The build name. /// </summary> /// public static string BuildName() { var ChampionName = Player.Instance.CleanChampionName(); if (ADC.Any(s => s.Equals(ChampionName, StringComparison.CurrentCultureIgnoreCase))) { return("ADC"); } if (AD.Any(s => s.Equals(ChampionName, StringComparison.CurrentCultureIgnoreCase))) { return("AD"); } if (AP.Any(s => s.Equals(ChampionName, StringComparison.CurrentCultureIgnoreCase))) { return("AP"); } if (ManaAP.Any(s => s.Equals(ChampionName, StringComparison.CurrentCultureIgnoreCase))) { return("ManaAP"); } if (Tank.Any(s => s.Equals(ChampionName, StringComparison.CurrentCultureIgnoreCase))) { return("Tank"); } Logger.Send("Failed to detect champion: " + ChampionName, Logger.LogLevel.Warn); //Logger.Send("Using Default Build !"); return("Default"); }
/// <summary> /// returns The build name. /// </summary> public static string BuildName() { var ChampionName = Player.Instance.ChampionName; if (ADC.Contains(ChampionName)) { return("ADC"); } if (AD.Contains(ChampionName)) { return("AD"); } if (AP.Contains(ChampionName)) { return("AP"); } if (ManaAP.Contains(ChampionName)) { return("ManaAP"); } if (Tank.Contains(ChampionName)) { return("Tank"); } Console.WriteLine("Failed To Detect " + ChampionName); Console.WriteLine(DateTime.Now.ToString("[H:mm:ss - ") + "AramBuddy Info] Using Default Build !"); return("Default"); }
public MethodOfCalibrationOfWeights(ADC adcInst) { this.adcInst = adcInst; this.dacInst = adcInst.dac; this.shchvnInst = adcInst.dac.schvn; RAM.InitRAM(shchvnInst); }
/// <summary> /// Periodically check switching progress. /// </summary> /// <exception cref="ApplicationException">Wrong TemperatureControlMode.</exception> /// <param name="sender"></param> /// <param name="e"></param> private void TimerSwitch_Tick(object sender, EventArgs e) { switch (temperatureControlMode) { case TemperatureControlMode.None: throw new ApplicationException("Wrong mode."); case TemperatureControlMode.ET2PC_switch: if (!ADC.Switched2Eurotherm()) { timerSwitch.Stop(); temperatureControlMode = TemperatureControlMode.None; Front.SwitchButtonTextIndex = 0; LED(LEDcolour.Off); } break; case TemperatureControlMode.PC2ET_equal: // If switched before the voltages are equalized. if (ADC.Switched2Eurotherm()) { timerSwitch.Stop(); temperatureControlMode = TemperatureControlMode.None; Front.SwitchButtonTextIndex = 0; LED(LEDcolour.Off); break; } // If difference is lesser than error. Front.My_msg("XX AR" + ADC.ReadEurothermV() + " AL" + DAC.LastWrittenValue); if (Math.Abs(ADC.ReadEurothermV() - DAC.LastWrittenValue) < 0.05) { temperatureControlMode = TemperatureControlMode.PC2ET_switch; Front.My_msg("You can switch to Eurotherm."); LED(LEDcolour.Green); } break; case TemperatureControlMode.PC2ET_switch: // If difference is greater again than error. if (Math.Abs(ADC.ReadEurothermV() - DAC.LastWrittenValue) >= 0.05) { temperatureControlMode = TemperatureControlMode.PC2ET_equal; LED(LEDcolour.Red); } if (ADC.Switched2Eurotherm()) { timerSwitch.Stop(); temperatureControlMode = TemperatureControlMode.None; Front.SwitchButtonTextIndex = 0; LED(LEDcolour.Off); } break; default: break; } }
public CalibratorOfCollapsingCombinations(ADC adcInst) { this.adcInst = adcInst; registerUnCollapsed = (SCHVNRegister)this.adcInst.reg.Clone(); registerUnCollapsed.SetPolinomNull(); registerUnCollapsed.AddBitValue(0, 1); registerUnCollapsed.AddBitValue(1, 1); }
public AutoCycle(Machine _machine, ADC _adc, List <IProcessButton> _buttons, SummaryTracker _tracker) { machine = _machine; adc = _adc; cycleProcesses = _buttons; tracker = _tracker; adc.OnAverageValues += UpdateEstTime; currProgress = cycleProgressEnum.STANDBY; }
public ProcessController(Machine _machine, ADC _adc) { fillPump = new FillPumpWithSensor(_machine); lowRangeOscillator = new LROscillator(_machine, _adc); drainPump = new DrainPump(_machine, _adc); runPump = new RunPumpAutoTrigger(_machine, tracker, _adc); autoCycle = new AutoCycle(_machine, _adc, new List <IProcessButton> { runPump, lowRangeOscillator, drainPump, fillPump }, tracker); }
public CalibratorOfTrackingCombinations(ADC adcInst) { this.adcInst = adcInst; int binaryN = (int)Math.Ceiling(Math.Log(adcInst.dac.schvn.alpha, Math.E) * adcInst.dac.schvn.n / Math.Log(2, Math.E)); NotationSystem binarySys = new NotationSystem(binaryN, 2, 0); binaryReg = new BinaryRegister(binarySys); bToSchvnConv = new Converter(binarySys, adcInst.dac.schvn); }
public MainWindow() { InitializeComponent(); RPI.RPi _rpi = new RPI.RPi(); ADC _adc = new ADC(_rpi); _adc.initAdc(); List<float> dataList = new List<float>(); float sample = Convert.ToSingle((_adc.readADC(0) / 2048.0) * 6.144)); dataList.Add(sample); Thread.Sleep(20); }
public void Analog() { #region Startup var TestTable = new LadderDataTable(); Node PowerRail = new Node(); PowerRail.LogicLevel = false; PWM pwm = new PWM("1", PowerRail); pwm.DataTable = TestTable; ADC adc = new ADC("1", PowerRail); adc.DataTable = TestTable; #endregion Startup #region PWM pwm.DudyCycle = "255"; pwm.Execute(); Assert.IsFalse(pwm.InternalState); PowerRail.LogicLevel = true; pwm.Execute(); Assert.IsTrue(pwm.InternalState); PowerRail.LogicLevel = false; pwm.DudyCycle = "DudyCycle"; pwm.DudyCycleValue = (byte)128; pwm.Execute(); Assert.IsFalse(pwm.InternalState); PowerRail.LogicLevel = true; pwm.Execute(); Assert.IsTrue(pwm.InternalState); #endregion PWM #region ADC PowerRail.LogicLevel = false; adc.Execute(); Assert.IsFalse(adc.InternalState); adc.InputValue = (short)1023; adc.Execute(); Assert.IsFalse(adc.InternalState); PowerRail.LogicLevel = true; adc.Execute(); Assert.IsTrue(adc.InternalState); #endregion ADC }
/// <summary> /// /// </summary> /// <returns></returns> public bool Switch(out double outputVoltage) { outputVoltage = double.NaN; if (temperatureControlMode == TemperatureControlMode.None) { if (!double.IsNaN(outputVoltage)) { // Switched to eurotherm, so switching to this app. if (ADC.Switched2Eurotherm()) { outputVoltage = ADC.ReadEurothermV(); // Round to 12b - this should be given by DAC. outputVoltage = Math.Round(outputVoltage / 10 * 4096) / 409.6; // ?? DAC.SetV(outputVoltage, 2); Front.My_msg("You can switch to PC."); LED(LEDcolour.Green); } // Switched to this app, so switching to eurotherm. else { double percent = DAC.LastWrittenValue / 5 * 100; // Percentage out of 5 V. var a = DAC.GetV(); Front.My_msg("XX P" + percent + " DL" + DAC.LastWrittenValue + " a0" + a[0] + " a1" + a[1]); // Analyze. DELETE!!! Front.My_msg(string.Format("Set Eurotherm to Manual / {0:F1} %.", percent)); LED(LEDcolour.Red); } timerSwitch.Start(); temperatureControlMode = TemperatureControlMode.ET2PC_switch; } else { temperatureControlMode = TemperatureControlMode.PC2ET_equal; } } // Sth is already happening => abort. else { timerSwitch.Stop(); LED(LEDcolour.Off); temperatureControlMode = TemperatureControlMode.None; } return(temperatureControlMode == TemperatureControlMode.None); }
private void buttonBrowseForNewData_Click(object sender, EventArgs e) { if (openFileDialogAddFile.ShowDialog() == DialogResult.OK) { ////// Image imageToAdd = new Image() { FilePath = openFileDialogAddFile.FileName, Project = (comboBoxProjects.SelectedItem as Project), Session = (comboBoxSession.SelectedItem as Session), ImageType = (comboBoxImageType.SelectedItem as ImageType), DateAdded = DateTime.Now }; ADC.Images.InsertOnSubmit(imageToAdd); ADC.SubmitChanges(); } else { return; } }
/// <summary> /// returns The build name. /// </summary> public static string BuildName() { var ChampionName = CleanUpChampionName(Player.Instance.ChampionName); if (ChampionName.Equals("MonkeyKing", StringComparison.CurrentCultureIgnoreCase)) { ChampionName = "Wukong"; } if (ADC.Any(s => s.Equals(ChampionName, StringComparison.CurrentCultureIgnoreCase))) { return("ADC"); } if (AD.Any(s => s.Equals(ChampionName, StringComparison.CurrentCultureIgnoreCase))) { return("AD"); } if (AP.Any(s => s.Equals(ChampionName, StringComparison.CurrentCultureIgnoreCase))) { return("AP"); } if (ManaAP.Any(s => s.Equals(ChampionName, StringComparison.CurrentCultureIgnoreCase))) { return("ManaAP"); } if (Tank.Any(s => s.Equals(ChampionName, StringComparison.CurrentCultureIgnoreCase))) { return("Tank"); } Logger.Send("Failed To Detect " + ChampionName, Logger.LogLevel.Warn); //Logger.Send("Using Default Build !"); return("Default"); }
public Form1() { InitializeComponent(); this.Text += System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); pwmKey1 = Registry.LocalMachine.CreateSubKey("\\Drivers\\BuiltIn\\PWM1"); pwmKey1.SetValue("DutyCycleA", 10); pwmKey1.SetValue("DutyCycleB", 10); pwmKey1.SetValue("Frequency", 50); pwm1 = new PWM("PWM1:"); pwm1.DutyCycleA = 10; pwm1.RunPWMA = true; pwmKey2 = Registry.LocalMachine.CreateSubKey("\\Drivers\\BuiltIn\\PWM2"); pwmKey2.SetValue("DutyCycleA", 10); pwmKey2.SetValue("DutyCycleB", 10); pwmKey2.SetValue("Frequency", 50); pwm2 = new PWM("PWM2:"); pwm2.DutyCycleA = 10; pwm2.RunPWMA = true; gpio = new GPIO(); gpio.SetDirection(Z1FANS, Direction.Output); gpio.SetDirection(Z1HEAT, Direction.Output); gpio.SetDirection(Z2FANS, Direction.Output); gpio.SetDirection(Z2HEAT, Direction.Output); gpio.ClearBit(Z1FANS); gpio.ClearBit(Z1HEAT); gpio.ClearBit(Z2FANS); gpio.ClearBit(Z2HEAT); adc = new ADC(); updateTMR.Enabled = true; }
public CalibratorOfWeights(ADC adcInst) { this.adcInst = adcInst; }
public ADCTest() { _adc = new ADC(machine.CPU); }
/// <summary> /// Costruttore /// </summary> /// <param name="res">Numero del canale analogico su cui è collegata la sonda</param> /// <param name="scale">Valore di scalatura del valore letto dal canale analogico</param> /// <param name="offset">Offset aggiunto sul valore letto dal canale analogico</param> /// <param name=" movingAverageSize">Dimensione del buffer per calcolo media</param> public PT1000(ADC res, double scale, double offset, int movingAverageSize) : base(res, scale, offset, movingAverageSize, 1000, 1000, 2.5) { }
/// <summary> /// Costruttore /// </summary> /// <param name="res">Numero del canale analogico su cui è collegata la sonda</param> /// <param name="scale">Valore di scalatura del valore letto dal canale analogico</param> /// <param name="offset">Offset aggiunto sul valore letto dal canale analogico</param> /// <param name="movingAverageSize">Dimensione del buffer per calcolo media</param> /// <param name="r0">Resistenza in Ohm dell'PRT alla temperatura T0</param> /// <param name="rb">Il valore della resistenza utilizzata come partitore di tensione verso massa con l'PRT (in Ohm)</param> /// <param name="vref">Il Vref del convertitore A/D (in Volt)</param> public Prt(ADC res, double scale, double offset, int movingAverageSize, int r0, double rb, double vref) : this(r0, rb, vref) { _ai = new AnalogIn(res, movingAverageSize) {Scale = scale, Offset = offset}; }
public LROscillator(Machine _machine, ADC _adc) { machine = _machine; adc = _adc; }
/// <summary> /// Create a single component from XML data /// </summary> /// <param name="node">XML node containing component data</param> /// <returns>Created Component</returns> private static ComponentBase CreateComponent(XmlNode node) { ComponentBase component; switch (node.LocalName) { #region Basic case "Coil": Coil coil = new Coil(); coil.Mode = node.Attributes["Mode"].Value.ToEnum <Coil.CoilMode>(); coil.Type = node.Attributes["Type"].Value.ToEnum <Coil.CoilType>(); component = coil; break; case "Contact": Contact contact = new Contact(); contact.IsClosed = node.Attributes["IsClosed"].Value.ToBool(); contact.IsInverted = node.Attributes["IsInverted"].Value.ToBool(); contact.Type = node.Attributes["Type"].Value.ToEnum <Contact.ContactType>(); component = contact; break; case "SC": component = new SC(); break; case "OSF": component = new OSF(); break; case "OSR": component = new OSR(); break; #endregion Basic #region Compare Components case "EQU": component = new EQU(); break; case "GEQ": component = new GEQ(); break; case "GRT": component = new GRT(); break; case "LEG": component = new LEG(); break; case "LES": component = new LES(); break; case "NEQ": component = new NEQ(); break; #endregion Compare Components #region Counter Components case "CTC": component = new CTC(); break; case "CTD": component = new CTD(); break; case "CTU": component = new CTU(); break; case "RES": component = new RES(); break; #endregion Counter Components #region Math Components case "ADD": component = new ADD(); break; case "DIV": component = new DIV(); break; case "MUL": component = new MUL(); break; case "SUB": component = new SUB(); break; case "MOV": component = new MOV(); break; #endregion Math Components #region Analog Components case "ADC": ADC adc = new ADC(); adc.Destination = node.Attributes["Destination"].Value; component = adc; break; case "PWM": PWM pwm = new PWM(); pwm.DudyCycle = node.Attributes["DudyCycle"].Value; component = pwm; break; #endregion Analog Components #region Function Components case "ELF": ELF elf = new ELF(); elf.Name = node.Attributes["Name"].Value; elf.Code = node.InnerText; component = elf; break; #endregion Function Components default: throw new ArgumentException("Unknow Component", "node"); } component.Comment = node.Attributes["Comment"].Value; #region Extra Processing based on Components Base Class if (component is NameableComponent) { (component as NameableComponent).Name = node.Attributes["Name"].Value; } if (component is CompareComponent) { (component as CompareComponent).VarA = node.Attributes["VarA"].Value; (component as CompareComponent).VarB = node.Attributes["VarB"].Value; } else if (component is CounterComponent) { (component as CounterComponent).Limit = node.Attributes["Limit"].Value; } else if (component is MathComponent) { (component as MathComponent).Destination = node.Attributes["Destination"].Value; (component as MathComponent).VarA = node.Attributes["VarA"].Value; (component as MathComponent).VarB = node.Attributes["VarB"].Value; } #endregion Extra Processing based on Components Base Class return(component); }
/// <summary> /// Costruttore /// </summary> /// <param name="res">Numero del canale analogico su cui è collegata la sonda</param> /// <param name="scale">Valore di scalatura del valore letto dal canale analogico</param> /// <param name="offset">Offset aggiunto sul valore letto dal canale analogico</param> /// <param name="r0">Resistenza in Ohm dell'PRT alla temperatura T0</param> /// <param name="rb">Il valore della resistenza utilizzata come partitore di tensione verso massa con l'PRT (in Ohm)</param> /// <param name="vref">Il Vref del convertitore A/D (in Volt)</param> public Prt(ADC res, double scale, double offset, int r0, double rb, double vref) : this(res, scale, offset, 1,r0, rb, vref) { }
/// <summary> /// Costruttore /// </summary> /// <param name="res">Nome del canale analogico</param> /// <param name="movingAverageSize">Dimensione del buffer per calcolo media</param> public AnalogIn(ADC res, int movingAverageSize) : this(res, 1, 0, movingAverageSize) { }
public producer(BlockingCollection <int> BC) { BC_ = BC; adConverter = new ADC(); }
/// <summary> /// Costruttore /// </summary> /// <param name="res">Numero del canale analogico su cui è collegata la sonda</param> /// <param name="scale">Valore di scalatura del valore letto dal canale analogico</param> /// <param name="offset">Offset aggiunto sul valore letto dal canale analogico</param> public PT1000(ADC res, double scale, double offset) : base(res, scale, offset, 1000, 1000, 2.5) { }
} // Drain rolling average public DrainPump(Machine _machine, ADC _adc) { machine = _machine; adc = _adc; }
public CalibratorOfCletchingCombinations(ADC adcInst) { this.adcInst = adcInst; }
/// <summary> /// Costruttore /// </summary> /// <param name="res">Numero del canale analogico su cui è collegata la sonda</param> /// <param name="scale">Valore di scalatura del valore letto dal canale analogico</param> /// <param name="offset">Offset aggiunto sul valore letto dal canale analogico</param> /// <param name="r0">Resistenza in Ohm dell'PRT alla temperatura T0</param> /// <param name="rb">Il valore della resistenza utilizzata come partitore di tensione verso massa con l'PRT (in Ohm)</param> /// <param name="vref">Il Vref del convertitore A/D (in Volt)</param> public Prt(ADC res, double scale, double offset, int r0, double rb, double vref) : this(res, scale, offset, 1, r0, rb, vref) { }
/// <summary> /// Costruttore /// </summary> /// <param name="res">Numero del canale analogico su cui è collegata la sonda</param> /// <param name="scale">Valore di scalatura del valore letto dal canale analogico</param> /// <param name="offset">Offset aggiunto sul valore letto dal canale analogico</param> /// <param name=" movingAverageSize">Dimensione del buffer per calcolo media</param> public PT1000(ADC res, double scale, double offset, int movingAverageSize) : base(res, scale, offset, movingAverageSize, 1000, 1000, 2.5) { }
public float GetVoltage(ADC channel) { return(((Values[(int)channel] * 3300.00f) / 4095.0f) / 1000.0f); }
public void Close() { DAC.Close(); ADC.Close(); BtnDisconnect(); }
/// <summary> /// Costruttore /// </summary> /// <param name="res">Nome del canale analogico</param> public AnalogIn(ADC res) : this(res, 1, 0, 1) { }
/// <summary> /// Costruttore /// </summary> /// <param name="res">Numero del canale analogico su cui è collegata la sonda</param> /// <param name="scale">Valore di scalatura del valore letto dal canale analogico</param> /// <param name="offset">Offset aggiunto sul valore letto dal canale analogico</param> /// <param name="r0">Resistenza nominale a 25 gradi centigradi espressa in Ohm</param> /// <param name="rb">Il valore della resistenza utilizzata come partitore di tensione verso massa con l'NTC (in Ohm)</param> /// <param name="beta">Coefficiente specifico della sonda (normalmente quello indicato nell'intervallo di temperatura 25-85 gradi centigradi)</param> /// <param name="vref">Il Vref del convertitore A/D (in Volt)</param> public Ntc(ADC res, double scale, double offset, int r0, double rb, int beta, double vref) : this(res, scale, offset, 1, r0, rb, beta, vref) { }
/// <summary> /// Costruttore /// </summary> /// <param name="res">Numero del canale analogico su cui è collegata la sonda</param> /// <param name="scale">Valore di scalatura del valore letto dal canale analogico</param> /// <param name="offset">Offset aggiunto sul valore letto dal canale analogico</param> public PT1000(ADC res, double scale, double offset) : base(res, scale, offset, 1000, 1000, 2.5) { }
/// <summary> /// Costruttore /// </summary> /// <param name="res">Nome del canale analogico</param> /// <param name="scale">Valore di scalatura del valore letto dal canale analogico</param> /// <param name="offset">Offset aggiunto sul valore letto dal canale analogico</param> public AnalogIn(ADC res, double scale, double offset) : this(res, scale, offset, 1) { }