示例#1
0
 /// <summary>
 /// 输出组信息命令流
 /// </summary>
 void ExptGroups()
 {
     Sw.WriteLine("*GROUP");
     for (int i = 0; i < Model.Groups.Count; i++)
     {
         string     groupi_name = Model.Groups[i].Gname;
         List <int> groupi_no   = Model.Groups[i].Ele_no;
         groupi_no.Sort();
         List <string> groupi_DomList  = FunctionClass.GetDomain(groupi_no);
         List <string> groupi_DomList2 = FunctionClass.mergeList(groupi_DomList, 60);//单元列表改为每一行60个字符
         string        cmd             = null;
         for (int j = 0; j < groupi_DomList2.Count; j++)
         {
             if (j == 0)
             {
                 cmd = groupi_name + "," + " " + "," + groupi_DomList2[0];
             }
             else
             {
                 cmd = groupi_DomList2[j];
             }
             Sw.WriteLine(cmd);
         }
     }
 }
示例#2
0
            public PropertyFormatter Property(String methodName)
            {
                Sw.Append("this.");
                Sw.Append(methodName);

                return(new PropertyFormatter(this));
            }
示例#3
0
        public void RemoveMenus()
        {
            foreach (eMenu menu in _ListeMnu)
            {
                menu.Remove();
            }

            for (int i = 1; i < 80000; i++)
            {
                var cg = CmdMgr.GetCommandGroup(i);
                if (cg.IsRef())
                {
                    Log.Message("CommandGroup " + cg.Name + "(" + i + ") supp : " + (swRemoveCommandGroupErrors)CmdMgr.RemoveCommandGroup2(i, false));
                }
            }

            foreach (eTypeDoc T in Enum.GetValues(typeof(eTypeDoc)))
            {
                Object[] tTab = CmdMgr.CommandTabs((int)Sw.eGetSwTypeDoc(T));

                if (tTab.IsRef())
                {
                    foreach (CommandTab tab in tTab)
                    {
                        Log.Message(tab.Name + " supp : " + CmdMgr.RemoveCommandTab(tab));
                    }
                }
            }
        }
示例#4
0
 public MethodFormatter Method(String methodName)
 {
     Sw.Append("this.");
     Sw.Append(methodName);
     Sw.Append("(");
     return(new MethodFormatter(this));
 }
示例#5
0
        /// <summary>
        /// 获取时间并停止
        /// </summary>
        public void LogTime(string title = null)
        {
            Sw.Stop();
            var ms = Sw.ElapsedMilliseconds;

            Log?.Invoke($"{title}{(title != null ? ": " : "")}{ms}ms", null);
        }
示例#6
0
 public void Inicializar()
 {
     Before2 = GC.CollectionCount(2);
     Before1 = GC.CollectionCount(1);
     Before0 = GC.CollectionCount(0);
     Sw.Start();
 }
        /// <summary>
        /// 写文本文件
        /// </summary>
        /// <param name="Content"></param>
        /// <param name="FilePath"></param>
        /// <returns></returns>
        public static bool Writer(string Content, string FilePath)
        {
            bool check = false;

            if (!File.Exists(FilePath))
            {
                return(false);
            }
            StreamWriter Sw;

            Sw = File.AppendText(FilePath);
            try
            {
                Sw.WriteLine(Content);
                check = true;
            }
            catch
            {
                check = false;
            }
            finally
            {
                Sw.Close();
                Sw = null;
            }

            return(check);
        }
示例#8
0
        /// <summary>
        /// 获取时间并停止
        /// </summary>
        public void ConsoleTime(string title = null)
        {
            Sw.Stop();
            var ms = Sw.ElapsedMilliseconds;

            Console.WriteLine($"{title}{(title != null ? ": " : "")}{ms}ms");
        }
示例#9
0
 public Beaverland()
 {
     InitializeComponent();
     TimerStart();
     FigureTimer();
     Sw.Start();
 }
示例#10
0
 /// <summary>
 /// Generates defines liens for generic and specific types. One line for each define:
 /// </summary>
 private void Generate_SpecificDevice()
 {
     if (GenericDeviceList != null)
     {
         foreach (GenericDevice gDev in GenericDeviceList)
         {
             //if (gDev.KeyId < 0xE0 || gDev.KeyId >= 0xFF)
             {
                 Sw.WriteLine("/* Device class {0} */",
                     Tools.CutUpperUnderscoreToMixedUpperLower(gDev.Name, Options1.ChGenericDeviceNamePrefix,
                         " "));
                 Generate_DefineLine(gDev, 0);
                 if (CommonSpecificDeviceList != null)
                     foreach (SpecificDevice entrySpecific in CommonSpecificDeviceList)
                     {
                         Generate_DefineLine(entrySpecific, 0);
                     }
                 if (gDev.SpecificDevice != null)
                     foreach (SpecificDevice entrySpecific in gDev.SpecificDevice)
                     {
                         Generate_DefineLine(entrySpecific, 0);
                     }
                 Sw.WriteLine("");
             }
         }
     }
 }
