Beispiel #1
0
        void UpdateSchedule()
        {
            try
            {
                var currentSchedule = DS_Schedule.Current as Schedule;

                ComponentQuery componentQuery = new ComponentQuery(_SERVER.ServerName.Database);
                var            component      = componentQuery.GetShoeComponents(currentSchedule.Model, currentSchedule.ModelName);
                var            order          = BeamCutQuery.GetBDeviceOrder(currentSchedule);

                MachineProgressViewer.UpdateOrderDetail(currentSchedule);

                BeginInvoke(new MethodInvoker(() =>
                {
                    lvComponent.Items.Clear();
                    if (component == null)
                    {
                        return;
                    }
                    var names = component.Select(i => i.Reference).ToArray();
                    foreach (string name in names)
                    {
                        lvComponent.Items.Add(name);
                    }
                }));
            }
            catch { }
        }
Beispiel #2
0
        // stop cut
        public RespCutting(IDbName database, int binterfaceId, int beamCounter)
        {
            BeamCutQuery   = new BeamCutQuery(database);
            StockQuery     = new StockQuery(database);
            EmployeeQuery  = new EmployeeQuery(database);
            SequenceQuery  = new SequenceQuery(database);
            ScheduleQuery  = new ScheduleQuery(database);
            ComponentQuery = new ComponentQuery(database);

            try
            {
                var bInterface = BeamCutQuery.GetBeamInterfaceById(binterfaceId);
                if (bInterface == null)
                {
                    Exception = new RespException(true, "Can not find BInterface", EKB_SYS_REQUEST.BEAM_STOP_CUTTING);
                    return;
                }

                bInterface.Finish         = true;
                bInterface.BeamCutCounter = beamCounter;
                bInterface.StopCutTime    = DateTime.Now;
                if (!BeamCutQuery.UpdateBeamInterface(bInterface))
                {
                    Exception = new RespException(true, "Can not update BInterface", EKB_SYS_REQUEST.BEAM_STOP_CUTTING);
                    return;
                }
                Exception = new RespException(false, "Stop cutting: OK", EKB_SYS_REQUEST.BEAM_STOP_CUTTING);
            }
            catch (Exception e)
            {
                Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_STOP_CUTTING);
            }
        }
Beispiel #3
0
        public void CreateEntityFromPrefab()
        {
            ECSWorld world  = new ECSWorld();
            var      buffer = new EntityCommandBuffer(world);

            SharedComponent1 shared1 = new SharedComponent1();
            Prefab           prefab  = new Prefab();

            prefab.AddComponent(new TestComponent1 {
                i = 1, d = 2, f = 3
            });
            prefab.AddSharedComponent(shared1);


            buffer.CreateEntity(prefab);
            buffer.Playback();

            ComponentQuery query = new ComponentQuery();

            query.IncludeReadWrite <TestComponent1>();
            query.IncludeShared <SharedComponent1>();

            Assert.Collection(world.ComponentManager.GetBlocks(query), accessor => {
                Assert.Equal(1, accessor.GetEntityData().Length);
                var cData = accessor.GetComponentData <TestComponent1>();
                Assert.Equal(1, cData[0].i);
                Assert.Equal(2d, cData[0].d, 3);
                Assert.Equal(3f, cData[0].f, 3);

                var shared = accessor.GetSharedComponentData <SharedComponent1>();
                Assert.Same(shared1, shared);
            });
        }
Beispiel #4
0
        public void DestroyEntity()
        {
            ECSWorld world  = new ECSWorld();
            var      buffer = new EntityCommandBuffer(world);

            SharedComponent1 shared1   = new SharedComponent1();
            EntityArchetype  archetype = EntityArchetype.Empty;

            archetype = archetype.Add <TestComponent1>();
            archetype = archetype.AddShared(shared1);


            buffer.CreateEntity(archetype);
            buffer.Playback();

            ComponentQuery query = new ComponentQuery();

            query.IncludeReadWrite <TestComponent1>();
            query.IncludeShared <SharedComponent1>();

            Entity e = default;

            Assert.Collection(world.ComponentManager.GetBlocks(query), accessor => {
                Assert.Equal(1, accessor.GetEntityData().Length);
                e = accessor.GetEntityData()[0];
            });

            buffer.DestroyEntity(e);
            buffer.Playback();

            Assert.Empty(world.ComponentManager.GetBlocks(query));
        }
Beispiel #5
0
        public void RemoveSharedComponentFromEntity()
        {
            ECSWorld world  = new ECSWorld();
            var      buffer = new EntityCommandBuffer(world);

            SharedComponent1 shared1   = new SharedComponent1();
            EntityArchetype  archetype = EntityArchetype.Empty;

            archetype = archetype.Add <TestComponent1>();
            archetype = archetype.AddShared(shared1);

            Entity target = world.Instantiate(archetype);

            buffer.RemoveSharedComponent <SharedComponent1>(target);
            buffer.Playback();

            ComponentQuery query = new ComponentQuery();

            query.IncludeReadWrite <TestComponent1>();
            query.ExcludeShared <SharedComponent1>();

            Assert.Collection(world.ComponentManager.GetBlocks(query), accessor => {
                Assert.Equal(1, accessor.GetEntityData().Length);
            });
        }
