public static bool DelcomLEDAction(uint hUSB, LightColors color, LightStates action)
        {
            bool success = false;

            //lock here so multiple threads don't try to toggle LEDs at once
            //(though presently only one instance of the program works with the light at a time anyway)
            lock (DelcomLightWrapper.CurrentLEDStates)
            {
                LightStates dictVal;
                if (DelcomLightWrapper.CurrentLEDStates.TryGetValue(color, out dictVal) && dictVal == action)
                {
                    //that LED is already in appropriate state
                    success = true;
                }
                else
                {
                    for (int i = 0; i < LEDMaxFailures; i++)
                    {
                        if (Delcom.DelcomLEDControl(hUSB, (byte)color, (byte)action) == 0)
                        {
                            DelcomLightWrapper.CurrentLEDStates[color] = action;
                            success = true;
                            break;
                        }
                        else
                        {
                            System.Threading.Thread.Sleep(LEDWaitTime);
                        }
                    }
                }
            }

            return(success);
        }
예제 #2
0
    public void ChangeColor()
    {
        var intColor = (int)this.LightColor;

        intColor        = (intColor + 1) % 3;
        this.LightColor = (LightColors)Enum.Parse(typeof(LightColors), intColor.ToString());
    }
예제 #3
0
    void clickNone()
    {
        bool bolt_check = false;

        foreach (Bolt bolt in bolt_list)
        {
            bolt_check = bolt_check || bolt.hasBolt;
        }
        if (bolt_check)
        {
            source.clip = wrong;
            source.Play();
            return;
        }
        if (controller.selected_tool == Tool.ToolType.lamp)
        {
            source.clip = screw;
            source.Play();
            current_color = controller.tool_color;
            SwitchStatus(LightStatus.working);
        }
        else
        {
            source.clip = wrong;
            source.Play();
        }
    }
예제 #4
0
        protected override void LoadContent()
        {
            base.LoadContent();

            const int TEXTURE_WIDTH  = 32;
            const int TEXTURE_HEIGHT = 2048;

            const int LIGHTS_TEXTURE_WIDTH  = 32;
            const int LIGHTS_TEXTURE_HEIGHT = 63;

            uint[] buffer = System.Buffers.ArrayPool <uint> .Shared.Rent(TEXTURE_WIDTH *TEXTURE_HEIGHT * 2);

            try
            {
                HuesLoader.Instance.CreateShaderColors(buffer);

                _hueSamplers[0] = new Texture2D(GraphicsDevice, TEXTURE_WIDTH, TEXTURE_HEIGHT);
                _hueSamplers[0].SetData(buffer, 0, TEXTURE_WIDTH * TEXTURE_HEIGHT);

                _hueSamplers[1] = new Texture2D(GraphicsDevice, TEXTURE_WIDTH, TEXTURE_HEIGHT);
                _hueSamplers[1].SetData(buffer, TEXTURE_WIDTH * TEXTURE_HEIGHT, TEXTURE_WIDTH * TEXTURE_HEIGHT);
            }
            finally
            {
                System.Buffers.ArrayPool <uint> .Shared.Return(buffer, true);
            }


            buffer = System.Buffers.ArrayPool <uint> .Shared.Rent(LIGHTS_TEXTURE_WIDTH *LIGHTS_TEXTURE_HEIGHT);

            try
            {
                LightColors.CreateLookupTables(buffer);

                _hueSamplers[2] = new Texture2D(GraphicsDevice, LIGHTS_TEXTURE_WIDTH, LIGHTS_TEXTURE_HEIGHT);
                _hueSamplers[2].SetData(buffer, 0, LIGHTS_TEXTURE_WIDTH * LIGHTS_TEXTURE_HEIGHT);
            }
            finally
            {
                System.Buffers.ArrayPool <uint> .Shared.Return(buffer, true);
            }


            GraphicsDevice.Textures[1] = _hueSamplers[0];
            GraphicsDevice.Textures[2] = _hueSamplers[1];
            GraphicsDevice.Textures[3] = _hueSamplers[2];

            GumpsLoader.Instance.CreateAtlas(GraphicsDevice);
            LightsLoader.Instance.CreateAtlas(GraphicsDevice);
            AnimationsLoader.Instance.CreateAtlas(GraphicsDevice);

            _fontRenderer = new UOFontRenderer(GraphicsDevice);

            UIManager.InitializeGameCursor();
            AnimatedStaticsManager.Initialize();

            SetScene(new LoginScene());
            SetWindowPositionBySettings();
        }
