Ejemplo n.º 1
0
        public void TellMeDemands(EngineContainer container)
        {
            if (container == null || container.ItemFlows == null || container.ItemFlows.Count == 0)
            {
                return;
            }

            #region Initialize
            kb  = new KB(container.Plans, container.InvBalances, container.DemandChains);
            jit = new JIT(container.Plans, container.InvBalances, container.DemandChains);
            odp = new ODP(container.Plans, container.InvBalances, container.DemandChains);
            #endregion

            #region Container param
            List <ItemFlow>    ItemFlows    = container.ItemFlows;
            List <Plans>       Plans        = container.Plans;
            List <InvBalance>  InvBalances  = container.InvBalances;
            List <DemandChain> DemandChains = container.DemandChains;
            #endregion

            #region Process time
            List <Flow> flows = ItemFlows.Select(s => s.Flow).Distinct().ToList <Flow>();
            this.ProcessTime(flows);
            #endregion

            #region Process ReqQty
            foreach (var itemFlow in ItemFlows)
            {
                this.DataValidCheck(itemFlow);
                this.SetFlowProperty(itemFlow, flows);

                this.ProcessReqQty(itemFlow);
            }
            #endregion
        }
Ejemplo n.º 2
0
        EngineContainer SaveCache(string key, IEnumerable <Lazy <IEngine, IEngineMetadata> > engines)
        {
            if (EngineCache == null)
            {
                EngineCache = new Dictionary <string, EngineContainer>();
            }

            return(EngineCache[key] = new EngineContainer(engines));
        }
Ejemplo n.º 3
0
        public static async Task Main(string[] args)
        {
            var engine = new EngineContainer();

            if (args.Length > 0)
            {
                await engine.Run(args);
            }
        }
Ejemplo n.º 4
0
		IEnumerable<FileAssociation> ProcessEngine(ProjectItem projectItem, string filename, EngineContainer engine)
		{
			List<EngineResult> engineResults = null;
			try
			{
				var contents = FileHandler.GetContents(filename);

				engineResults = engine.Process(contents, filename);
			}
			catch (Exception e)
			{
				TaskList.Add(e.Message, filename, ErrorCategory.Error);

				Console.WriteLine("{0}", e.Message);
			}

			if (engineResults == null)
				yield break;

			foreach (var engineResult in engineResults)
			{
				if (engineResult.Exceptions.Any())
				{
					var error = false;
					foreach (var exception in engineResult.Exceptions)
					{
						if (string.IsNullOrEmpty(exception.FileName))
						{
							exception.FileName = filename;
						}
						error = error || exception.Category == ErrorCategory.Error;
						TaskList.Add(exception);
					}
					if (error)
					{
						continue;
					}
				}

				if (engineResult.Contents == null)
					continue;

				var outputFilename = engineResult.FileName;

				if (!string.IsNullOrEmpty(engineResult.Extension))
					outputFilename = GetOutputFileName(engineResult, filename, engine);

				outputFilename = FileHandler.GetAbsoluteFileName(outputFilename, filename);

				FileHandler.SaveFile(outputFilename, engineResult.Contents);

				yield return new FileAssociation(outputFilename, projectItem);

				Logger.Log(string.Format("{0} > {1}", engine.Name, outputFilename));
			}
		}
Ejemplo n.º 5
0
		void SaveDependencies(ProjectItem projectItem, string filename, string contents, EngineContainer engine)
		{
			RemoveDependenciesForFile(projectItem);

			var dependencies = engine.GetDependencies(contents, filename);

			if (dependencies == null)
				return;

			AddDependenciesForFile(projectItem, filename, dependencies);
		}
Ejemplo n.º 6
0
		string GetOutputFileName(EngineResult result, string filename, EngineContainer engine)
		{
			var baseFileName = filename;

			if (!string.IsNullOrEmpty(result.FileName))
				baseFileName = result.FileName;

			var inputExtension = ExtensionResolver.GetExtensionFromCategory(engine.Category);

			if (baseFileName.EndsWith(inputExtension))
				baseFileName = filename.Substring(0, filename.Length - inputExtension.Length);
			else
				baseFileName = FileHandler.GetBaseFileName(baseFileName);

			return string.Format("{0}.{1}", baseFileName, result.Extension);
		}
Ejemplo n.º 7
0
        public static int Sector_AllowTraverse(RoomSector rs, float floor, EngineContainer container)
        {
            var f0 = rs.FloorCorners[0][2];
            if (rs.FloorCorners[1][2] != f0 || rs.FloorCorners[2][2] != f0 || rs.FloorCorners[3][2] != f0)
            {
                return 0x00;
            }

            if (Math.Abs(floor - f0) < 1.1f && rs.Ceiling - rs.Floor >= TR_METERING_SECTORSIZE)
            {
                return 0x01;
            }

            var cb = new BtEngineClosestRayResultCallback(container);
            var from = new Vector3(rs.Position.X, rs.Position.Y, floor + TR_METERING_SECTORSIZE * 0.5f);
            var to = new Vector3(rs.Position.X, rs.Position.Y, floor - TR_METERING_SECTORSIZE * 0.5f);
            BtEngineDynamicsWorld.RayTest(from.ToBullet(), to.ToBullet(), cb);
            if (cb.HasHit)
            {
                Vector3 v;
                Helper.SetInterpolate3(out v, from, to, cb.ClosestHitFraction);
                if (Math.Abs(v.Z - floor) < 1.1f)
                {
                    var cont = (EngineContainer) cb.CollisionObject.UserObject;
                    if (cont != null && cont.ObjectType == OBJECT_TYPE.Entity &&
                        ((Entity) cont.Object).TypeFlags.HasFlag(ENTITY_TYPE.TraverseFloor))
                    {
                        return 0x01;
                    }
                }
            }

            return 0x00;
        }
Ejemplo n.º 8
0
		EngineContainer SaveCache(string key, IEnumerable<Lazy<IEngine, IEngineMetadata>> engines)
		{
			if (EngineCache == null)
				EngineCache = new Dictionary<string, EngineContainer>();

			return EngineCache[key] = new EngineContainer(engines);
		}