示例#1
0
    // Work out display type from wall type and shortlist (make tiles calculate in future)
    private void CalculateDisplayColour()
    {
        string dispType = "";

        CheckIfDisplaying(Wavelength.I, ref dispType);
        CheckIfDisplaying(Wavelength.V, ref dispType);
        CheckIfDisplaying(Wavelength.U, ref dispType);
        // If the wall exists for any colour
        if (dispType != "")
        {
            // If the wall used to be air, and had changable sprite colour, reset the colour to white
            if (displayType == BitType.Air)
            {
                sprite.color = Color.white;
            }
            displayWavelength    = (Wavelength)System.Enum.Parse(typeof(Wavelength), dispType);
            dispType            += "Wall";
            displayType          = (BitType)System.Enum.Parse(typeof(BitType), dispType);
            wallCollider.enabled = true;
        }
        // If the wall is hidden
        else
        {
            displayWavelength    = Wavelength.None;
            displayType          = BitType.Air;
            wallCollider.enabled = false;
        }
    }
示例#2
0
 // Swap the wavelength affecting the list of grids
 private void SwapAffector(Wavelength newAffector, Wavelength oldAffector)
 {
     foreach (Grid g in gridsAffecting)
     {
         g.SwapAffector(newAffector, oldAffector);
     }
 }
示例#3
0
 // Checks if a colour required to hide the wall is absent, and appends the representative letter
 private void CheckIfDisplaying(Wavelength colour, ref string dispType)
 {
     if (wallColours[(int)colour] && !shortList[(int)colour])
     {
         dispType += colour.ToString();
     }
 }
示例#4
0
 // For recieving an update from the grid this bit is in
 public void UpdatedByGrid(bool[] shortList, Wavelength shortListEnum)
 {
     this.shortList     = shortList;
     this.shortListEnum = shortListEnum;
     UpdateSprite();
     //UpdateNeighbours();
     //UpdateBitShape();
     if (neighbourDependant)
     {
         world.UpdateAdjacentBits(this);
     }
 }
示例#5
0
 public override void GiveMulticolourInfo(Color32 pixel)
 {
     if (pixel.Equals(new Color32(153, 0, 0, 255)))
     {
         startColour = Wavelength.I;
     }
     else if (pixel.Equals(new Color32(153, 153, 0, 255)))
     {
         startColour = Wavelength.V;
     }
     else if (pixel.Equals(new Color32(153, 0, 153, 255)))
     {
         startColour = Wavelength.U;
     }
 }
示例#6
0
    private void MakeShortList()
    {
        string sLE = "";

        if (affectors.Contains(Wavelength.I))
        {
            shortList[(int)Wavelength.I] = true;
            sLE += "I";
        }
        else
        {
            shortList[(int)Wavelength.I] = false;
        }

        if (affectors.Contains(Wavelength.V))
        {
            shortList[(int)Wavelength.V] = true;
            sLE += "V";
        }
        else
        {
            shortList[(int)Wavelength.V] = false;
        }

        if (affectors.Contains(Wavelength.U))
        {
            shortList[(int)Wavelength.U] = true;
            sLE += "U";
        }
        else
        {
            shortList[(int)Wavelength.U] = false;
        }
        if (sLE == "")
        {
            sLE = "None";
        }
        shortListEnum = (Wavelength)System.Enum.Parse(typeof(Wavelength), sLE);
    }
示例#7
0
        protected bool ConfigWavelength(string dutcurrentchannel)
        {
            //string CurrnentWavelength = "";
            bool flag = false;

            string[] wavtemp = new string[4];
            Wavelength = Wavelength.Trim();
            wavtemp    = Wavelength.Split(new char[] { ',' });
            byte i = Convert.ToByte(Convert.ToInt16(dutcurrentchannel) - 1);

            try
            {
                //flag = MyIO.WriteString(":sense" + AttSlot + ":channel " + AttChannel + ":power:wavelength" + wavtemp[i] + "E-9");
                flag = MyIO.WriteString(":INP" + AttSlot + ":WAV " + wavtemp[i] + "nm");
                logger.AdapterLogString(0, "AttSlot is" + AttSlot + "Wavelength is" + wavtemp[i] + "nm");
                return(flag);
            }
            catch (Exception error)
            {
                logger.AdapterLogString(3, error.ToString());
                return(false);
            }
        }