예제 #5
0
 public void ChangeLight()
 {
     this.Light++;
     if ((int)this.Light > 2)
     {
         this.Light = 0;
     }
 }
예제 #6
0
 public HMISquareIlluminatedButton()
 {
     this.m_LightColor     = LightColors.Green;
     this.m_OutputType     = OutputType.MomentarySet;
     this.sf               = new StringFormat();
     this.tmrError         = new Timer();
     this.sf.Alignment     = StringAlignment.Center;
     this.sf.LineAlignment = StringAlignment.Center;
     this.TextBrush        = new SolidBrush(Color.Black);
     this.TextRectangle    = new Rectangle();
 }
예제 #7
0
        public void ChangeLight()
        {
            var nextValue = (int)this.Light + 1;

            if (nextValue == this.lightsCount)
            {
                nextValue = 0;
            }

            var nextLight = (LightColors)nextValue;

            this.Light = nextLight;
        }
예제 #8
0
        public WaitState()
        {
            Task t = new Task(() =>
            {
                bool light = false;
                while (true)
                {
                    Color = (light = !light) ? LightColors.Orange : LightColors.None;
                    Task.Delay(2000).Wait();
                }
            });

            t.Start();
        }
예제 #9
0
    //Add new color values here
    public static Color getColorFromType(LightColors type)
    {
        switch (type)
        {
        case LightColors.yellow:
            return(new Color(255, 255, 0, 1));

        case LightColors.red:
            return(new Color(255, 0, 0, 1));

        default:
            return(new Color(255, 255, 255, 1));
        }
    }
예제 #10
0
 public HMIMotor2()
 {
     TextRectangle    = new Rectangle();
     m_LightColor     = LightColors.Green;
     m_Rotation       = RotateFlipType.RotateNoneFlipNone;
     m_OutputType     = OutputType.MomentarySet;
     tmrError         = new Timer();
     SourceImageRatio = new decimal((double)Properties.Resources.Motor1_Red_Right.Height / (double)Properties.Resources.Motor1_Red_Right.Width);
     TextBrush        = new SolidBrush(base.ForeColor);
     TextFormat       = new StringFormat()
     {
         Alignment     = StringAlignment.Center,
         LineAlignment = StringAlignment.Far
     };
 }
예제 #11
0
        private void Start()
        {
            if (this.launchFlag != -1)
            {
                this.containerManager = new ContainerManager();
            }

            if (this.launchFlag == 0)
            {
                GuiManager.title.open();
            }
            else if (this.launchFlag > 0)   // Debug instant load
            {
                this.createNewWorld(false); // When false, the world is not saved.
            }
            else
            {
                MeshBuilder.FLAG = true;

                MeshBuilder mb = RenderManager.getMeshBuilder();

                for (int x = -1; x < 2; x++)
                {
                    for (int y = -1; y < 2; y++)
                    {
                        for (int z = -1; z < 2; z++)
                        {
                            mb.setLightLevel(x, y, z, 5 + 1 + x);
                        }
                    }
                }
                // print(mb.getLightLevel(-1, 0, 0));
                // print(mb.getLightLevel(0, 0, 0));
                // print(mb.getLightLevel(1, 0, 0));
                // Light levels
                // +---------> X
                // | 5, 6, 7

                print(mb.sampleAxis(0, EnumAxis.X));
                print(mb.sampleAxis(0.5f, EnumAxis.X));
                print(mb.sampleAxis(-0.5f, EnumAxis.X));


                float i = mb.sampleAxis(0.5f, EnumAxis.X);
                float j = mb.sampleAxis(0.0f, EnumAxis.Y);
                float k = mb.sampleAxis(0.0f, EnumAxis.Z);
                print(i);
                print(j);
                print(k);
                print("Result: " + (i + j + k) / 3);

                LightColors lc = RenderManager.instance.lightColors;

                /*
                 * Color c = mb.calculateLightForVertex(new Vector3(0.5f, 0, 0), new BlockPos(0, 0, 0));
                 * Color l6 = lc.getColorFromBrightness(6);
                 * Color l7 = lc.getColorFromBrightness(7);
                 * print("6: " + l6);
                 * print("/  " + c);
                 * print("\\  "+ (l6 + l7) / 2);
                 * print("7: " + l7);
                 */
            }
        }