示例#11
0
        private DrawingDoc CreerPlan(String materiau, Double epaisseur, Boolean mettreAJourExistant)
        {
            String Fichier = NomFichierPlan(materiau, epaisseur);

            if (DicDessins.ContainsKey(Fichier))
            {
                return(DicDessins[Fichier]);
            }

            DrawingDoc Dessin = null;
            ModelDoc2  Mdl    = null;

            if (mettreAJourExistant)
            {
                Mdl = Sw.eOuvrir(Path.Combine(DossierDVP, Fichier), eTypeDoc.Dessin);
            }

            if (Mdl.IsNull())
            {
                Dessin = Sw.eCreerDocument(DossierDVP, Fichier, eTypeDoc.Dessin, CONSTANTES.MODELE_DE_DESSIN_LASER).eDrawingDoc();
            }
            else
            {
                Dessin = Mdl.eDrawingDoc();
                return(Dessin);
            }

            Dessin.eFeuilleActive().SetName(Fichier);
            DicDessins.Add(Fichier, Dessin);

            Dessin.eModelDoc2().pAppliquerOptionsDessinLaser(AfficherNotePliage, TailleInscription);

            return(Dessin);
        }
示例#12
0
 public async Task <IActionResult> PutSO2Cleaner(Actuator data)
 {
     using (var httpClient = new HttpClient())
     {
         Console.WriteLine(JsonConvert.SerializeObject(data));
         Sw sw = new Sw()
         {
             Switch = data.Switch
         };
         var           c       = JsonConvert.SerializeObject(sw);
         StringContent content = new StringContent(c, Encoding.UTF8, "application/json");
         using (var response = await httpClient.PutAsync("http://gateway:3000/so2/cleaner", content))
         {
             string response1 = await response.Content.ReadAsStringAsync();
         }
     }
     using (var httpClient = new HttpClient())
     {
         Level lv = new Level()
         {
             Lvl = data.Lvl
         };
         var           c       = JsonConvert.SerializeObject(lv);
         StringContent content = new StringContent(c, Encoding.UTF8, "application/json");
         using (var response = await httpClient.PutAsync("http://gateway:3000/so2/cleaner/lvl", content))
         {
             string response2 = await response.Content.ReadAsStringAsync();
         }
     }
     return(Ok());
 }
示例#13
0
 private static void LogMessage(string message)
 {
     if (null != Sw)
     {
         Sw.WriteLine(message);
     }
     Console.Error.WriteLine(message);
 }
示例#14
0
        private DrawingDoc CreerPlan(String materiau, Double epaisseur)
        {
            String Fichier = String.Format("{0}{1} - Ep{2}",
                                           String.IsNullOrWhiteSpace(RefFichier) ? "" : RefFichier + " - ",
                                           materiau.eGetSafeFilename("-"),
                                           epaisseur.ToString().Replace('.', ',')
                                           ).Trim();

            if (DicDessins.ContainsKey(Fichier))
            {
                return(DicDessins[Fichier]);
            }

            if (MajPlans)
            {
                var di            = new DirectoryInfo(DossierDVP);
                var NomFichierExt = Fichier + eTypeDoc.Dessin.GetEnumInfo <ExtFichier>();
                var r             = di.GetFiles(NomFichierExt, SearchOption.TopDirectoryOnly);
                if (r.Length > 0)
                {
                    int        Erreur = 0, Warning = 0;
                    DrawingDoc dessin = App.Sw.OpenDoc6(Path.Combine(DossierDVP, NomFichierExt),
                                                        (int)swDocumentTypes_e.swDocDRAWING,
                                                        (int)swOpenDocOptions_e.swOpenDocOptions_Silent,
                                                        "",
                                                        ref Erreur,
                                                        ref Warning).eDrawingDoc();
                    DicDessins.Add(Fichier, dessin);

                    return(dessin);
                }
            }

            DrawingDoc Dessin = Sw.eCreerDocument(DossierDVP, Fichier, eTypeDoc.Dessin, CONSTANTES.MODELE_DE_DESSIN_LASER).eDrawingDoc();

            Dessin.eFeuilleActive().SetName(Fichier);
            DicDessins.Add(Fichier, Dessin);

            ModelDoc2 mdl = Dessin.eModelDoc2();

            LayerMgr LM = mdl.GetLayerManager();

            LM.AddLayer("GRAVURE", "", 1227327, (int)swLineStyles_e.swLineCONTINUOUS, (int)swLineWeights_e.swLW_LAYER);
            LM.AddLayer("QUANTITE", "", 1227327, (int)swLineStyles_e.swLineCONTINUOUS, (int)swLineWeights_e.swLW_LAYER);

            ModelDocExtension ext = mdl.Extension;

            ext.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swFlatPatternOpt_ShowFixedFace, 0, false);
            ext.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swShowSheetMetalBendNotes, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, AfficherNotePliage);

            TextFormat tf = ext.GetUserPreferenceTextFormat(((int)(swUserPreferenceTextFormat_e.swDetailingAnnotationTextFormat)), 0);

            tf.CharHeight = TailleInscription / 1000.0;
            ext.SetUserPreferenceTextFormat((int)swUserPreferenceTextFormat_e.swDetailingAnnotationTextFormat, 0, tf);

            return(Dessin);
        }
