Exemple #1
0
 // =========================================================================================================
 public psdxTools(ErrHandle objErr, XmlDocument pdxThis)
 {
     this.errHandle = objErr;
       oXmlTools = new xmlTools(objErr);
       oXmlTools.SetXmlDocument(pdxThis);
       pdxCurrentFile = pdxThis;
 }
Exemple #2
0
        // ------------------------------------------------------------------------------------
        // Name:   DoLike
        // Goal:   Perform the "Like" function using the pattern (or patterns) stored in [strPattern]
        //         There can be more than 1 pattern in [strPattern], which must be separated
        //         by a vertical bar: |
        // History:
        // 17-06-2010  ERK Created
        // ------------------------------------------------------------------------------------
        public static bool DoLike(string strText, string strPattern)
        {
            string[] arPattern = null;
            // Array of patterns
            int intI = 0;

            // Counter

            try {
                // Validate
                if ((strText == null))
                {
                    return(true);
                }
                // If the text to compare is empty, then we return false
                if ((string.IsNullOrEmpty(strText)))
                {
                    return(false);
                }
                // Reduce the [strPattern]
                strPattern = strPattern.Trim().ToLower();
                // Take lower case of the text
                strText = strText.ToLower();
                // SPlit the [strPattern] into different ones
                arPattern = strPattern.Split(new string[] { "|" }, StringSplitOptions.None);
                // Perform the "Like" operation for all needed patterns
                for (intI = 0; intI < arPattern.Length; intI++)
                {
                    // See if something positive comes out of this comparison
                    if (strText.IsLike(arPattern[intI]))
                    {
                        return(true);
                    }
                }
                // No match has happened, so return false
                return(false);
            } catch (Exception ex) {
                // Show error
                ErrHandle.HandleErr("General/DoLike", ex);
                // Return failure
                return(false);
            }
        }
Exemple #3
0
 private XmlReaderSettings setThis = null; // Settings to read the document
 // ==================================== CLASS INITIALIZER =============================
 public ParReader(String sFileIn, ErrHandle oErr)
 {
     // Set error handler
     this.errHandle = oErr;
     // Set local file name
     this.loc_sFileIn = sFileIn;
     // Create correct reader settings
     setThis = new XmlReaderSettings();
     setThis.DtdProcessing  = DtdProcessing.Ignore;
     setThis.IgnoreComments = true;
     // Validate
     if (!File.Exists(sFileIn))
     {
         return;
     }
     // Try opening the file
     rdFileIn  = new StreamReader(sFileIn);
     rdFileXml = XmlReader.Create(rdFileIn, setThis);
     // Create an xml document
     pdxThis = new XmlDocument();
     // Set init flag
     bInit = true;
 }
Exemple #4
0
        /// <summary>
        /// File-to-file buffered decompression
        /// </summary>
        /// <param name="sFileIn"></param>
        /// <param name="sFileOut"></param>
        /// <returns></returns>
        public static bool DecompressFile(String sFileIn, String sFileOut)
        {
            const int size = 8192;

            byte[] buffer = new byte[size];

            try {
                using (FileStream fCompr = new FileStream(sFileIn, FileMode.Open, FileAccess.Read))
                    using (FileStream fDecom = new FileStream(sFileOut, FileMode.Create, FileAccess.Write))
                        using (GZipStream alg = new GZipStream(fCompr, CompressionMode.Decompress)) {
                            int bytesRead = 0;
                            do
                            {
                                // Read buffer
                                bytesRead = alg.Read(buffer, 0, buffer.Length);
                                // Write buffer away
                                if (bytesRead > 0)
                                {
                                    fDecom.Write(buffer, 0, bytesRead);
                                }
                            } while (bytesRead > 0);
                            // finish writing
                            fDecom.Flush();
                            fDecom.Close(); fDecom.Dispose();
                            // Finish reading
                            alg.Close();
                            fCompr.Close(); fCompr.Dispose();
                        }
                // Return success
                return(true);
            } catch (Exception ex) {
                ErrHandle.HandleErr("DecompressFile", ex);
                // Return failure
                return(false);
            }
        }
Exemple #5
0
 // ============ Class initializer calls the base class =====================
 public OpsToFolia(ErrHandle objErr)
 {
     this.errHandle = objErr;
       this.oXmlTools = new util.xmlTools(objErr);
       this.oPsdxTools = new util.psdxTools(objErr, null);
 }
 private static extern int sequencer_write(int ID_ref, Double[] ID_speeds, Double[] ID_accels, Double[] ID_jerks, UInt32[] ID_delays, UInt16 ID_set_length, ref ErrHandle ID_err);
 private static extern int sequencer_init(int ID_ref, Double ID_max_accel, Double ID_max_jerk, ref ErrHandle ID_err);
 private static extern int sequencer_softtrigger(int ID_ref, ref ErrHandle ID_err);
Exemple #9
0
 // =========================================================================================================
 public xmlTools(ErrHandle objErr)
 {
     this.errHandle = objErr;
 }
 private static extern int get_opstate(int ID_ref, ref Byte state, ref ErrHandle ID_err);
 private static extern int close(int ID_ref, ref ErrHandle ID_err);
 private static extern int clear_error(int ID_ref, ref ErrHandle ID_err);
 private static extern int open(int ID_ref, Byte[] ID_comport, UInt32 ID_combaudrate, ref ErrHandle ID_err);
 private static extern int get_diagnostic_num(int ID_ref, ref UInt32 ID_diagnostic_num, ref ErrHandle ID_err);
 private static extern int get_diagnostic_msg(int ID_ref, Byte[] ID_diagnostic_msg, ref ErrHandle ID_err);
 private static extern int get_speed(int ID_ref, ref Double speed, ref ErrHandle ID_err);