示例#8
0
        protected bool ConfigWavelength(string dutcurrentchannel, int syn = 0)
        {
            lock (syncRoot)
            {
                //string CurrnentWavelength = "";
                bool     flag     = false;
                bool     flag1    = false;
                int      k        = 0;
                string   readtemp = "";
                double   waveinput;
                double   waveoutput;
                string[] wavtemp = new string[4];
                Wavelength = Wavelength.Trim();
                wavtemp    = Wavelength.Split(new char[] { ',' });
                byte i = Convert.ToByte(Convert.ToInt16(dutcurrentchannel) - 1);
                try
                {
                    if (syn == 0)
                    {
                        Log.SaveLogToTxt("AttSlot is" + AttSlot + ":Channel" + AttChannel + "Wavelength is" + wavtemp[i] + "nm");
                        return(this.WriteString(":INP" + AttSlot + ":Channel" + AttChannel + ":WAV " + wavtemp[i] + "nm"));
                    }
                    else
                    {
                        for (int j = 0; j < 3; j++)
                        {
                            flag1 = this.WriteString(":INP" + AttSlot + ":Channel" + AttChannel + ":WAV " + wavtemp[i] + "nm");
                            if (flag1 == true)
                            {
                                break;
                            }
                        }
                        if (flag1 == true)
                        {
                            for (k = 0; k < 3; k++)
                            {
                                this.WriteString(":INP" + AttSlot + ":Channel" + AttChannel + ":WAV?");
                                readtemp   = this.ReadString();
                                waveinput  = Convert.ToDouble(wavtemp[i]);
                                waveoutput = Convert.ToDouble(readtemp) * Math.Pow(10, 9);
                                if (waveinput == waveoutput)
                                {
                                    break;
                                }
                            }
                            if (k <= 3)
                            {
                                flag = true;
                                Log.SaveLogToTxt("AttSlot is" + AttSlot + ":Channel" + AttChannel + "Wavelength is" + wavtemp[i] + "nm");
                            }
                            else
                            {
                                Log.SaveLogToTxt("ATT set Wavelength wrong");
                            }
                        }

                        return(flag);
                    }
                }
                catch (InnoExCeption error)
                {
                    Log.SaveLogToTxt("ErrorCode=" + ExceptionDictionary.Code._Funtion_Fatal_0x05002 + "Reason=" + error.TargetSite.Name + "Fail");
                    throw error;
                }

                catch (Exception error)
                {
                    Log.SaveLogToTxt("ErrorCode=" + ExceptionDictionary.Code._Funtion_Fatal_0x05002 + "Reason=" + error.TargetSite.Name + "Fail");
                    throw new InnoExCeption(ExceptionDictionary.Code._Funtion_Fatal_0x05002, error.StackTrace);
                    // throw new InnoExCeption(ex);
                }
            }
        }
示例#9
0
 public override int GetHashCode()
 {
     return(Wavelength.GetHashCode());
 }
示例#10
0
 // Get the sprite for a Wavelength
 public Sprite GetAirColourSprites(Wavelength wl)
 {
     return(airColourSprites[wl]);
 }
示例#11
0
 // Add air colour to dictionary
 public void AddAirColourSprite(Wavelength wl, Sprite sprite)
 {
     airColourSprites.Add(wl, sprite);
 }
示例#12
0
 // When rotating a beacons colours, and don't want to waste a call to the finish function
 public void SwapAffector(Wavelength newAffector, Wavelength oldAffector)
 {
     affectors.Remove(oldAffector);
     affectors.Add(newAffector);
     FinishAffectorUpdate();
 }
示例#13
0
 // When only removing an affector from the list
 public void RemoveAffector(Wavelength oldAffector)
 {
     affectors.Remove(oldAffector);
     FinishAffectorUpdate();
 }
示例#14
0
 // When only adding an affector to the list
 public void AddAffector(Wavelength newAffector)
 {
     affectors.Add(newAffector);
     FinishAffectorUpdate();
 }
示例#15
0
 private void StartBeaconInfo()
 {
     beaconOutput = neighbours[(int)Direction.up].BeaconGetWaveLength();
     pickup       = neighbours[(int)Direction.right].BeaconGetPickup();
     direction    = world.GetGrid(worldPos).GetBit(gridPos.x + 1, gridPos.y + 1).BeaconGetFacing();
 }
示例#16
0
        private bool ConfigWavelength(string dutCurrentChannel, int syn = 0)
        {
            lock (syncRoot)
            {
                bool     flag           = false;
                string[] wavelengthList = new string[4];
                byte     i = Convert.ToByte(Convert.ToInt16(dutCurrentChannel) - 1);

                Wavelength     = Wavelength.Trim();
                wavelengthList = Wavelength.Split(',');

                try
                {
                    if (syn == 0)
                    {
                        Log.SaveLogToTxt("AttSlot is " + AttSlot + ", DeviceChannel is "
                                         + DeviceChannel + ", Wavelength is " + wavelengthList[i] + "nm");
                        return(this.WriteString(":OUTP:WAV " + AttSlot + "," + DeviceChannel + "," + wavelengthList[i]));
                    }
                    else
                    {
                        bool   tempFlag = false;
                        string readtemp = "";
                        int    k        = 0;

                        for (int j = 0; j < 3; j++)
                        {
                            tempFlag = this.WriteString(":OUTP:WAV " + AttSlot + "," + DeviceChannel + "," + wavelengthList[i]);

                            if (tempFlag)
                            {
                                break;
                            }
                        }

                        if (tempFlag)
                        {
                            for (k = 0; k < 3; k++)
                            {
                                Thread.Sleep(100);
                                this.WriteString(":OUTP:WAV? " + AttSlot + "," + DeviceChannel);

                                readtemp = this.ReadString();
                                if (Convert.ToDouble(readtemp) == Convert.ToDouble(wavelengthList[i]))
                                {
                                    break;
                                }
                            }

                            if (k <= 2)
                            {
                                Log.SaveLogToTxt("AttSlot is " + AttSlot + ", DeviceChannel is "
                                                 + DeviceChannel + ", Wavelength is " + wavelengthList[i] + "nm");
                                flag = true;
                            }
                            else
                            {
                                Log.SaveLogToTxt("ConfigWavelength wrong");
                            }
                        }
                        return(flag);
                    }
                }
                catch (Exception error)
                {
                    Log.SaveLogToTxt(error.ToString());

                    return(false);
                }
            }
        }