Пример #1
0
 public void SetupContext(string gsaFileName)
 {
     gsaInterfacer         = new GSAProxy();
     gsaCache              = new GSACache();
     Initialiser.Interface = gsaInterfacer;
     Initialiser.Cache     = gsaCache;
     Initialiser.Settings  = new Settings();
     gsaInterfacer.OpenFile(Helper.ResolveFullPath(gsaFileName, TestDataDirectory));
 }
        public void SetupContext()
        {
            gsaInterfacer = new GSAProxy();
            gsaCache      = new GSACache();

            Initialiser.Cache     = gsaCache;
            Initialiser.Interface = gsaInterfacer;
            Initialiser.Settings  = new Settings();
        }
Пример #3
0
        public void SetupTests()
        {
            //This uses the installed SpeckleKits - when SpeckleStructural is built, the built files are copied into the
            // %LocalAppData%\SpeckleKits directory, so therefore this project doesn't need to reference the projects within in this solution
            SpeckleInitializer.Initialize();
            gsaInterfacer = new GSAProxy();
            gsaCache      = new GSACache();

            Initialiser.Cache     = gsaCache;
            Initialiser.Interface = gsaInterfacer;
            Initialiser.Settings  = new Settings();
        }
Пример #4
0
        public void SetupTests()
        {
            //This uses the installed SpeckleKits - when SpeckleStructural is built, the built files are copied into the
            // %LocalAppData%\SpeckleKits directory, so therefore this project doesn't need to reference the projects within in this solution

            //If this isn't called, then the GetObjectSubtypeBetter method in SpeckleCore will cause a {"Value cannot be null.\r\nParameter name: source"} message
            SpeckleInitializer.Initialize();
            gsaInterfacer = new GSAProxy();
            gsaCache      = new GSACache();

            Initialiser.Cache     = gsaCache;
            Initialiser.Interface = gsaInterfacer;
            Initialiser.Settings  = new Settings();
        }
Пример #5
0
        public SenderProcessor(string directory, GSAProxy gsaInterfacer, GSACache gsaCache, GSATargetLayer layer, bool embedResults, string[] cases = null, string[] resultsToSend = null) : base(directory)
        {
            GSAInterfacer = gsaInterfacer;
            Initialiser.Settings.TargetLayer = layer;

            Initialiser.Settings.EmbedResults = embedResults;
            if (cases != null)
            {
                Initialiser.Settings.ResultCases = cases.ToList();
            }
            if (resultsToSend != null)
            {
                processResultLabels(resultsToSend);
            }
        }
        private void ConvertSpeckleObjectsToGsaInterfacerCache()
        {
            // Write objects
            var currentBatch      = new List <Type>();
            var traversedTypes    = new List <Type>();
            var TypePrerequisites = Helper.GetTypeCastPriority(ioDirection.Receive, GSATargetLayer.Design, false);

            do
            {
                currentBatch = TypePrerequisites.Where(i => i.Value.Count(x => !traversedTypes.Contains(x)) == 0).Select(i => i.Key).ToList();
                currentBatch.RemoveAll(i => traversedTypes.Contains(i));

                foreach (var t in currentBatch)
                {
                    var dummyObject     = Activator.CreateInstance(t);
                    var keyword         = dummyObject.GetAttribute("GSAKeyword").ToString();
                    var valueType       = t.GetProperty("Value").GetValue(dummyObject).GetType();
                    var speckleTypeName = ((SpeckleObject)((IGSASpeckleContainer)dummyObject).Value).Type;
                    var targetObjects   = receivedObjects.Where(o => o.Item2.GetType() == valueType).ToList();

                    for (var i = 0; i < targetObjects.Count(); i++)
                    {
                        var streamId = targetObjects[i].Item1;
                        var obj      = targetObjects[i].Item2;

                        //DESERIALISE
                        var deserialiseReturn = ((string)Converter.Deserialise(obj));
                        var gwaCommands       = deserialiseReturn.Split(new[] { '\n' }).Where(c => c.Length > 0).ToList();

                        for (var j = 0; j < gwaCommands.Count(); j++)
                        {
                            Initialiser.Interface.ParseGeneralGwa(gwaCommands[j], out keyword, out int?foundIndex, out string foundStreamId, out string foundApplicationId, out string gwaWithoutSet, out GwaSetCommandType? gwaSetCommandType);

                            GSAInterfacer.SetGwa(gwaCommands[j]);

                            //Only cache the object against, the top-level GWA command, not the sub-commands
                            GSACache.Upsert(keyword, foundIndex.Value, gwaWithoutSet, applicationId: foundApplicationId, so: (foundApplicationId == obj.ApplicationId) ? obj : null);
                        }
                    }


                    traversedTypes.Add(t);
                }
            } while (currentBatch.Count > 0);
        }
        public void JsonSpeckleStreamsToGwaRecords(IEnumerable <string> savedJsonFileNames, out List <GwaRecord> gwaRecords)
        {
            gwaRecords = new List <GwaRecord>();

            receivedObjects = JsonSpeckleStreamsToSpeckleObjects(savedJsonFileNames);

            ScaleObjects();

            ConvertSpeckleObjectsToGsaInterfacerCache();

            var gwaCommands = GSACache.GetGwaSetCommands();

            foreach (var gwaC in gwaCommands)
            {
                GSAInterfacer.ParseGeneralGwa(gwaC, out var keyword, out int?index, out var streamId, out var applicationId, out var gwaWithoutSet, out GwaSetCommandType? gwaSetType);
                gwaRecords.Add(new GwaRecord(string.IsNullOrEmpty(applicationId) ? null : applicationId, gwaC));
            }
        }
 public ReceiverProcessor(string directory, GSAProxy gsaInterfacer, GSACache gsaCache, GSATargetLayer layer = GSATargetLayer.Design) : base(directory)
 {
     GSAInterfacer = gsaInterfacer;
     GSACache      = gsaCache;
     Initialiser.Settings.TargetLayer = layer;
 }