示例#15
0
        /// <summary>
        /// 获取时间并重置继续
        /// </summary>
        public long GetTimeRestart()
        {
            Sw.Stop();
            var ms = Sw.ElapsedMilliseconds;

            Sw.Restart();

            return(ms);
        }
示例#16
0
            public Formatter CommentLine(String text)
            {
                if (!Sw.HasWhiteLine)
                {
                    Sw.AppendLine();
                }

                Sw.Append("// ");
                Sw.AppendLine(text);
                return(this);
            }
        private void Ouvrir_Modele_Click(object sender, RoutedEventArgs e)
        {
            var Mi    = sender as MenuItem;
            var V     = (Mi.Parent as ContextMenu).PlacementTarget as ListView;
            var corps = (Corps)V.SelectedItem;

            if (corps.IsRef())
            {
                Sw.eOuvrir(corps.CheminFichierRepere);
            }

            this.Topmost = true;
        }
示例#18
0
        public long Add()
        {
            Sw.Reset();
            Sw.Start();
            for (int i = 0; i < _size; i++)
            {
                _collection.Add(i, i);
            }

            Sw.Stop();

            return(Sw.ElapsedTicks);
        }
示例#19
0
    public void ChooseStage(int lv)
    {
        Debug.Log("选择关卡" + lv);
        int l = lv % sws.Length;

        for (int i = 0; i < sws.Length; i++)
        {
            sws[i].gameObject.SetActive(false);
        }
        sws[l].gameObject.SetActive(true);
        activeSw = sws[l];
        activeSw.Ini(lv);
    }
示例#20
0
        void Write(LogLevel logLevel, EventId eventId, string message, Exception ex)
        {
            EnsureInitFile();

            //TODO 提高效率 队列写!!!
            var log = String.Concat(DateTime.Now.ToString("HH:mm:ss"), '[', logLevel.ToString(), ']', '[',
                                    Thread.CurrentThread.ManagedThreadId.ToString(), ',', eventId.Id.ToString(), ',', eventId.Name, ']',
                                    Delimiter, message, Delimiter, ex?.ToString());

            lock (this)
            {
                Sw.WriteLine(log);
            }
        }
示例#21
0
 private void Save()
 {
     if (mSettingsNeedSaving)
     {
         string       newSettings = Path.Combine(Path.GetDirectoryName(mSettingsFile), "new." + Path.GetFileName(mSettingsFile));
         StreamWriter Sw;
         Sw = File.CreateText(newSettings);
         foreach (KeyValuePair <string, string> setting in mSettings)
         {
             Sw.WriteLine(setting.Key + mSeparator + setting.Value);
         }
         Sw.Close();
     }
 }
示例#22
0
        public long Reach()
        {
            var rnd = new Random();

            Sw.Reset();
            Sw.Start();
            for (int i = 0; i < 100; i++)
            {
                _collection.ContainsKey(rnd.Next(0, _size));
            }

            Sw.Stop();

            return(Sw.ElapsedTicks);
        }
