Ejemplo n.º 1
0
 private Mixer(XElement element)
 {
     Inputs      = new ConnectionsArray(element.Element("inputs"));
     Outputs     = new ConnectionsArray(element.Element("outputs"));
     InputGains  = new Gains(element.Element("inputGains"));
     OutputGains = new Gains(element.Element("outputGains"));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Read the device configuration from the ASCOM Profile store
        /// </summary>
        internal void ReadProfile()
        {
            using (Profile driverProfile = new Profile())
            {
                driverProfile.DeviceType = "Camera";
                tl.Enabled = Convert.ToBoolean(driverProfile.GetValue(driverID, traceStateProfileName, string.Empty, traceStateDefault));

                DeserializeModelsFromJson();

                string cameraModelID = driverProfile.GetValue(driverID, cameraModelProfileName, string.Empty, "");

                var firstCameraModel = CameraModel.Models.FirstOrDefault();

                if (string.IsNullOrEmpty(cameraModelID))
                {
                    cameraModel = firstCameraModel;
                }
                else
                {
                    cameraModel = CameraModel.Models.FirstOrDefault(m => m.ID == cameraModelID) ?? firstCameraModel;
                }

                string isoAsString = driverProfile.GetValue(driverID, isoProfileName, string.Empty, cameraModel.Gains.First().ToString());
                iso  = short.Parse(isoAsString);
                Gain = (short)Array.IndexOf(Gains.ToArray(), iso);

                imageFormat         = (ImageFormat)Enum.Parse(typeof(ImageFormat), driverProfile.GetValue(driverID, imageFormatProfileName, string.Empty, ImageFormat.CFA.ToString()));
                autoDeleteImageFile = Boolean.Parse(driverProfile.GetValue(driverID, autoDeleteImageFileProfileName, string.Empty, false.ToString()));


                cameraNumX = cameraModel.Sensor.GetReadoutWidth(imageFormat);
                cameraNumY = cameraModel.Sensor.GetReadoutHeight(imageFormat);
            }
        }
Ejemplo n.º 3
0
 public Mixer(float[] inputGains, float[] outputGains)
 {
     Inputs      = new ConnectionsArray(inputGains.Length);
     Outputs     = new ConnectionsArray(outputGains.Length);
     InputGains  = new Gains(inputGains);
     OutputGains = new Gains(outputGains);
 }
Ejemplo n.º 4
0
 public Mixer(int inputs, int outputs)
 {
     Inputs      = new ConnectionsArray(inputs);
     Outputs     = new ConnectionsArray(outputs);
     InputGains  = new Gains(inputs);
     OutputGains = new Gains(outputs);
 }
Ejemplo n.º 5
0
 public static void SetProfile(User user)
 {
     Profile.id             = user.id;
     Profile.name           = user.name;
     Profile.alienImagePath = user.alienImagePath;
     Profile.currentPlanet  = user.currentPlanet;
     Profile.gains          = user.gains;
 }
Ejemplo n.º 6
0
 public Mixer()
 {
     useable     = false;
     Inputs      = new ConnectionsArray(0);
     Outputs     = new ConnectionsArray(0);
     InputGains  = new Gains(0);
     OutputGains = new Gains(0);
 }
Ejemplo n.º 7
0
    public void UpdateGains(Gains deltaGains, bool useAnimation = true)
    {
        gains += deltaGains;

        popularity.Alter(deltaGains.GetPopularity(), useAnimation);
        energy.Alter(deltaGains.GetEnergy(), useAnimation);
        trust.Alter(deltaGains.GetTrust(), useAnimation);
        days.Alter(deltaGains.GetDays(), useAnimation);
    }
Ejemplo n.º 8
0
        private Gains _gain;                                // Gain mode

        /// <summary>
        /// Initializes a new instance of the <see cref="DacClick"/> class.
        /// </summary>
        /// <param name="socket">The socket on which the BarGraph Click board is plugged on MikroBus.Net</param>
        public DacClick(Hardware.Socket socket)
        {
            // Initialize SPI
            _dac = SpiController.FromName(socket.SpiBus).GetDevice(new SpiConnectionSettings()
            {
                ChipSelectType = SpiChipSelectType.Gpio,
                ChipSelectLine = GHIElectronics.TinyCLR.Devices.Gpio.GpioController.GetDefault().OpenPin(socket.Cs),
                Mode           = SpiMode.Mode0,
                ClockFrequency = 2000000
            });

            _controlBits = 0x30;          // Unbuffered, Gain 1x, active mode
            Output       = 0;             // Clean output value
            _powerMode   = PowerModes.On; // Active
            _isBuffered  = false;         // Unbuffered
            _gain        = Gains.X1;      // Gain 1x
        }
Ejemplo n.º 9
0
        private void init()
        {
            _hasBayerOffset      = true;
            _hasCCDTemperature   = true;
            _hasCooler           = true;
            CanSetGain           = true;
            CanGetGain           = true;
            _canGetGainMinMax    = true;
            _hasLastExposureInfo = true;
            _hasPercentCompleted = true;
            BinningModes         = new AsyncObservableCollection <BinningMode>();
            for (short i = 1; i <= MaxBinX; i++)
            {
                if (CanAsymmetricBin)
                {
                    for (short j = 1; j <= MaxBinY; j++)
                    {
                        BinningModes.Add(new BinningMode(i, j));
                    }
                }
                else
                {
                    BinningModes.Add(new BinningMode(i, i));
                }
            }

            Gains.Clear();
            try {
                var gains = _camera.Gains;
                foreach (object o in _camera.Gains)
                {
                    if (o.GetType() == typeof(string))
                    {
                        var gain = Regex.Match(o.ToString(), @"\d+").Value;
                        Gains.Add(int.Parse(gain, CultureInfo.InvariantCulture));
                    }
                }
            } catch (Exception) {
            }
        }
Ejemplo n.º 10
0
    public void StartLoadField(int widthX, int lengthY, Level level)
    {
        LoadObject loadObject = new LoadObject();
        GameObject plane      = loadObject.LoadPlane();
        GameObject wall       = loadObject.LoadCube();
        GameObject cylinder   = loadObject.LoadCylinder();
        GameObject cubebox    = loadObject.LoadBox();
        GameObject player     = loadObject.LoadPlayer();
        //List<Vector3> emptySpace = new List<Vector3>();

        int width  = widthX;
        int length = lengthY;
        int indexX = 0;
        int indexZ = 0;

        LoadWall(wall, emptySpace, width, length, ref indexX, ref indexZ);
        int numberEmpty = emptySpace.Count;

        LoadField(plane, width, length, indexX, indexZ);

        int randomNumber = Random.Range(0, numberEmpty - 1);

        Instantiate(player, emptySpace[randomNumber], Quaternion.identity);

        /* EnemyControl enemy = new EnemyControl();
         * enemy.LoadEnemy(emptySpace);*/
        TestMoveEnemy enemy = new TestMoveEnemy();

        enemy.LoadEnemy(emptySpace);


        Box Box = new Box();

        Box.LoadBox(emptySpace, randomNumber, level);

        Gains gains = new Gains();

        gains.LoadGains(emptySpace);
    }
Ejemplo n.º 11
0
        private Gains _gain;                           // Gain mode

        /// <summary>
        /// Initializes a new instance of the <see cref="DacClick"/> class.
        /// </summary>
        /// <param name="socket">The socket on which the BarGraph Click board is plugged on MikroBus.Net</param>
        /// <exception cref="System.InvalidOperationException">Thrown if some pins are already in use by another board on the same socket</exception>
        public DacClick(Hardware.Socket socket)
        {
            try
            {
                // Checks if needed SPI pins are available
                Hardware.CheckPins(socket, socket.Miso, socket.Mosi, socket.Cs, socket.Sck, socket.Rst);

                // Initialize SPI
                _spiConfig = new SPI.Configuration(socket.Cs, false, 15, 10, false, true, 20000, socket.SpiModule);
                if (Hardware.SPIBus == null)
                {
                    Hardware.SPIBus = new SPI(_spiConfig);
                }

                _controlBits = 0x30;          // Unbuffered, Gain 1x, active mode
                Output       = 0;             // Clean output value
                _powerMode   = PowerModes.On; // Active
                _isBuffered  = false;         // Unbuffered
                _gain        = Gains.X1;      // Gain 1x
            }
            // Catch only the PinInUse exception, so that program will halt on other exceptions
            // Send it directly to caller
            catch (PinInUseException) { throw new PinInUseException(); }
        }
Ejemplo n.º 12
0
 public CtrlChannel(float sLim, float rLim, float rImx, float sKp, float rKp, float rKi, float rKd)
 {
     // :) We should initialize all important variables (Limits, gains, imax)
     sLimit = sLim;
     rLimit = rLim;
     sGains = new Gains(sKp, 0, 0);
     rGains = new Gains(rKp, rKi, rKd);
     sTarget = new Angle(0);
     sCurrent = new Angle(0);
     rIMax = rImx;
 }
 public PidControllerOld(Gains gains, IntegratorLimits limits)
 {
     this.gains  = gains;
     this.limits = limits;
     pid         = PidControllerExtensions.Pid();
 }
Ejemplo n.º 14
0
 public void setGain(Gains enumVal)
 {
     gain = (int)enumVal;
 }
Ejemplo n.º 15
0
        public void RenderChart()
        {
            canvas.Clear(SKColors.White);

            // set up drawing tools
            using (var paint = new SKPaint())
            {
                paint.IsAntialias = true;
                paint.Color       = new SKColor(0x2c, 0x3e, 0x50);
                paint.StrokeCap   = SKStrokeCap.Round;

                var xCoordStart = new Point(0 + (width / 20), height - (height / 3));
                var xCoordEnd   = new Point(width - (width / 20), height - (height / 3));

                var yCoordStart = new Point(0 + (width / 20), height - (height / 3));
                var yCoordEnd   = new Point(0 + (width / 20), 0 + (height / 95));

                var zCoordStart = new Point(width - (width / 20), xCoordStart.Y - 150);
                var zCoordEnd   = new Point(width - (width / 20), xCoordStart.Y + 150);

                canvas.DrawLine(xCoordStart.X, xCoordStart.Y, xCoordEnd.X, xCoordEnd.Y, new SKPaint());
                canvas.DrawLine(yCoordStart.X, yCoordStart.Y, yCoordEnd.X, yCoordEnd.Y, new SKPaint());
                canvas.DrawLine(zCoordStart.X, zCoordStart.Y, zCoordEnd.X, zCoordEnd.Y, new SKPaint());

                //TODO: temporary workaround ;)
                canvas.DrawLine(zCoordStart.X, zCoordStart.Y - 200, zCoordEnd.X, zCoordEnd.Y, new SKPaint());
                //assume: data to x and y coord are ordered

                //map xcoord between xstart and xend;
                var xRange    = xCoordEnd.X - xCoordStart.X;
                var xPlotUnit = xRange / DatesList.Count;

                //map ycoord between ystart and yend
                var yRange    = yCoordStart.Y - yCoordEnd.Y;
                var yPlotUnit = yRange / (float)(Values.Select(n => n.Item1).Max() - Values.Select(n => n.Item1).Min());

                //map zcoord between zstart and zend
                var zRange    = zCoordStart.Y - zCoordEnd.Y;
                var zPlotUnit = zRange / (float)(Gains.Max() - Gains.Min());

                var maxGains = GainsList.Max();
                var minGains = GainsList.Min();
                //Plot the values
                for (int i = 0; i < DatesList.Count; i++)
                {
                    var xCoord = xCoordStart.X + (i * xPlotUnit);
                    var yCoord = yCoordStart.Y - (yPlotUnit * (float)(ValuesList[i].Item1 - Values.Select(n => n.Item1).Min()));
                    //canvas.DrawPoint(xCoord,yCoord, new SKPaint());

                    var skPaint = new SKPaint();

                    switch (ValuesList[i].Item2)
                    {
                    case PointColor.Green:
                        skPaint.Color = new SKColor(0, 255, 0);
                        break;

                    case PointColor.Red:
                        skPaint.Color = new SKColor(255, 0, 0);
                        break;

                    default:
                        break;
                    }

                    canvas.DrawCircle(xCoord, yCoord, 1, skPaint);

                    var gainyCoord = zCoordEnd.Y - 150 + (zPlotUnit * (float)(GainsList[i]));

                    if (GainsList[i] == maxGains || GainsList[i] == minGains)
                    {
                        canvas.DrawLine(zCoordEnd.X - 5, gainyCoord, zCoordEnd.X + 5, gainyCoord, new SKPaint());

                        var plusSign = GainsList[i] > 0 ? "+" : String.Empty;
                        canvas.DrawText(plusSign + (int)GainsList[i] + "%", zCoordEnd.X + 8, gainyCoord + 5, new SKPaint());
                    }

                    canvas.DrawCircle(xCoord, gainyCoord, 1, new SKPaint());
                }

                canvas.DrawText("0%", zCoordEnd.X + 8, zCoordEnd.Y - 153, new SKPaint());

                //add x labels
                var nOfXLabels     = 8;
                var xLabelPlotUnit = xRange / (nOfXLabels - 1);


                for (int i = 0; i < (nOfXLabels - 1); i++)
                {
                    canvas.DrawLine(xCoordStart.X + (xLabelPlotUnit * i),
                                    yCoordStart.Y - 5, xCoordStart.X + (xLabelPlotUnit * i), yCoordStart.Y + 5,
                                    new SKPaint());

                    var txt = DatesList[(i) * DatesList.Count() / (nOfXLabels - 1)].ToShortDateString();
                    canvas.DrawText(txt, xCoordStart.X + (xLabelPlotUnit * i) - 35,
                                    yCoordStart.Y + 25, new SKPaint());
                }
                canvas.DrawLine(xCoordEnd.X,
                                yCoordStart.Y - 5, xCoordEnd.X, yCoordStart.Y + 5,
                                new SKPaint());
                canvas.DrawText(Dates.Last().ToShortDateString(), xCoordEnd.X - 35,
                                yCoordStart.Y + 25, new SKPaint());


                //add y labels
                var nOfYLabels     = 8;
                var yLabelPlotUnit = yRange / (nOfYLabels - 1);

                var vv  = (float)(Values.Select(n => n.Item1).Max() - Values.Select(n => n.Item1).Min());
                var vv2 = vv / (nOfYLabels - 1);
                for (int i = 0; i < (nOfYLabels - 1); i++)
                {
                    canvas.DrawLine(yCoordStart.X - 5, yCoordStart.Y - (yLabelPlotUnit * i),
                                    yCoordStart.X + 5, yCoordStart.Y - (yLabelPlotUnit * i), new SKPaint());


                    var val = Values.Select(n => n.Item1).Min() + (Decimal)i * (decimal)vv2;
                    canvas.DrawText(((int)val).ToString(), yCoordStart.X - 38,
                                    yCoordStart.Y - (yLabelPlotUnit * i) + 5, new SKPaint());
                }

                canvas.DrawLine(yCoordStart.X - 5, yCoordEnd.Y - 1,
                                yCoordStart.X + 5, yCoordEnd.Y - 1, new SKPaint());

                canvas.DrawText(((int)Values.Select(n => n.Item1).Max()).ToString(), yCoordStart.X - 38,
                                yCoordEnd.Y + 5, new SKPaint());


                //Add z. label (gains)
            }
        }