Пример #1
0
        protected bool RunSingleScript(string name, int flag)
        {
            try
            {
                Offset param = null;
                if (flag != -1)
                {
                    param = new Offset(0x0D6C, 4);
                    param.SetValue(flag);
                    FSUIPCConnection.Process();
                }

                Offset request = new Offset(0x0D70, 128);
                request.SetValue(name);

                FSUIPCConnection.Process();
                request.Disconnect();
                request = null;
                if (flag != -1)
                {
                    param.Disconnect();
                    param = null;
                }
            }
            catch
            {
                Log.Logger.Error($"IPCManager: Exception while Executing Script: {name}");
                return(false);
            }

            return(true);
        }
Пример #2
0
 public override void Dispose()
 {
     base.Dispose();
     if (offset != null)
     {
         if (offset.IsConnected)
         {
             offset.Disconnect();
         }
         offset = null;
     }
 }
Пример #3
0
        public bool RunMacro(string name)
        {
            try
            {
                Offset request = new Offset(0x0D70, 128);
                request.SetValue(name);
                FSUIPCConnection.Process();
                request.Disconnect();
                request = null;
            }
            catch
            {
                Log.Logger.Error($"IPCManager: Exception while Executing Macro: {name}");
                return(false);
            }

            return(true);
        }
Пример #4
0
        private bool fsSetInt(int address, int value)
        {
            bool success = true;

            Offset <int> offset = new Offset <int>(address, true);

            offset.Value = value;
            try
            {
                FSUIPCConnection.Process();
            }
            catch (Exception ex)
            {
                fsInitMessage = ex.Message;
                success       = false;
            }
            offset.Disconnect();

            return(success);
        }
Пример #5
0
        private bool fsExecute(string commandlist)
        {
            bool success = true;

            string[]             commands = commandlist.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            List <Offset <int> > offsets  = new List <Offset <int> >();

            //process conditionals
            bool conditional = true;

            foreach (string command in commands)
            {
                if (command.Contains("?"))
                {
                    string[] symbols = command.Trim(new char[] { '?' }).Split(new string[] { "=" }, StringSplitOptions.None);
                    if (symbols.Length == 2)
                    {
                        bool invert = false;
                        bool lt     = false;
                        bool gt     = false;

                        if (symbols[0].Contains('!'))
                        {
                            invert     = true;
                            symbols[0] = symbols[0].Replace("!", "");
                        }

                        if (symbols[0].Contains('<'))
                        {
                            lt         = true;
                            symbols[0] = symbols[0].Replace("<", "");
                        }

                        if (symbols[0].Contains('>'))
                        {
                            gt         = true;
                            symbols[0] = symbols[0].Replace(">", "");
                        }

                        Debug.Print(symbols[0]);
                        Debug.Print(symbols[1]);

                        int address = stringToInt(symbols[0]);
                        int value   = stringToInt(symbols[1]);

                        Offset <Byte> offset = new Offset <Byte>(address);

                        try
                        {
                            FSUIPCConnection.Process();
                        }
                        catch (Exception ex)
                        {
                            fsInitMessage = ex.Message;
                            success       = false;
                            conditional   = false;
                        }

                        if (success)
                        {
                            conditional = (offset.Value == value);

                            if (lt)
                            {
                                conditional = (offset.Value <= value);
                            }

                            if (gt)
                            {
                                conditional = (offset.Value >= value);
                            }

                            if (invert)
                            {
                                conditional = !conditional;
                            }
                        }

                        offset.Disconnect();
                    }
                }
            }

            // process commands
            if (conditional)
            {
                foreach (string command in commands)
                {
                    if (!command.Contains("?"))
                    {
                        string[] symbols = command.Split(new string[] { "=" }, StringSplitOptions.None);
                        if (symbols.Length == 2)
                        {
                            int address = stringToInt(symbols[0]);
                            int value   = stringToInt(symbols[1]);

                            Offset <int> offset = new Offset <int>(address, true);
                            offset.Value = value;
                            offsets.Add(offset);
                        }
                    }
                }
            }
            else
            {
                Debug.Print("skipping previous step because conditional evaluated to false");
            }

            try
            {
                FSUIPCConnection.Process();
            }
            catch (Exception ex)
            {
                fsInitMessage = ex.Message;
                success       = false;
            }

            foreach (Offset <int> offset in offsets)
            {
                offset.Disconnect();
            }

            return(success);
        }
Пример #6
0
 public void Disconnect(bool AfterNextProcess)
 {
     m_wrappedOffset.Disconnect(AfterNextProcess);
 }
Пример #7
0
        public bool FSUIPC_GetBit(int offset, int bit, int bytes, ref bool data)
        {
            if (_FSUIPCConnection == false)
                return false;

            Offset<BitArray> testoffset = new Offset<BitArray>(offset, bytes);
            try
            {
                FSUIPCConnection.Process();
            }
            catch (Exception)
            {
                _FSUIPCConnection = false;
                testoffset.Disconnect();
                FSUIPCConnection.Close();
                return false;
            }
            data = testoffset.Value[bit];
            testoffset.Disconnect();
            return true;
        }