示例#23
0
 /// <summary>
 /// 输出梁单元荷载
 /// </summary>
 void ExptBLoad()
 {
     Sw.WriteLine("*STLDCASE");
     Sw.WriteLine("    DeadLoad,D,");
     Sw.WriteLine("    LiveLoad,L,");
     Sw.WriteLine("*USE-STLD,DeadLoad");
     Sw.WriteLine("*SELFWEIGHT");
     Sw.WriteLine("0,0,-1");
     Sw.WriteLine("*BEAMLOAD");
     for (int i = 0; i < Model.BeamLoads.Count; i++)
     {
         BeamLoadCls loadi = Model.BeamLoads[i];
         Sw.WriteLine("   {0},Beam,UNILOAD,{1},NO,NO,aDir[1], , , , 0,{2},1,{2},0,0,0,0,,NO,0,0,NO,", loadi.EleNo, loadi.CoordDir, loadi.Value);
     }
 }
 public void Write()
 {
     Sw.WriteLine("infoText:{0}", InfoText);
     Sw.WriteLine();
     Sw.WriteLine("dictionaryAbbreviation:{0}", DictionaryAbbreviation);
     Sw.WriteLine("numberOfAvailableLanguages:2");
     Sw.WriteLine();
     Sw.WriteLine(@"indexFileSeparationCharacter:'\t'");
     Sw.WriteLine(@"searchListFileSeparationCharacter:'\t'");
     Sw.WriteLine(@"dictionaryFileSeparationCharacter:'\t'");
     Sw.WriteLine(@"dictionaryGenerationSeparatorCharacter:'\t'");
     Sw.WriteLine();
     Sw.WriteLine("dictionaryGenerationInputCharEncoding:UTF-8");
     Sw.WriteLine("indexCharEncoding:UTF-8");
     Sw.WriteLine("searchListCharEncoding:UTF-8");
     Sw.WriteLine("dictionaryCharEncoding:UTF-8");
     Sw.WriteLine();
     Sw.WriteLine("dictionaryGenerationOmitParFromIndex:true");
     Sw.WriteLine();
     Sw.WriteLine("language1DisplayText:{0}", _displayText[1]);
     Sw.WriteLine("language1FilePostfix:{0}", _filePostfix[1]);
     Sw.WriteLine();
     Sw.WriteLine("language1IsSearchable:true");
     Sw.WriteLine("language1GenerateIndex:true");
     Sw.WriteLine("language1HasSeparateDictionaryFile:false");
     Sw.WriteLine();
     Sw.WriteLine("language2DisplayText:{0}", _displayText[2]);
     Sw.WriteLine("language2FilePostfix:{0}", _filePostfix[2]);
     Sw.WriteLine();
     Sw.WriteLine("language2IsSearchable:true");
     Sw.WriteLine("language2GenerateIndex:true");
     Sw.WriteLine("language2HasSeparateDictionaryFile:false");
     Sw.WriteLine();
     Sw.WriteLine("language1NumberOfContentDeclarations:{0}", Language1NumberOfContentDeclarations);
     Sw.WriteLine("language2NumberOfContentDeclarations:1");
     for (int n = 1; n <= Language1NumberOfContentDeclarations; n++)
     {
         Sw.WriteLine("language1Content{0:D2}DisplayText:{1}", n, _styles.DisplayText(n));
         Sw.WriteLine("language1Content{0:D2}FontColour:{1}", n, _styles.FontColor(n));
         Sw.WriteLine("language1Content{0:D2}FontStyle:{1}", n, _styles.ContentStyle(n));
         Sw.WriteLine("language1Content{0:D2}DisplaySelectable:true", n);
     }
     Sw.WriteLine();
     Sw.WriteLine("language2Content01DisplayText:Gloss");
     Sw.WriteLine("language2Content01FontColour:128,0,0");
     Sw.WriteLine("language2Content01FontStyle:plain");
     Sw.WriteLine("language2Content01DisplaySelectable:true");
 }
示例#25
0
 /// <summary>
 /// 输出壳元命令流
 /// </summary>
 void ExptShells()
 {
     for (int k = 0; k < Model.ShellElements.Count; k++)
     {
         ShellElementCls shellk          = Model.ShellElements[k];
         List <int>      shellK_nodesInd = shellk.Nodes_no;
         if (shellK_nodesInd.Count == 3)
         {
             Sw.WriteLine("    {0},PLATE,{1},{2},{3},{4},{5},0,3,0", shellk.Ele_no, shellk.Mat, shellk.Prop, shellK_nodesInd[0] + 1, shellK_nodesInd[1] + 1, shellK_nodesInd[2] + 1);
         }
         if (shellK_nodesInd.Count == 4)
         {
             Sw.WriteLine("    {0},PLATE,{1},{2},{3},{4},{5},{6},3,0", shellk.Ele_no, shellk.Mat, shellk.Prop, shellK_nodesInd[0] + 1, shellK_nodesInd[1] + 1, shellK_nodesInd[2] + 1, shellK_nodesInd[3] + 1);
         }
     }
 }
示例#26
0
        public override bool WrtFile(string logString, string logLevel, string module, DateTime date)
        {
            var file = new FileInfo(NameFile);

            if (!file.Exists)
            {
                file.Create().Dispose();
            }
            lock (LockObj)
            {
                Sw = File.AppendText(NameFile);
                Sw.WriteLine($"{date} | {logLevel} | {logString} | {module}");
            }


            return(true);
        }