Exemple #17
0
 // ============ Class initializer calls the base class =====================
 public OpsToFolia(ErrHandle objErr)
 {
     this.errHandle  = objErr;
     this.oXmlTools  = new util.xmlTools(objErr);
     this.oPsdxTools = new util.psdxTools(objErr, null);
 }
Exemple #18
0
 /*
  * private String[] arField = { "title", "year", "rated", "released", "runtime", "genre", "director",
  * "writer", "actors", "plot", "language", "country", "awards", "imdbRating", "imdbVotes", "type"};
  */
 // ================= CLASS INITIALIZER ============================================
 public omdbapi(ErrHandle oErr)
 {
     this.errHandle = oErr;
 }
 private static extern int speedcontrol_activate(int ID_ref, ref ErrHandle ID_err);
 private static extern int get_drivemode(int ID_ref, ref UInt32 mode, ref ErrHandle ID_err);
Exemple #21
0
        /// <summary>
        /// Convert a string consisting of base64 encoded characters to a number
        /// </summary>
        /// <param name="sEncoded"></param>
        /// <returns></returns>
        public static int base64ToInt(String sEncoded)
        {
            int iBack = 0;

            try {
                // COnvert string into byte array
                char[] arEncoded = sEncoded.ToCharArray();
                // Treat the characters one-by-one from right-to-left
                for (int i = 0; i < arEncoded.Length; i++)
                {
                    // Conversion depends on the character values
                    char chThis = arEncoded[i];
                    int  iThis  = 0;
                    switch (chThis)
                    {
                    case 'A': iThis = 0; break;

                    case 'B': iThis = 1; break;

                    case 'C': iThis = 2; break;

                    case 'D': iThis = 3; break;

                    case 'E': iThis = 4; break;

                    case 'F': iThis = 5; break;

                    case 'G': iThis = 6; break;

                    case 'H': iThis = 7; break;

                    case 'I': iThis = 8; break;

                    case 'J': iThis = 9; break;

                    case 'K': iThis = 10; break;

                    case 'L': iThis = 11; break;

                    case 'M': iThis = 12; break;

                    case 'N': iThis = 13; break;

                    case 'O': iThis = 14; break;

                    case 'P': iThis = 15; break;

                    case 'Q': iThis = 16; break;

                    case 'R': iThis = 17; break;

                    case 'S': iThis = 18; break;

                    case 'T': iThis = 19; break;

                    case 'U': iThis = 20; break;

                    case 'V': iThis = 21; break;

                    case 'W': iThis = 22; break;

                    case 'X': iThis = 23; break;

                    case 'Y': iThis = 24; break;

                    case 'Z': iThis = 25; break;

                    case 'a': iThis = 26; break;

                    case 'b': iThis = 27; break;

                    case 'c': iThis = 28; break;

                    case 'd': iThis = 29; break;

                    case 'e': iThis = 30; break;

                    case 'f': iThis = 31; break;

                    case 'g': iThis = 32; break;

                    case 'h': iThis = 33; break;

                    case 'i': iThis = 34; break;

                    case 'j': iThis = 35; break;

                    case 'k': iThis = 36; break;

                    case 'l': iThis = 37; break;

                    case 'm': iThis = 38; break;

                    case 'n': iThis = 39; break;

                    case 'o': iThis = 40; break;

                    case 'p': iThis = 41; break;

                    case 'q': iThis = 42; break;

                    case 'r': iThis = 43; break;

                    case 's': iThis = 44; break;

                    case 't': iThis = 45; break;

                    case 'u': iThis = 46; break;

                    case 'v': iThis = 47; break;

                    case 'w': iThis = 48; break;

                    case 'x': iThis = 49; break;

                    case 'y': iThis = 50; break;

                    case 'z': iThis = 51; break;

                    case '0': iThis = 52; break;

                    case '1': iThis = 53; break;

                    case '2': iThis = 54; break;

                    case '3': iThis = 55; break;

                    case '4': iThis = 56; break;

                    case '5': iThis = 57; break;

                    case '6': iThis = 58; break;

                    case '7': iThis = 59; break;

                    case '8': iThis = 60; break;

                    case '9': iThis = 61; break;

                    case '+': iThis = 62; break;

                    case '/': iThis = 63; break;
                    }
                    // Add the new value to the existing ones
                    iBack = iBack * 64 + iThis;
                }
                return(iBack);
            } catch (Exception ex) {
                ErrHandle.HandleErr("base64ToInt", ex);
                // Return failure
                return(-1);
            }
        }
 private static extern int speedcontrol_init(int ID_ref, Double ID_max_accel, Double ID_max_jerk, ref ErrHandle ID_err);
 private static extern int speedcontrol_write(int ID_ref, Double ID_speed, Double ID_accel, ref ErrHandle ID_err);
 private static extern int sequencer_activate(int ID_ref, ref ErrHandle ID_err);
Exemple #25
0
 // =========================================================================================================
 public xmlTools(ErrHandle objErr)
 {
     this.errHandle = objErr;
 }
Exemple #26
0
 // ================= Class initializer =======================================================
 public XmlConv(ErrHandle oErr)
 {
     this.errHandle = oErr;
 }