Пример #8
0
        private void tmrCheckFSUIPC_Tick(object sender, EventArgs e)
        {
            if (!_FSUIPCConnection)
            {
                try
                {
                    FSUIPCConnection.Open();
                    _FSUIPCConnection = true;
                }
                catch (Exception)
                {
                    FSUIPCConnection.Close();
                    _FSUIPCConnection = false;
                }
            }

            if (_FSUIPCConnection)
            {
                // Test FSUIPC Connection
                Offset<byte[]> testoffset = new Offset<byte[]>(0x0264, 2);
                try
                {
                    FSUIPCConnection.Process();
                }
                catch (Exception)
                {
                    _FSUIPCConnection = false;
                    FSUIPCConnection.Close();
                }
                testoffset.Disconnect();
            }

            if (_FSUIPCConnection)
                lblFSUIPCConnection.Caption = "FSUIPC Connection: Connected";
            else
                lblFSUIPCConnection.Caption = "FSUIPC Connection: Disconnected";
        }
Пример #9
0
        /// <summary>
        /// Send multiple bytes to FSUIPC
        /// </summary>
        /// <param name="offset">Offset to send data to</param>
        /// <param name="data">Data to send as a Long</param>
        /// <param name="length">Length of the offset</param>
        /// <returns></returns>
        public bool FSUIPC_SendBytes(int offset, long data, int length)
        {
            if (_FSUIPCConnection == false)
                return false;

            Offset<byte[]> testoffset = new Offset<byte[]>(offset, length);
            byte[] offsetvalue = new byte[length];
            byte[] rawvalue = BitConverter.GetBytes(data);
            for (int i = 0; i < length; i++)
            {
                offsetvalue[i] = rawvalue[i];
            }
            testoffset.Value = offsetvalue;
            try
            {
                FSUIPCConnection.Process();
            }
            catch (Exception)
            {
                _FSUIPCConnection = false;
                testoffset.Disconnect();
                FSUIPCConnection.Close();
                return false;
            }
            testoffset.Disconnect();
            return true;
        }
Пример #10
0
        /// <summary>
        /// Send a single byte to FSUIPC
        /// </summary>
        /// <param name="offset">Offset to send data to</param>
        /// <param name="data">Data to send as a Long</param>
        /// <returns></returns>
        public bool FSUIPC_SendByte(int offset, long data)
        {
            if (_FSUIPCConnection == false)
                return false;

            Offset<byte> testoffset = new Offset<byte>(offset);
            byte offsetvalue = Convert.ToByte(data);
            testoffset.Value = offsetvalue;
            try
            {
                FSUIPCConnection.Process();
            }
            catch (Exception)
            {
                _FSUIPCConnection = false;
                testoffset.Disconnect();
                FSUIPCConnection.Close();
                return false;
            }
            testoffset.Disconnect();
            return true;
        }
Пример #11
0
        public bool FSUIPC_SendBit(int offset, int bit, bool value, int length)
        {
            if (_FSUIPCConnection == false)
                return false;

            //int bitnum = Convert.ToInt32(bit);
            //double bittest = bitnum / 8;
            //int length = Convert.ToInt32(Math.Floor(bittest)) + 1;
            Offset<BitArray> testoffset = new Offset<BitArray>(offset, length);
            try
            {
                FSUIPCConnection.Process();
            }
            catch (Exception)
            {
                _FSUIPCConnection = false;
                testoffset.Disconnect();
                FSUIPCConnection.Close();
                return false;
            }
            testoffset.Value[bit] = value;
            try
            {
                FSUIPCConnection.Process();
            }
            catch (Exception)
            {
                _FSUIPCConnection = false;
                testoffset.Disconnect();
                FSUIPCConnection.Close();
                return false;
            }
            testoffset.Disconnect();
            return true;
        }
Пример #12
0
        public bool FSUIPC_GetBytes(int offset, int length, ref long data)
        {
            if (_FSUIPCConnection == false)
                return false;

            Offset<byte[]> testoffset = new Offset<byte[]>(offset, length);
            try
            {
                FSUIPCConnection.Process();
            }
            catch (Exception)
            {
                _FSUIPCConnection = false;
                testoffset.Disconnect();
                FSUIPCConnection.Close();
                return false;
            }
            //data = BitConverter.ToInt64(testoffset.Value, 0);
            data = BitConverter.ToInt32(testoffset.Value, 0);
            testoffset.Disconnect();
            return true;
        }
Пример #13
0
        public bool FSUIPC_GetBytes(int offset, int length, ref int data)
        {
            if (_FSUIPCConnection == false)
                return false;

            Offset<byte[]> testoffset = new Offset<byte[]>(offset, length);
            try
            {
                FSUIPCConnection.Process();
            }
            catch (Exception)
            {
                _FSUIPCConnection = false;
                testoffset.Disconnect();
                FSUIPCConnection.Close();
                return false;
            }
            string test = BitConverter.ToString(testoffset.Value, 0);
            string[] test2 = test.Split('-');
            string test3 = "";
            for (int i = test2.Length - 1; i >= 0; i--)
            {
                test3 = test3 + test2[i];
            }
            data = Convert.ToInt32(test3, 16);
            //data = BitConverter.ToInt32(testoffset.Value, 0);
            testoffset.Disconnect();
            return true;
        }
Пример #14
0
        public bool FSUIPC_GetByte(int offset, ref int data)
        {
            if (_FSUIPCConnection == false)
                return false;

            Offset<byte> testoffset = new Offset<byte>(offset);
            try
            {
                FSUIPCConnection.Process();
            }
            catch (Exception)
            {
                _FSUIPCConnection = false;
                testoffset.Disconnect();
                FSUIPCConnection.Close();
                return false;
            }
            data = testoffset.Value;
            testoffset.Disconnect();
            return true;
        }