Beispiel #6
0
        public void SetComponentToEntity()
        {
            ECSWorld world  = new ECSWorld();
            var      buffer = new EntityCommandBuffer(world);

            SharedComponent1 shared1   = new SharedComponent1();
            EntityArchetype  archetype = EntityArchetype.Empty;

            archetype = archetype.Add <TestComponent1>();
            archetype = archetype.AddShared(shared1);

            Entity target = world.Instantiate(archetype);

            buffer.SetComponent(target, new TestComponent1 {
                i = 2, d = 3, f = 4
            });
            buffer.Playback();

            ComponentQuery query = new ComponentQuery();

            query.IncludeReadWrite <TestComponent1>();
            query.IncludeShared <SharedComponent1>();

            Assert.Collection(world.ComponentManager.GetBlocks(query), accessor => {
                Assert.Equal(1, accessor.GetEntityData().Length);

                var cData = accessor.GetComponentData <TestComponent1>();
                Assert.Equal(2, cData[0].i);
                Assert.Equal(3d, cData[0].d, 3);
                Assert.Equal(4f, cData[0].f, 3);
            });
        }
        public override ComponentQuery GetQuery()
        {
            ComponentQuery query = new ComponentQuery();

            query.IncludeReadonly <Asteroid>();
            return(query);
        }
 public override void OnCreateSystem(ECSWorld world)
 {
     cameraQuery = new ComponentQuery();
     cameraQuery.IncludeShared <Camera>();
     cameraQuery.IncludeReadonly <Position>();
     cameraQuery.IncludeReadonly <Rotation>();
 }
        public void HashCodeSame()
        {
            ComponentQuery query1 = new ComponentQuery();

            query1.IncludeReadWrite <TestComponent1>();
            ComponentQuery query2 = new ComponentQuery();

            query2.IncludeReadWrite <TestComponent1>();

            Assert.Equal(query1.GetHashCode(), query2.GetHashCode());

            query1 = new ComponentQuery();
            query1.Exclude <TestComponent1>();
            query2 = new ComponentQuery();
            query2.Exclude <TestComponent1>();

            Assert.Equal(query1.GetHashCode(), query2.GetHashCode());

            query1 = new ComponentQuery();
            query1.IncludeShared <SharedComponent1>();
            query2 = new ComponentQuery();
            query2.IncludeShared <SharedComponent1>();

            Assert.Equal(query1.GetHashCode(), query2.GetHashCode());

            query1 = new ComponentQuery();
            query1.ExcludeShared <SharedComponent1>();
            query2 = new ComponentQuery();
            query2.ExcludeShared <SharedComponent1>();

            Assert.Equal(query1.GetHashCode(), query2.GetHashCode());
        }
Beispiel #10
0
        public override ComponentQuery GetQuery()
        {
            ComponentQuery query = new ComponentQuery();

            query.IncludeReadonly <InternalStaticBodyHandle>();
            query.Exclude <StaticRigidBody>();
            return(query);
        }
Beispiel #11
0
        public override ComponentQuery GetQuery()
        {
            var query = new ComponentQuery();

            query.IncludeReadonly <CameraFollow>();
            query.IncludeReadWrite <Position>();
            return(query);
        }
Beispiel #12
0
        public override ComponentQuery GetQuery()
        {
            ComponentQuery query = new ComponentQuery();

            query.IncludeShared <MeshCollider>();
            query.Exclude <InternalColliderHandle>();
            return(query);
        }
Beispiel #13
0
 public Unblock(IDbName _database)
 {
     database        = _database;
     BuildingQuery   = new BuildingQuery(database);
     SequenceQuery   = new SequenceQuery(database);
     SysHistoryQuery = new SysHistoryQuery(database);
     ComponentQuery  = new ComponentQuery(database);
 }
        public override ComponentQuery GetQuery()
        {
            ComponentQuery query = new ComponentQuery();

            query.IncludeReadonly <BoundingBox>();
            query.IncludeShared <CulledRenderTag>();
            return(query);
        }
Beispiel #15
0
        public override ComponentQuery GetQuery()
        {
            ComponentQuery query = new ComponentQuery();

            query.IncludeReadonly <BoxCollider>();
            query.Exclude <InternalColliderHandle>();
            return(query);
        }