示例#27
0
 /// <summary>
 /// 输出节点和梁单元命令流
 /// </summary>
 void ExptNodesBeams()
 {
     //输出节点信息
     Sw.WriteLine("*UNIT");
     Sw.WriteLine("N,MM,J,C");
     Sw.WriteLine("*NODE");
     for (int i = 0; i < Model.Nodes.Count; i++)
     {
         Sw.WriteLine("    {0},{1},{2},{3}", i + 1, Model.Nodes[i].X, Model.Nodes[i].Y, Model.Nodes[i].Z);
     }
     //输出梁单元信息
     Sw.WriteLine("*ELEMENT");
     for (int j = 0; j < Model.BeamElements.Count; j++)
     {
         BeamElementCls beami         = Model.BeamElements[j];
         List <int>     beamiNodesInd = beami.Nodes_no;
         if (beamiNodesInd.Count == 2)
         {
             Sw.WriteLine("    {0},BEAM,{1},{2},{3},{4},{5},{6}", beami.Ele_no, beami.Mat, beami.Prop, beamiNodesInd[0] + 1, beamiNodesInd[1] + 1, beami.Beta, 0);
         }
     }
 }
示例#28
0
            public Info(String materiau, String baseMat, Double volume, Boolean herite = false)
            {
                Materiau = materiau;
                Base     = baseMat;
                Volume   = volume;
                Herite   = herite;

                if (_DicDensite.ContainsKey(Materiau))
                {
                    Densite = _DicDensite[Materiau];
                    Classe  = _DicClasse[Materiau];
                }
                else
                {
                    String _classe;
                    Densite = Sw.eProprieteMat(Base, Materiau, eMatPropriete.densite, out _classe);
                    _DicDensite.Add(Materiau, Densite);
                    Classe = _classe;
                    _DicClasse.Add(Materiau, _classe);
                }

                Masse = Volume * Densite;
            }