예제 #12
0
    public TrafficLight(string lightColorString)
    {
        var lightColor = (LightColors)Enum.Parse(typeof(LightColors), lightColorString);

        this.LightColor = lightColor;
    }
예제 #13
0
 public TrafficLight(string light)
 {
     this.Light = (LightColors)Enum.Parse(typeof(LightColors), light);
 }
예제 #14
0
 public override void SwitchOn(int lightNumber, int blinkOnCycle, int blinkOffCycle, LightColors color, LightAlarms alarm)
 {
     VerifyResult(_cco.SwitchOn(lightNumber, blinkOnCycle, blinkOffCycle, (int)color, (int)alarm));
 }
예제 #15
0
        public SpriteFontObject(int which, Vector2 tile, string TexturePath, Color DrawColor, bool randomColor = true)
        {
            this.drawColor = DrawColor;
            if (randomColor == true)
            {
                this.drawColor = LightColors.randomColor();
            }
            this.tileLocation = tile;
            this.InitializeBasics(0, tile);
            if (TextureSheet == null)
            {
                TextureSheet = Game1.content.Load <Texture2D>(TexturePath);
                texturePath  = TexturePath;
            }
            Dictionary <int, string> dictionary = Game1.content.Load <Dictionary <int, string> >("Data\\Furniture");

            string[] array = dictionary[which].Split(new char[]
            {
                '/'
            });
            this.name              = array[0];
            this.Decoration_type   = this.getTypeNumberFromName(array[1]);
            this.description       = "Can be placed inside your house.";
            this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, 1, 1);
            if (array[2].Equals("-1"))
            {
                this.sourceRect        = this.getDefaultSourceRectForType(which, this.Decoration_type);
                this.defaultSourceRect = this.sourceRect;
            }
            else
            {
                this.defaultSourceRect.Width = Convert.ToInt32(array[2].Split(new char[]
                {
                    ' '
                })[0]);
                this.defaultSourceRect.Height = Convert.ToInt32(array[2].Split(new char[]
                {
                    ' '
                })[1]);
                this.sourceRect        = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, this.defaultSourceRect.Width * 16, this.defaultSourceRect.Height * 16);
                this.defaultSourceRect = this.sourceRect;
            }
            this.defaultBoundingBox = new Rectangle((int)this.tileLocation.X, (int)this.tileLocation.Y, 1, 1);
            if (array[3].Equals("-1"))
            {
                this.boundingBox        = this.getDefaultBoundingBoxForType(this.Decoration_type);
                this.defaultBoundingBox = this.boundingBox;
            }
            else
            {
                this.defaultBoundingBox.Width = Convert.ToInt32(array[3].Split(new char[]
                {
                    ' '
                })[0]);
                this.defaultBoundingBox.Height = Convert.ToInt32(array[3].Split(new char[]
                {
                    ' '
                })[1]);
                this.boundingBox        = new Rectangle((int)this.tileLocation.X * Game1.tileSize, (int)this.tileLocation.Y * Game1.tileSize, this.defaultBoundingBox.Width * Game1.tileSize, this.defaultBoundingBox.Height * Game1.tileSize);
                this.defaultBoundingBox = this.boundingBox;
            }
            this.updateDrawPosition();
            this.rotations        = Convert.ToInt32(array[4]);
            this.price            = Convert.ToInt32(array[5]);
            this.parentSheetIndex = which;
        }
예제 #16
0
 public TrafficLight(LightColors light)
 {
     this.Light       = light;
     this.lightsCount = Enum.GetNames(typeof(LightColors)).Length;
 }