Beispiel #16
0
            public override ComponentQuery GetQuery()
            {
                ComponentQuery query = new ComponentQuery();

                query.IncludeReadWrite <Rotation>();
                query.IncludeReadonly <RotateComponent>();
                return(query);
            }
Beispiel #17
0
        public override ComponentQuery GetQuery()
        {
            var query = new ComponentQuery();

            query.IncludeReadonly <PhysicsBodyLockAxis>();
            query.Exclude <PhysicsBodyLockedValues>();

            return(query);
        }
        public override ComponentQuery GetQuery()
        {
            ComponentQuery query = new ComponentQuery();

            query.IncludeReadWrite <BoundingBox>();
            query.IncludeReadonly <ObjectToWorld>();
            query.IncludeShared <MeshRenderer>();
            return(query);
        }
Beispiel #19
0
            public override ComponentQuery GetQuery()
            {
                ComponentQuery query = new ComponentQuery();

                query.IncludeShared <FaceCameraComponent>();
                query.IncludeReadWrite <Position>();
                query.IncludeReadWrite <Rotation>();
                return(query);
            }
Beispiel #20
0
        public override ComponentQuery GetQuery()
        {
            ComponentQuery query = new ComponentQuery();

            query.IncludeReadonly <Player>();
            query.IncludeReadonly <Rotation>();
            query.IncludeReadWrite <Velocity>();
            query.IncludeReadWrite <AngularVelocity>();
            return(query);
        }
Beispiel #21
0
        public override ComponentQuery GetQuery()
        {
            var query = new ComponentQuery();

            query.IncludeShared <Camera>();
            query.IncludeReadWrite <Position>();
            query.IncludeReadWrite <Rotation>();
            query.IncludeReadonly <CameraFlightComponent>();
            return(query);
        }
        public override ComponentQuery GetQuery()
        {
            ComponentQuery query = new ComponentQuery();

            query.IncludeReadWrite <RigidBody>();
            query.IncludeReadWrite <Position>();
            query.IncludeReadWrite <Rotation>();
            query.IncludeReadonly <Velocity>();
            query.IncludeReadonly <AngularVelocity>();
            return(query);
        }
Beispiel #23
0
        public override ComponentQuery GetQuery()
        {
            ComponentQuery query = new ComponentQuery();

            query.IncludeReadonly <StaticRigidBody>();
            query.IncludeReadWrite <InternalColliderHandle>();
            query.IncludeReadonly <Position>();
            query.IncludeReadonly <Rotation>();
            query.Exclude <InternalStaticBodyHandle>();
            query.Exclude <RigidBody>();
            return(query);
        }
Beispiel #24
0
        public override ComponentQuery GetQuery()
        {
            var query = new ComponentQuery();

            query.IncludeReadWrite <Position>();
            query.IncludeReadWrite <Rotation>();
            query.IncludeReadWrite <Velocity>();
            query.IncludeReadWrite <AngularVelocity>();
            query.IncludeReadonly <PhysicsBodyLockedValues>();
            query.IncludeReadonly <PhysicsBodyLockAxis>();
            return(query);
        }
Beispiel #25
0
        public RespComponent(IDbName _database, int _scheduleId, int originalPoId)
        {
            try
            {
                ComponentQuery componentQuery = new ComponentQuery(_database);
                ScheduleQuery  scheduleQuery  = new ScheduleQuery(_database);
                SequenceQuery  SequenceQuery  = new SequenceQuery(_database);

                var schedule = scheduleQuery.GetSchedule(_scheduleId);

                var originalPo = SequenceQuery.GetOriginalPo(originalPoId);

                if (schedule == null)
                {
                    if (originalPo == null)
                    {
                        Exception = new RespException(true, "Can not find original po", EKB_SYS_REQUEST.BEAM_GET_COMPONENT);
                        return;
                    }

                    schedule = scheduleQuery.GetSchedule(originalPo);
                    if (schedule == null)
                    {
                        Exception = new RespException(true, "Can not find schedule", EKB_SYS_REQUEST.BEAM_GET_COMPONENT);
                        return;
                    }
                }

                var components = componentQuery.GetModelComponents(schedule.Model);

                if (components == null)
                {
                    Exception = new RespException(true, "Can not find component list", EKB_SYS_REQUEST.BEAM_GET_COMPONENT);
                    return;
                }

                components = components.OrderByDescending(i => i.CuttingType.id).ToList();

                ComponentList = new List <Component_t>();

                foreach (var item in components)
                {
                    ComponentList.Add(new Component_t(item));
                }

                Exception = new RespException(false, "Get component: Ok", EKB_SYS_REQUEST.BEAM_GET_COMPONENT);
            }
            catch (Exception e)
            {
                Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_COMPONENT);
            }
        }
        public void Exclude()
        {
            ComponentQuery query = new ComponentQuery();

            query.Exclude <TestComponent2>();

            Assert.True(query.Matches(archetypeEmpty));
            Assert.False(query.Matches(archetypeC1C2S1));
            Assert.False(query.Matches(archetypeC1C2S1S2));
            Assert.True(query.Matches(archetypeC1));
            Assert.False(query.Matches(archetypeC1C2));
            Assert.True(query.Matches(archetypeC1S1));
            Assert.False(query.Matches(archetypeC2S1));
        }
        public void IncludeShared()
        {
            ComponentQuery query = new ComponentQuery();

            query.IncludeShared <SharedComponent1>();
            query.IncludeShared <SharedComponent2>();

            Assert.False(query.Matches(archetypeEmpty));
            Assert.False(query.Matches(archetypeC1C2S1));
            Assert.True(query.Matches(archetypeC1C2S1S2));
            Assert.False(query.Matches(archetypeC1));
            Assert.False(query.Matches(archetypeC1C2));
            Assert.False(query.Matches(archetypeC1S1));
            Assert.False(query.Matches(archetypeC2S1));
        }
