Example #1
0
        private void HandleMouseWheel(int obj)
        {
            var factor = obj / 20d;

            foreach (var item in Lamps.Where(i => i.Highlighted && !i.Locked))
            {
                double newVal = item.Strenght + factor;
                if (newVal > byte.MaxValue)
                {
                    item.Strenght = 255;
                }
                else if (newVal < byte.MinValue)
                {
                    item.Strenght = 0;
                }
                else
                {
                    item.Strenght += (byte)factor;
                }
            }
        }
Example #2
0
 public ScannerProps( byte[] data )
 {
     BinaryReader br = new System.IO.BinaryReader( new MemoryStream( data ) );
     WorkMode = (WorkMode)br.ReadInt16();
     DpiX0 = br.ReadInt16();
     DpiY0 = br.ReadInt16();
     DpiX1 = br.ReadInt16();
     DpiY1 = br.ReadInt16();
     DoubleSheet = (DoubleSheet)br.ReadInt16();
     Marker = (Marker)br.ReadInt16();
     DoubleSheetLevelL = br.ReadInt16();
     WhiteCoeff = (WhiteCoeff)br.ReadInt16();
     BinaryThreshold0 = br.ReadInt16();
     BinaryThreshold1 = br.ReadInt16();
     MinSheetLength = br.ReadInt16();
     MaxSheetLength = br.ReadInt16();
     DoubleSheetLevelR = br.ReadInt16();
     TuningMode = (TuningMode)br.ReadInt16();
     MarkerWork = br.ReadInt16();
     DirtDetection = (DirtDetection)br.ReadInt16();
     OfflineMode = br.ReadInt16();
     Lamps = (Lamps)br.ReadInt16();
     reserv = new short[21];
     for ( int i = 0; i < reserv.Length; i++ )
     {
         reserv[i] = br.ReadInt16();
     }
     br.Close();
 }
        /// <summary>
        /// Updates the machine configuration collections. Switches, lamps, coils etc.
        /// </summary>
        private void UpdateMachineConfigCollections()
        {
            Log("Updating UI Collections");

            //Add only the switches not containing dedicated and flipper
            if (MachineConfig.PRSwitches != null)
            {
                Log("Adding dedicated switches");

                //Quick hack for PDB switches. Need to put the 64-127 range of switch into the dedicated collection...
                if (MachineConfig.GetMachineType() == MachineType.PDB)
                {
                    var lowRange = MachineConfig.PRSwitches.Where(x => x.Number.Contains("SD") &&
                                                                  Convert.ToByte(x.Number.Replace("SD", "")) < 64);
                    var hiRange = MachineConfig.PRSwitches.Where(x => x.Number.Contains("SD") &&
                                                                 (Convert.ToByte(x.Number.Replace("SD", "")) < 128 && Convert.ToByte(x.Number.Replace("SD", "")) > 63));

                    Switches.AddRange(lowRange.Select(x => new SwitchViewModel(x)));
                    DedicatedSwitches.AddRange(hiRange.Select(x => new SwitchViewModel(x)));
                }
                else
                {
                    DedicatedSwitches.AddRange(MachineConfig.PRSwitches
                                               .Where(x => x.Number.Contains("SD"))
                                               .Select(x => new SwitchViewModel(x)).OrderBy(x => x.Number));

                    Log("Adding switches");
                    Switches.AddRange(MachineConfig.PRSwitches
                                      .Where(x => !x.Number.Contains("F") & !x.Number.Contains("SD"))
                                      .Select(x => new SwitchViewModel(x)).OrderBy(x => x.Number));
                }

                Log("Adding flipper switches");
                FlippersSwitches.AddRange(MachineConfig.PRSwitches
                                          .Where(x => x.Number.Contains("SF"))
                                          .Select(x => new SwitchViewModel(x)).OrderBy(x => x.Number));
            }
            else
            {
                Log("PRSwitches doesn't exist");
            }

            if (MachineConfig.PRCoils != null)
            {
                Coils.AddRange(MachineConfig.PRCoils.Select(x => new SolenoidFlasherViewModel(x)).OrderBy(x => x.Number));
            }
            else
            {
                Log("PRCoils doesn't exist");
            }

            if (MachineConfig.PRLamps != null)
            {
                Lamps.AddRange(MachineConfig.PRLamps.Select(x => new LampViewModel(x)).OrderBy(x => x.Number));
            }
            else
            {
                Log("PRLamps doesn't exist");
            }

            if (MachineConfig.PRLeds != null)
            {
                PRLeds.AddRange(MachineConfig.PRLeds.Select(x => new LampViewModel(x)));//.OrderBy(x => x.Number.Replace("A8-", "")));
            }
            else
            {
                Log("PRLeds doesn't exist");
            }
        }