示例#29
0
        private void Structs(CommandClass cmdClass, Command cmd, Param vgParam)
        {
            const string structPrefixVg = "VG";
            const string structPostfixVg = "VG";
            string structPrefix = cmd == null && vgParam != null ? structPrefixVg : "ZW";
            string structPostfix = cmd == null && vgParam != null ? structPostfixVg : "FRAME";

            const string structFieldFormat = "{0}{1,-10}{2,-30}{3}";
            if (cmd == null || cmd.Name == "CRC_16_ENCAP" ||
                !cmd.Name.EndsWith(Options1.ChEncapsulatedCommandIdentifier))
            {
                // determine if the command has Param.ParamType.VARIANT or Param.ParamType.BITMASK

                #region Determine count params and groups

                int structCount = 1;
                var list = new SortedList<string, Param>();
                list.Add("", null);

                IList<Param> parameters = null;
                if (cmd != null)
                {
                    parameters = cmd.Param;
                }
                else if (vgParam != null)
                {
                    parameters = vgParam.Param1;
                }

                if (parameters != null)
                    foreach (Param param in parameters)
                    {
                        if (param.SkipField)
                            continue;
                        if (param.Param1 != null && param.Param1.Count > 0 &&
                            (param.Size > 1 || param.SizeReference != null))
                        {
                            structCount = 4;
                            Structs(cmdClass, null, param);
                        }
                        else
                        {
                            if (param.Bits >= 8)
                            {
                                if (!list.ContainsKey(param.Name))
                                    list.Add(param.Name, param);
                                else
                                    throw new ApplicationException("Command " + cmd != null
                                        ? cmd.Name
                                        : vgParam.Name + " already has parameter " + param.Name);
                            }
                            if (param.Type == zwParamType.BITMASK && param.Size != 1 ||
                                param.SizeReference != null)
                            {
                                if (structCount == 4)
                                {
                                    SystemLogSingleton.Instance.DoAddLogLine(
                                        SystemLogSingleton.Category.Warning,
                                        SystemLogSingleton.Action.CodeGeneration,
                                        Tools.FormatStr("Multiple VARIANT/BITMASK found in command {0}",
                                            cmd != null ? cmd.Name : vgParam.Name)
                                    );
                                    break;
                                }
                                structCount = 4;
                            }
                        }
                    }

                #endregion

                string versionPostfix = "";
                if (cmdClass.Version > 1) versionPostfix = "_V" + cmdClass.Version;
                for (int structIdx = 1; structIdx <= structCount; structIdx++)
                {
                    string byteStr = "";
                    if (structCount > 1)
                    {
                        byteStr = "_" + structIdx + "BYTE";
                    }

                    Sw.WriteLine("/{0}/", DuplicateStr("*", 60));
                    if (cmd != null)
                    {
                        Sw.WriteLine("{0,-60}", GetTypeStructCaptionCmd(cmdClass, cmd, byteStr, versionPostfix));
                    }
                    else if (vgParam != null)
                    {
                        Sw.WriteLine("{0,-60}", GetTypeStructCaptionVg(cmdClass, vgParam, byteStr, versionPostfix));
                    }
                    Sw.WriteLine("/{0}/", DuplicateStr("*", 60));
                    if (cmd != null)
                    {
                        Sw.WriteLine("typedef struct _{0}_{1}_{2}_", structPrefix,
                            GetTypeStructNameCmd(cmdClass, cmd, byteStr, versionPostfix), structPostfix);
                    }
                    else if (vgParam != null)
                    {
                        Sw.WriteLine("typedef struct _{0}_{1}_{2}_", structPrefix,
                            GetTypeStructNameVg(cmdClass, vgParam, byteStr, versionPostfix), structPostfix);
                    }
                    Sw.WriteLine("{");
                    string tab1 = MakeTabs(1);
                    if (cmd != null)
                    {
                        Sw.WriteLine(structFieldFormat, tab1, "uint8_t", "cmdClass;", "/* The command class */");
                        string cmdName = "cmd;";
                        string cmdComment = "/* The command */";
                        if (cmd.Bits > 0 && cmd.Bits < 8)
                        {
                            if (cmd.Param != null && cmd.Param.Count > 0)
                            {
                                cmdName = "cmd_" + Tools.MakeLegalMixCaseIdentifier(cmd.Param[0].Param1[0].Text) +
                                          ";";
                                cmdComment = "/* The command + parameter " + cmd.Param[0].Param1[0].Text + " */";
                            }
                        }
                        Sw.WriteLine(structFieldFormat, tab1, "uint8_t", cmdName, cmdComment);
                    }

                    #region foreach params

                    parameters = cmd != null ? cmd.Param : vgParam.Param1;
                    if (parameters != null)
                        foreach (Param param in parameters)
                        {
                            if (cmd != null && cmd.Name.StartsWith("SECURITY_MESSAGE_ENCAPSULATION") &&
                                param.Name == "commandClassIdentifier")
                                continue;
                            if (cmd != null && cmd.Name.StartsWith("SECURITY_MESSAGE_ENCAPSULATION") &&
                                param.Name == "commandIdentifier")
                                continue;
                            if (param.SkipField)
                                continue;
                            if (cmd != null && cmd.Bits > 0 && cmd.Bits < 8 && param.Order == 0 &&
                                param.Param1 != null && param.Param1.Count > 0)
                            {
                            }
                            else if (param.Param1 != null && param.Param1.Count > 0 &&
                                     (param.Size > 1 || param.SizeReference != null))
                            {
                                for (int i = 1; i <= structIdx; i++)
                                {
                                    Sw.WriteLine(
                                        structFieldFormat,
                                        tab1,
                                        Tools.FormatStr("{0}_{1}_{2} ", structPrefixVg,
                                            GetTypeStructNameCmd(cmdClass, cmd, _lastVgByteStr, versionPostfix),
                                            structPostfixVg),
                                        Tools.MakeLegalMixCaseIdentifier("variantGroup" + i) + ";",
                                        "/*" + param.Comment + "*/");
                                }
                            }
                            else
                            {
                                string comment = "/*" + param.Comment + "*/";
                                if (param.Param1 != null && param.Param1.Count > 0 && param.Bits > 1)
                                {
                                    comment = "/* masked byte */";
                                }
                                int byteFieldCount = 0;
                                if (param.Type == zwParamType.BITMASK && param.Size != 1 ||
                                    param.SizeReference != null)
                                {
                                    byteFieldCount = structIdx;
                                }

                                else if (param.Bits % 8 == 0)
                                {
                                    if (param.Bits == 8 && param.Size <= 1)
                                    {
                                        byteFieldCount = 0;
                                        Sw.WriteLine(structFieldFormat, tab1, "uint8_t",
                                            Tools.MakeLegalMixCaseIdentifier(param.Text) + ";", comment);
                                    }
                                    else
                                    {
                                        byteFieldCount = param.Size <= 1
                                            ? param.Bits / 8
                                            : param.Size * (param.Bits / 8);
                                    }
                                }
                                //if (byteFieldCount > 0 && param.Size > 1 &&
                                //    !((param.Type == zwParamType.BITMASK && param.Size != 1) || param.SizeReference != null))
                                //{
                                //    sw.WriteLine(StructFieldFormat, tab1, "uint8_t", Tools.MakeLegalMixCaseIdentifier(param.Text) + "[" + byteFieldCount.ToString() + "];", comment);
                                //}
                                //else
                                //{
                                if (cmd != null && cmd.Name.StartsWith("SECURITY_MESSAGE_ENCAPSULATION") &&
                                    param.Name == "commandByte")
                                {
                                    Sw.WriteLine(structFieldFormat, tab1, "uint8_t", "commandClassIdentifier" + ";",
                                        "/**/");
                                    Sw.WriteLine(structFieldFormat, tab1, "uint8_t", "commandIdentifier" + ";",
                                        "/**/");
                                }
                                for (int i = 1; i <= byteFieldCount; i++)
                                {
                                    if (i == 1 && byteFieldCount > 1)
                                    {
                                        comment = "/* MSB */";
                                    }
                                    else if (i == byteFieldCount && byteFieldCount > 1)
                                    {
                                        comment = "/* LSB */";
                                    }
                                    else
                                    {
                                        comment = "";
                                    }
                                    if (param.Text.StartsWith("Receiver’s Entropy Input"))
                                    {
                                    }
                                    Sw.WriteLine(structFieldFormat, tab1, "uint8_t",
                                        Tools.MakeLegalMixCaseIdentifier(param.Text) + i + ";", comment);
                                }
                                //}
                            }
                        }

                    #endregion

                    Sw.Write("}");
                    if (cmd != null)
                    {
                        Sw.WriteLine(" {0}_{1}_{2};", structPrefix,
                            GetTypeStructNameCmd(cmdClass, cmd, byteStr, versionPostfix), structPostfix);
                    }
                    else
                    {
                        _lastVgByteStr = byteStr;
                        Sw.WriteLine(" {0}_{1}_{2};", structPrefix,
                            GetTypeStructNameVg(cmdClass, vgParam, byteStr, versionPostfix), structPostfix);
                    }
                    Sw.WriteLine("");
                }
            }
        }