Beispiel #28
0
        public void OnCreateSystem(ECSWorld world)
        {
            //camera = new Camera() {
            //	aspect = (float)Window.window.Width / (float)Window.window.Height,
            //	farPlane = 10000,
            //	fow = 60,
            //	nearPlane = 0.1f
            //};

            //cameraPosition = new Vector3(4 , 10, 20);
            //cameraRotation = MathHelper.LookAt(cameraPosition, Vector3.Zero, Vector3.UnitY);
            cameraQuery = new ComponentQuery();
            cameraQuery.IncludeShared <Camera>();
            cameraQuery.IncludeReadonly <Position>();
            cameraQuery.IncludeReadonly <Rotation>();

            foreach (var assembly in AssemblyHelper.GetAllUserAssemblies())
            {
                foreach (Type type in AssemblyHelper.GetTypesWithAttribute(assembly, typeof(RenderSystemAttribute)))
                {
                    try
                    {
                        if (!type.GetInterfaces().Contains(typeof(IRenderSystem)))
                        {
                            continue;
                        }

                        RenderSystemAttribute attribute =
                            type.GetCustomAttribute(typeof(RenderSystemAttribute)) as RenderSystemAttribute;
                        IRenderSystem instance = Activator.CreateInstance(type) as IRenderSystem;

                        RegisterRenderSystem(instance, type, attribute.renderStage, attribute.renderBefore,
                                             attribute.renderAfter);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"could not create an instance of type {type.Name}. Does it have an empty constructor? \n{ex.StackTrace}");
                    }
                }
            }

            foreach (var renderSystem in systems)
            {
                renderSystem.Value.OnCreate(world);
            }
        }
        public void HashCodeNotZero()
        {
            ComponentQuery query1 = new ComponentQuery();

            query1.IncludeReadWrite <TestComponent1>();
            Assert.NotEqual(0, query1.GetHashCode());

            query1 = new ComponentQuery();
            query1.Exclude <TestComponent1>();
            Assert.NotEqual(0, query1.GetHashCode());

            query1 = new ComponentQuery();
            query1.IncludeShared <SharedComponent1>();
            Assert.NotEqual(0, query1.GetHashCode());

            query1 = new ComponentQuery();
            query1.ExcludeShared <SharedComponent1>();
            Assert.NotEqual(0, query1.GetHashCode());
        }
Beispiel #30
0
        public void CreateEntitySetComponent()
        {
            ECSWorld world  = new ECSWorld();
            var      buffer = new EntityCommandBuffer(world);

            SharedComponent1 shared1 = new SharedComponent1();
            Prefab           prefab  = new Prefab();

            prefab.AddComponent(new TestComponentVector3()
            {
                value = Vector3.UnitY
            });
            prefab.AddSharedComponent(shared1);


            buffer.CreateEntity(prefab);
            buffer.CreateEntity(prefab);
            buffer.SetComponent(new TestComponentVector3 {
                value = Vector3.UnitX
            });
            buffer.CreateEntity(prefab.Archetype);
            buffer.SetComponent(new TestComponentVector3 {
                value = Vector3.UnitZ
            });
            buffer.Playback();

            ComponentQuery query = new ComponentQuery();

            query.IncludeReadWrite <TestComponentVector3>();
            query.IncludeShared <SharedComponent1>();

            Assert.Collection(world.ComponentManager.GetBlocks(query), accessor => {
                Assert.Equal(3, accessor.GetEntityData().Length);
                var cData = accessor.GetComponentData <TestComponentVector3>();
                Assert.Equal(Vector3.UnitY, cData[0].value);
                Assert.Equal(Vector3.UnitX, cData[1].value);
                Assert.Equal(Vector3.UnitZ, cData[2].value);

                var shared = accessor.GetSharedComponentData <SharedComponent1>();
                Assert.Same(shared1, shared);
            });
        }