示例#30
0
        /// <summary>
        /// Generates Command Defines in the following format
        /// </summary>
        /// <code>
        /// /* xxxx command class commands */
        /// #define XXXX_VERSION   0xHH
        /// </code>
        /// <example>
        /// For param key of type STRUCT_uint8_t the following is generated:
        /// <code>
        /// /* Values used for xxxx command */
        /// #define YYYY_ZZZZ_MASK 0x3F
        /// #define YYYY_ZZZZ_BIT_MASK 0x80
        /// #define YYYY_ZZZZ_SHIFT 0x05
        /// </code>
        /// For param key of type ENUM the following is generated
        /// <code>
        /// #define YYYY_ZZZZ_WWWW VVVV
        /// </code>
        /// For param key of type CONST the following is generated
        /// <code>
        /// #define YYYY_FLAGNAME FLAGMASK
        /// </code>
        /// where,<br/>
        /// XXXX is the command class name.<br/>
        /// YYYY is the command name.<br/>
        /// ZZZZ is the is the field name  (ParamField.Name).<br/>
        /// _BIT is added if ParamField.fieldName equals "bitflag".<br/>
        /// WWWW is the name of the enum (name attribute).<br/>
        /// VVVV is the hexadecimal value of the key attribute.<br/>
        /// FLAGNAME is the value of the flagname attribute in the const tag.<br/>
        /// FLAGMASK is the value of the flagmask attribute in the const tag.<br/>
        /// </example>        
        private void Generate_Command_Def(bool keepLegacyExceptions)
        {
            //Sw.WriteLine(Generate_DefineLineStr("APP_SMODE", 0x00, "application specific", 1));
            //Sw.WriteLine(Generate_DefineLineStr("TX_SMODE", 0x01, "sending node: support; receiving node: control", 1));
            //Sw.WriteLine(Generate_DefineLineStr("RX_SMODE", 0x02, "sending node: control; receiving node: support", 1));
            //Sw.WriteLine(Generate_DefineLineStr("TX_RX_SMODE", 0x03, "sending node: support; receiving node: support", 1));
            //Sw.WriteLine();
            foreach (CommandClass cmdClass in CommandClassList)
            {
                if (cmdClass.KeyId == 0x59)
                {
                }
                if (cmdClass.KeyId == 0 || cmdClass.KeyId >= 0x20)
                {
                    Sw.WriteLine("/* {0} command class commands */",
                        Tools.CutUpperUnderscoreToMixedUpperLower(cmdClass.Name, Options1.ChCommandClassPrefix, " "));
                    Generate_DefineLine(
                        Tools.CutString(cmdClass.Name, Options1.ChCommandClassPrefix) +
                        Options1.ChCommandClassVersionPostfix, cmdClass.Version, "", cmdClass.Version);
                    Generate_Defines(cmdClass.Command);

                    if (!keepLegacyExceptions)
                    {
                        if (cmdClass.DefineSet != null && cmdClass.DefineSet.Count > 0)
                        {
                            Sw.WriteLine("/* Values used for {0} command class */",
                                Tools.UpperUnderscoreToMixedUpperLower(cmdClass.Name, " "));
                            foreach (DefineSet dSet in cmdClass.DefineSet)
                            {
                                bool isMultiarray = dSet.Define.Aggregate(true, (current, df) => current & df.Define1 != null);
                                if (isMultiarray)
                                {
                                    foreach (var groupItem in dSet.Define)
                                    {
                                        foreach (var item in groupItem.Define1)
                                        {
                                            Sw.WriteLine(Generate_DefineLineStr(
                                                cmdClass.Name + "_" + Tools.MakeLegalUpperCaseIdentifier(dSet.Name) +
                                                "_" + Tools.MakeLegalUpperCaseIdentifier(item.Name), item.KeyId, "",
                                                cmdClass.Version));
                                        }
                                    }
                                }
                                else
                                {
                                    foreach (var item in dSet.Define)
                                    {
                                        Sw.WriteLine(Generate_DefineLineStr(
                                            cmdClass.Name + "_" + Tools.MakeLegalUpperCaseIdentifier(dSet.Name) + "_" +
                                            Tools.MakeLegalUpperCaseIdentifier(item.Name), item.KeyId, "",
                                            cmdClass.Version));
                                    }
                                }
                            }
                        }
                    }

                    if (cmdClass.Command != null)
                        foreach (Command cmd in cmdClass.Command)
                        {
                            //DCP_LIST_SET
                            ArrayList defineLines = new ArrayList();
                            if (cmd.Bits > 0 && cmd.Bits < 8)
                            {
                                defineLines.Add(Generate_DefineLineStr(cmd.Name + "_MASK",
                                    Tools.GetMaskFromBits(cmd.Bits, (byte)(8 - cmd.Bits)), "", cmdClass.Version));
                            }
                            if (cmd.Param != null)
                                foreach (Param param in cmd.Param)
                                {
                                    if (cmd.Bits > 0 && cmd.Bits < 8 && param.Order == 0 && param.Param1 != null &&
                                        param.Param1.Count > 0)
                                    {
                                        defineLines.Add(Generate_DefineLineStr(
                                            cmd.Name + "_" + Tools.MakeLegalUpperCaseIdentifier(param.Param1[0].Text) +
                                            Options1.ChMaskPostfix, Tools.GetMaskFromBits((byte)(8 - cmd.Bits), 0),
                                            param.Comment, cmdClass.Version));
                                    }
                                    else if (param.Type == zwParamType.MARKER)
                                    {
                                        defineLines.Add(Generate_DefineLineStr(
                                            cmd.Name + "_" + Tools.MakeLegalUpperCaseIdentifier(param.Text),
                                            param.DefaultValue, param.Comment, cmdClass.Version));
                                    }
                                    else if (param.Param1 != null)
                                    {
                                        switch (param.Mode)
                                        {
                                            case ParamModes.Property:
                                                byte shifter = 0;
                                                foreach (var prm1 in param.Param1)
                                                {
                                                    string postfix = Options1.ChMaskPostfix;
                                                    if (prm1.Bits == 1)
                                                    {
                                                        postfix = Options1.ChBitPostfix + Options1.ChMaskPostfix;
                                                    }
                                                    defineLines.Add(Generate_DefineLineStr(
                                                        cmd.Name + "_" + Tools.MakeLegalUpperCaseIdentifier(param.Text) +
                                                        "_" + Tools.MakeLegalUpperCaseIdentifier(prm1.Text) + postfix,
                                                        Tools.GetMaskFromBits(prm1.Bits, shifter), param.Comment,
                                                        cmdClass.Version));

                                                    // shift definitions
                                                    if (prm1.Bits > 1 && shifter != 0 && shifter != 8)
                                                    {
                                                        defineLines.Add(Generate_DefineLineStr(
                                                            cmd.Name + "_" +
                                                            Tools.MakeLegalUpperCaseIdentifier(param.Text) + "_" +
                                                            Tools.MakeLegalUpperCaseIdentifier(prm1.Text) +
                                                            Options1.ChShiftPostfix, shifter, "", cmdClass.Version));
                                                    }
                                                    shifter += prm1.Bits;
                                                    if (keepLegacyExceptions)
                                                    {
                                                        if (prm1.Defines != null)
                                                        {
                                                            FillDefines(cmdClass, cmd, defineLines, prm1);
                                                        }
                                                    }
                                                }
                                                break;
                                            case ParamModes.VariantGroup:
                                                foreach (var prm1 in param.Param1)
                                                {
                                                    if (keepLegacyExceptions)
                                                    {
                                                        if (prm1.Defines != null)
                                                        {
                                                            FillDefines(cmdClass, cmd, defineLines, prm1);
                                                        }
                                                    }
                                                }
                                                break;
                                        }
                                    }
                                    if (keepLegacyExceptions)
                                    {
                                        if (param.Defines != null)
                                        {
                                            FillDefines(cmdClass, cmd, defineLines, param);
                                        }
                                    }
                                }

                            if (defineLines.Count > 0)
                            {
                                Sw.WriteLine("/* Values used for {0} command */",
                                    Tools.UpperUnderscoreToMixedUpperLower(cmd.Name, " "));
                                foreach (string s in defineLines)
                                {
                                    Sw.WriteLine(s);
                                }
                            }
                        }
                    Sw.WriteLine("");
                }
            }
        }
示例#31
0
 private static extern bool ShowWindow(IntPtr hWnd, Sw style);