Example #1
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="localPort">自分のポート</param>
        public RemoteHost(int localPort, DebugWindow debugwindow, TerminalConnection.TerminalConnection TC)
        {
            try
            {
                this.UP_Cliant  = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(localPort);
                this.UP_Encoder = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                this.UP_Decoder = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER();
                this.id         = localPort;

                this.CTS    = new CancellationTokenSource();
                this.mytask = new Task(() => this.Main_Task(), CTS.Token);

                this.mytask.Start();
                this.fpsa = new FPSAdjuster.FPSAdjuster();

                this.debugwindow          = debugwindow;
                this.debugwindow.DebugLog = "[Port:" + localPort.ToString() + "]受信を開始します";

                this.TC = TC;
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Example #2
0
        private void Button_ConnectionSettingSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (this.DCS.DataConnectionCount > 0)
                {
                    Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                    dlg.FileName        = "connectionsetting.dcs";              // Default file name
                    dlg.DefaultExt      = ".dcs";                               // Default file extension
                    dlg.Filter          = "DataConnectionSetting (.dcs)|*.dcs"; // Filter files by extension
                    dlg.CheckFileExists = false;
                    dlg.CheckPathExists = false;

                    // Show open file dialog box
                    Nullable <bool> result = dlg.ShowDialog();

                    string file;
                    // Process open file dialog box results
                    if (result == true)
                    {
                        // Open document
                        file = dlg.FileName;
                    }
                    else
                    {
                        throw new Exception("保存を中止しました.");
                    }
                    FileStream   fs = new FileStream(file, FileMode.Create);
                    StreamWriter sw = new StreamWriter(fs);
                    sw.WriteLine(this.DCS.DataConnectionCount);
                    for (int i = 0; i < this.DCS.DataConnectionCount; i++)
                    {
                        DATA_CONNECTION.MyDataConnection MDC = this.DCS.get_SelectedDataConnection(i);
                        sw.WriteLine(MDC.SENDER.remotePort + "," + MDC.RECEIVER.remotePort);
                    }
                    sw.Close();
                    fs.Close();
                    debugwindow.DebugLog = "[DataConnectionSever]設定を保存しました.ファイル名:" + file;
                    while (true)
                    {
                        myDialog dialog = new myDialog("ファイルに設定情報を書き込みました.");
                        if (dialog.ShowDialog() == true)
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Example #3
0
        private void Button_ConnectionSettingLoad_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.FileName        = "connectionsetting.dcs";              // Default file name
                dlg.DefaultExt      = ".dcs";                               // Default file extension
                dlg.Filter          = "DataConnectionSetting (.dcs)|*.dcs"; // Filter files by extension
                dlg.CheckFileExists = false;
                dlg.CheckPathExists = false;

                // Show open file dialog box
                Nullable <bool> result = dlg.ShowDialog();

                string file;
                // Process open file dialog box results
                if (result == true)
                {
                    // Open document
                    file = dlg.FileName;
                }
                else
                {
                    throw new Exception("読込を中止しました.");
                }

                this.DCS.delete_all_connection();
                this.DCS.ListBox_update(this.LISTBOX_DATA_CONNECTION);

                FileStream   fs = new FileStream(file, FileMode.Open);
                StreamReader sr = new StreamReader(fs);

                int size = int.Parse(sr.ReadLine());

                for (int i = 0; i < size; i++)
                {
                    string line  = sr.ReadLine();
                    var    parts = line.Split(',');
                    this.checkid_sender   = int.Parse(parts[0]);
                    this.checkid_receiver = int.Parse(parts[1]);
                    this.DCS.add_connection(this.rhServer.List_RemoteHost.Find(HostFindFromFile_sender), this.rhServer.List_RemoteHost.Find(HostFindFromFile_receiver), this.CheckBox_IsSyncReceived.IsChecked == true ? true : false);
                    this.DCS.ListBox_update(this.LISTBOX_DATA_CONNECTION);
                }
                sr.Close();
                fs.Close();
                debugwindow.DebugLog = "[DataConnectionSever]設定を読み込みました.ファイル名:" + file;
                this.ConnectionChangeNoticetoTerminal();
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Example #4
0
        public RemoteHostServer()
        {
            try
            {
                client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(myPort);
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }

            try
            {
                this.enc     = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                this.dec     = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER();
                this.LstPort = new List <int>();

                mytask = new Task(() => this.MAIN_TASK());
                mytask.Start();
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
            try
            {
                #region create remotehost servers list and one remotehost server
                this.List_remotehost = new List <RemoteHost>();
                #endregion
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Example #5
0
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     try
     {
         AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
     }
     catch (Exception ex)
     {
         myDialog dialog = new myDialog(ex.Message);
     }
 }
Example #6
0
        private void dispatchertimer_Tick(object sender, EventArgs e)
        {
            try
            {
                #region test

                //List<TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client> clientlist = new List<TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client>();
                //List<TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Connection> connectionlist = new List<TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Connection>();
                //clientlist.Add(new TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client(1000, "ohohoh", 2000, "192.168.11.1", 60));
                //clientlist.Add(new TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client(1000, "ohohoh", 2000, "192.168.11.1", 60));
                //connectionlist.Add(new TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Connection(200, 1000));
                //TerminalConnectionSettings.ServerProtocols.ReportInfo reportinfo = new TerminalConnectionSettings.ServerProtocols.ReportInfo(new TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo(clientlist, connectionlist));
                //TerminalConnectionSettings.CommandEventer messagereader = new TerminalConnectionSettings.CommandEventer();

                //messagereader.ReportInfo += messagereader_ReportInfo;
                //messagereader.Handle(reportinfo.Data);

                //System.Text.Encoding enc = System.Text.Encoding.UTF8;
                //byte[] sendBytes = enc.GetBytes(reportinfo.Data);
                //string str = enc.GetString(sendBytes);

                #endregion

                text1.Text =
                    "工程名    : " + System.Diagnostics.Process.GetCurrentProcess().ProcessName + "\n"
                    + "現在時刻   : " + DateTime.Now.ToLongTimeString() + "\n"
                    + "使用ポート数 : " + rhServer.host_num + "\n"
                    + "制御用ポート : " + Definitions.REMOTEHOSTSERVER_PORT + " ■■ ターミナル用ポート : " + Definitions.TERMINALCONNECTION_PORT;
                char[]   sepalater = { '\n' };
                string[] strs      = this.debugwindow.DebugLog.Split(sepalater, StringSplitOptions.RemoveEmptyEntries);
                this.TextBlock_Status.Text = strs[strs.Length - 1];

                if (rhServer.Num_Port != this.old_Num_Port)
                {
                    rhServer.Listupdate(LISTVIEW1);
                }
                this.old_Num_Port = rhServer.Num_Port;
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Example #7
0
 private void Cut_Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (int.Parse(this.sender_port.Text) != 0 && int.Parse(this.receiver_port.Text) != 0)
         {
             try
             {
                 this.DCS.delete_connection(this.rhServer.List_RemoteHost.Find(HostFindFromPort_sender), this.rhServer.List_RemoteHost.Find(HostFindFromPort_receiver));
                 this.DCS.ListBox_update(this.LISTBOX_DATA_CONNECTION);
                 this.ConnectionChangeNoticetoTerminal();
             }
             catch (Exception ex)
             {
                 while (true)
                 {
                     myDialog dialog = new myDialog(ex.Message);
                     if (dialog.ShowDialog() == true)
                     {
                         break;
                     }
                 }
             }
         }
         else
         {
             while (true)
             {
                 myDialog dialog = new myDialog("ポートの指定が不適切です");
                 if (dialog.ShowDialog() == true)
                 {
                     break;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         while (true)
         {
             myDialog dialog = new myDialog(ex.Message);
             if (dialog.ShowDialog() == true)
             {
                 break;
             }
         }
     }
 }
Example #8
0
 private void close_button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Close();
     }catch (Exception ex)
     {
         while (true)
         {
             myDialog dialog = new myDialog(ex.Message);
             if (dialog.ShowDialog() == true)
             {
                 break;
             }
         }
     }
 }
Example #9
0
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     try
     {
         AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
     }
     catch (Exception ex)
     {
         while (true)
         {
             myDialog dialog = new myDialog(ex.Message);
             if (dialog.ShowDialog() == true)
             {
                 break;
             }
         }
     }
 }
Example #10
0
 private void Button_Lunch_StreamAnalyzer_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         System.Diagnostics.Process.Start(@"..\..\..\StreamAnalyzer\bin\Debug\StreamAnalyzer.exe");
     }
     catch (Exception ex)
     {
         while (true)
         {
             myDialog dialog = new myDialog(ex.Message);
             if (dialog.ShowDialog() == true)
             {
                 break;
             }
         }
     }
 }
Example #11
0
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     try
     {
         AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
     }
     catch (Exception ex)
     {
         while (true)
         {
             myDialog dialog = new myDialog(ex.Message);
             if (dialog.ShowDialog() == true)
             {
                 break;
             }
         }
     }
 }
Example #12
0
 void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     try
     {
         this.debugwindow.Close();
         this.minimizedwindow.Close();
     }
     catch (Exception ex)
     {
         while (true)
         {
             myDialog dialog = new myDialog(ex.Message);
             if (dialog.ShowDialog() == true)
             {
                 break;
             }
         }
     }
 }
Example #13
0
 private void LISTBOX_DATA_CONNECTION_selectionchanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         if (this.DCS.DataConnectionCount > 0 && LISTBOX_DATA_CONNECTION.SelectedIndex >= 0)
         {
             DATA_CONNECTION.MyDataConnection MDC = this.DCS.get_SelectedDataConnection(this.LISTBOX_DATA_CONNECTION.SelectedIndex);
             this.sender_port.Text   = MDC.SENDER.ID.ToString();
             this.receiver_port.Text = MDC.RECEIVER.ID.ToString();
         }
     }
     catch (Exception ex)
     {
         while (true)
         {
             myDialog dialog = new myDialog(ex.Message);
             if (dialog.ShowDialog() == true)
             {
                 break;
             }
         }
     }
 }
Example #14
0
        public MainWindow()
        {
            try
            {
                int minWorkerThread, minCompletionPortThread;
                ThreadPool.GetMinThreads(out minWorkerThread, out minCompletionPortThread);
                ThreadPool.SetMinThreads(1000, minCompletionPortThread);



                #region window initialize
                this.Title = "CentralInterProcessCommunicationServer";
                this.MouseLeftButtonDown += (sender, e) => this.DragMove();

                this.Closing += MainWindow_Closing;
                #endregion

                #region DispatcherTimer

                dispatchertimer          = new DispatcherTimer(DispatcherPriority.Normal);
                dispatchertimer.Interval = new TimeSpan(0, 0, 1);
                dispatchertimer.Tick    += dispatchertimer_Tick;
                dispatchertimer.Start();

                #endregion DispatcherTimer

                try
                {
                    #region Minimizedwindow and debugwindow
                    this.debugwindow                = new DebugWindow();
                    this.minimizedwindow            = new MinimizedWindow();
                    this.minimizedwindow.mainwindow = this;
                    #endregion
                    #region RemoteHostServer
                    this.rhServer             = new RemoteHostServer();
                    this.rhServer.debugwindow = this.debugwindow;
                    #endregion
                    #region DataConnectionServer
                    this.DCS             = new DATA_CONNECTION.DataConnectionServer();
                    this.DCS.debugwindow = this.debugwindow;
                    #endregion
                    #region TerminalConnection
                    this.TC             = new TerminalConnection.TerminalConnection();
                    this.TC.debugwindow = this.debugwindow;
                    this.TC.RHS         = this.rhServer;
                    this.TC.DCS         = this.DCS;
                    this.TC.mainwindow  = this;
                    this.AddTCFunction();

                    this.rhServer.terminalconnection = this.TC;
                    #endregion
                    #region ProcessList
                    this.List_Processes = new List <System.Diagnostics.Process>();
                    #endregion

                    InitializeComponent();
                    debugwindow.DebugLog = "[CIPCServer]CIPCServerを開始します.";
                }
                catch (Exception ex)
                {
                    while (true)
                    {
                        myDialog dialog = new myDialog(ex.Message);
                        if (dialog.ShowDialog() == true)
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Example #15
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="localPort">自分のポート</param>
        public RemoteHost(int localPort, DebugWindow debugwindow/*, TerminalConnection.TerminalConnection TC*/)
        {
            try
            {
                this.UP_Cliant = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(localPort);
                this.UP_Encoder = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                this.UP_Decoder = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER();
                this.id = localPort;

                this.CTS = new CancellationTokenSource();
                this.mytask = new Task(() => this.Main_Task(), CTS.Token);

                this.mytask.Start();
                this.fpsa = new FPSAdjuster.FPSAdjuster();

                this.debugwindow = debugwindow;
                this.debugwindow.DebugLog = "[Port:" + localPort.ToString() + "]受信を開始します";

                //this.TC = TC;
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Example #16
0
 private void Button_Lunch_StreamController_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         System.Diagnostics.Process.Start(@"..\..\..\StreamController\bin\Debug\StreamController.exe");
     }
     catch (Exception ex)
     {
         while (true)
         {
             myDialog dialog = new myDialog(ex.Message);
             if (dialog.ShowDialog() == true)
             {
                 break;
             }
         }
     }
 }
Example #17
0
        private void Button_ConnectionSettingSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (this.DCS.DataConnectionCount > 0)
                {
                    Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                    dlg.FileName = "connectionsetting.dcs"; // Default file name
                    dlg.DefaultExt = ".dcs"; // Default file extension
                    dlg.Filter = "DataConnectionSetting (.dcs)|*.dcs"; // Filter files by extension
                    dlg.CheckFileExists = false;
                    dlg.CheckPathExists = false;

                    // Show open file dialog box
                    Nullable<bool> result = dlg.ShowDialog();

                    string file;
                    // Process open file dialog box results
                    if (result == true)
                    {
                        // Open document
                        file = dlg.FileName;
                    }
                    else
                    {
                        throw new Exception("保存を中止しました.");
                    }
                    FileStream fs = new FileStream(file, FileMode.Create);
                    StreamWriter sw = new StreamWriter(fs);
                    sw.WriteLine(this.DCS.DataConnectionCount);
                    for (int i = 0; i < this.DCS.DataConnectionCount; i++)
                    {
                        DATA_CONNECTION.MyDataConnection MDC = this.DCS.get_SelectedDataConnection(i);
                        sw.WriteLine(MDC.SENDER.remotePort + "," + MDC.RECEIVER.remotePort);
                    }
                    sw.Close();
                    fs.Close();
                    debugwindow.DebugLog = "[DataConnectionSever]設定を保存しました.ファイル名:" + file;
                    while (true)
                    {
                        myDialog dialog = new myDialog("ファイルに設定情報を書き込みました.");
                        if (dialog.ShowDialog() == true)
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Example #18
0
 private void close_button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Close();
     }catch(Exception ex)
     {
         while (true)
         {
             myDialog dialog = new myDialog(ex.Message);
             if (dialog.ShowDialog() == true)
             {
                 break;
             }
         }
     }
 }
Example #19
0
        private void Cut_Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (int.Parse(this.sender_port.Text) != 0 && int.Parse(this.receiver_port.Text) != 0)
                {
                    try
                    {
                        this.DCS.delete_connection(this.rhServer.List_RemoteHost.Find(HostFindFromPort_sender), this.rhServer.List_RemoteHost.Find(HostFindFromPort_receiver));
                        this.DCS.ListBox_update(this.LISTBOX_DATA_CONNECTION);
                        this.ConnectionChangeNoticetoTerminal();
                    }
                    catch (Exception ex)
                    {
                        while (true)
                        {
                            myDialog dialog = new myDialog(ex.Message);
                            if (dialog.ShowDialog() == true)
                            {
                                break;
                            }
                        }
                    }
                }
                else
                {
                    while (true)
                    {
                        myDialog dialog = new myDialog("ポートの指定が不適切です");
                        if (dialog.ShowDialog() == true)
                        {
                            break;
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Example #20
0
        public RemoteHostServer()
        {
            try
            {
                this.Eventer = new TerminalConnectionSettings.CommandEventer();
                client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(myPort);
                this.remoteOperator = new RemoteOperater(client);
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }

            try
            {
                this.enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                this.dec = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER();
                this.LstPort = new List<int>();

            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
            try
            {
                #region create remotehost servers list and one remotehost server
                this.List_remotehost = new List<RemoteHost>();
                #endregion
                client.DataReceived += client_DataReceived;
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Example #21
0
        private void Button_ConnectionSettingLoad_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.FileName = "connectionsetting.dcs"; // Default file name
                dlg.DefaultExt = ".dcs"; // Default file extension
                dlg.Filter = "DataConnectionSetting (.dcs)|*.dcs"; // Filter files by extension
                dlg.CheckFileExists = false;
                dlg.CheckPathExists = false;

                // Show open file dialog box
                Nullable<bool> result = dlg.ShowDialog();

                string file;
                // Process open file dialog box results
                if (result == true)
                {
                    // Open document
                    file = dlg.FileName;
                }
                else
                {
                    throw new Exception("読込を中止しました.");
                }

                this.DCS.delete_all_connection();
                this.DCS.ListBox_update(this.LISTBOX_DATA_CONNECTION);

                FileStream fs = new FileStream(file, FileMode.Open);
                StreamReader sr = new StreamReader(fs);

                int size = int.Parse(sr.ReadLine());

                for (int i = 0; i < size; i++)
                {
                    string line = sr.ReadLine();
                    var parts = line.Split(',');
                    this.checkid_sender = int.Parse(parts[0]);
                    this.checkid_receiver = int.Parse(parts[1]);
                    this.DCS.add_connection(this.rhServer.List_RemoteHost.Find(HostFindFromFile_sender), this.rhServer.List_RemoteHost.Find(HostFindFromFile_receiver), this.CheckBox_IsSyncReceived.IsChecked == true ? true : false);
                    this.DCS.ListBox_update(this.LISTBOX_DATA_CONNECTION);
                }
                sr.Close();
                fs.Close();
                debugwindow.DebugLog = "[DataConnectionSever]設定を読み込みました.ファイル名:" + file;
                this.ConnectionChangeNoticetoTerminal();
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Example #22
0
        public MainWindow()
        {
            try
            {
                int minWorkerThread, minCompletionPortThread;
                ThreadPool.GetMinThreads(out minWorkerThread, out minCompletionPortThread);
                ThreadPool.SetMinThreads(1000, minCompletionPortThread);

                #region window initialize
                this.Title = "CentralInterProcessCommunicationServer";
                this.MouseLeftButtonDown += (sender, e) => this.DragMove();

                this.Closing += MainWindow_Closing;
                #endregion

                #region DispatcherTimer

                dispatchertimer = new DispatcherTimer(DispatcherPriority.Normal);
                dispatchertimer.Interval = new TimeSpan(0, 0, 1);
                dispatchertimer.Tick += dispatchertimer_Tick;
                dispatchertimer.Start();

                #endregion DispatcherTimer

                try
                {
                    #region Minimizedwindow and debugwindow
                    this.debugwindow = new DebugWindow();
                    this.minimizedwindow = new MinimizedWindow();
                    this.minimizedwindow.mainwindow = this;
                    #endregion
                    #region RemoteHostServer
                    this.rhServer = new RemoteHostServer();
                    this.rhServer.debugwindow = this.debugwindow;
                    #endregion
                    #region DataConnectionServer
                    this.DCS = new DATA_CONNECTION.DataConnectionServer();
                    this.DCS.debugwindow = this.debugwindow;
                    #endregion
                    #region TerminalConnection
                    //this.TC = new TerminalConnection.TerminalConnection();
                    //this.TC.debugwindow = this.debugwindow;
                    //this.TC.RHS = this.rhServer;
                    //this.TC.DCS = this.DCS;
                    //this.TC.mainwindow = this;
                    //this.AddTCFunction();
                    this.AddRemoteOperateFunction();

                    //this.rhServer.terminalconnection = this.TC;
                    #endregion
                    #region ProcessList
                    this.List_Processes = new List<System.Diagnostics.Process>();
                    #endregion
                    this.rhServer.parent = this;
                    InitializeComponent();
                    debugwindow.DebugLog = "[CIPCServer]CIPCServerを開始します.";
                }
                catch (Exception ex)
                {
                    while (true)
                    {
                        myDialog dialog = new myDialog(ex.Message);
                        if (dialog.ShowDialog() == true)
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Example #23
0
        private void dispatchertimer_Tick(object sender, EventArgs e)
        {
            try
            {
                #region test

                //List<TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client> clientlist = new List<TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client>();
                //List<TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Connection> connectionlist = new List<TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Connection>();
                //clientlist.Add(new TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client(1000, "ohohoh", 2000, "192.168.11.1", 60));
                //clientlist.Add(new TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client(1000, "ohohoh", 2000, "192.168.11.1", 60));
                //connectionlist.Add(new TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Connection(200, 1000));
                //TerminalConnectionSettings.ServerProtocols.ReportInfo reportinfo = new TerminalConnectionSettings.ServerProtocols.ReportInfo(new TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo(clientlist, connectionlist));
                //TerminalConnectionSettings.CommandEventer messagereader = new TerminalConnectionSettings.CommandEventer();

                //messagereader.ReportInfo += messagereader_ReportInfo;
                //messagereader.Handle(reportinfo.Data);

                //System.Text.Encoding enc = System.Text.Encoding.UTF8;
                //byte[] sendBytes = enc.GetBytes(reportinfo.Data);
                //string str = enc.GetString(sendBytes);

                #endregion

                text1.Text =
                     "工程名    : " + System.Diagnostics.Process.GetCurrentProcess().ProcessName + "\n"
                    + "現在時刻   : " + DateTime.Now.ToLongTimeString() + "\n"
                    + "使用ポート数 : " + rhServer.host_num + "\n"
                    + "制御用ポート : " + Definitions.REMOTEHOSTSERVER_PORT + " ■■ ターミナル用ポート : " + Definitions.TERMINALCONNECTION_PORT;
                char[] sepalater = { '\n' };
                string[] strs = this.debugwindow.DebugLog.Split(sepalater,StringSplitOptions.RemoveEmptyEntries);
                this.TextBlock_Status.Text = strs[strs.Length - 1];

                if (rhServer.Num_Port != this.old_Num_Port)
                {
                    rhServer.Listupdate(LISTVIEW1);
                }
                this.old_Num_Port = rhServer.Num_Port;
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Example #24
0
        /// <summary>
        /// メインタスク。Whileの中にループを、その前に接続確認などの初期化処理を書く。
        /// 送信モードの場合、リモートホストを設定した場合、そこにデータを渡す。
        /// 受信モードの場合、データの中身があればそこにデータを送信する。
        /// </summary>
        private void Main_Task()
        {
            try
            {
                this.Connect();
                this.debugwindow.DebugLog = "[Port:" + this.ID.ToString() + "]接続に成功しました.";
                this.debugwindow.DebugLog = "[Port:" + this.ID.ToString() + "]RemoteIP:" + this.remoteIP;
                this.debugwindow.DebugLog = "[Port:" + this.ID.ToString() + "]RemotePort:" + this.remotePort.ToString();
                this.debugwindow.DebugLog = "[Port:" + this.ID.ToString() + "]Name:" + this.Name;
                this.debugwindow.DebugLog = "[Port:" + this.ID.ToString() + "]FPS:" + this.FPS;

                try
                {
                    this.TC.Tcp_Send();
                }
                catch (Exception ex)
                {
                    debugwindow.DebugLog = "[" + this.ToString() + "]" + ex.Message;
                }
                while (!CTS.IsCancellationRequested)
                {
                    try
                    {
                        if (this.cstate == ConnectionState.Receiver)
                        {
                            if (this.IsSyncSend == false)
                            {
                                if (this.connect_host != null)
                                {
                                    try
                                    {
                                        this.data = this.connect_host.data;
                                    }
                                    catch (Exception ex)
                                    {
                                        MessageBox.Show(ex.Message);
                                    }
                                }
                                if (this.connect_host != null)
                                {
                                    this.Send();
                                }
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    finally
                    {
                        this.FPSAdjuster();
                    }
                }
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
                Thread.Sleep(100);
                this.CTS    = new CancellationTokenSource();
                this.mytask = new Task(() => this.Main_Task(), CTS.Token);

                this.mytask.Start();
            }
        }
Example #25
0
        /// <summary>
        /// メインタスク。Whileの中にループを、その前に接続確認などの初期化処理を書く。
        /// 送信モードの場合、リモートホストを設定した場合、そこにデータを渡す。
        /// 受信モードの場合、データの中身があればそこにデータを送信する。
        /// </summary>
        private void Main_Task()
        {
            try
            {
                this.Connect();
                this.debugwindow.DebugLog = "[Port:" + this.ID.ToString() + "]接続に成功しました.";
                this.debugwindow.DebugLog = "[Port:" + this.ID.ToString() + "]RemoteIP:" + this.remoteIP;
                this.debugwindow.DebugLog = "[Port:" + this.ID.ToString() + "]RemotePort:" + this.remotePort.ToString();
                this.debugwindow.DebugLog = "[Port:" + this.ID.ToString() + "]Name:" + this.Name;
                this.debugwindow.DebugLog = "[Port:" + this.ID.ToString() + "]FPS:" + this.FPS;

                try
                {
                    //this.TC.Tcp_Send();
                }
                catch (Exception ex)
                {
                    debugwindow.DebugLog = "[" + this.ToString() + "]" + ex.Message;
                }
                while (!CTS.IsCancellationRequested)
                {
                    try
                    {
                        if (this.cstate == ConnectionState.Receiver)
                        {
                            if (this.IsSyncSend == false)
                            {
                                if (this.connect_host != null)
                                {
                                    try
                                    {
                                        this.data = this.connect_host.data;
                                    }
                                    catch (Exception ex)
                                    {
                                        MessageBox.Show(ex.Message);
                                    }
                                }
                                if (this.connect_host != null)
                                {
                                    this.Send();
                                }
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    finally
                    {
                        this.FPSAdjuster();
                    }
                }
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
                Thread.Sleep(100);
                this.CTS = new CancellationTokenSource();
                this.mytask = new Task(() => this.Main_Task(), CTS.Token);

                this.mytask.Start();

            }
        }
Example #26
0
 private void LISTBOX_DATA_CONNECTION_selectionchanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         if (this.DCS.DataConnectionCount > 0 && LISTBOX_DATA_CONNECTION.SelectedIndex >= 0)
         {
             DATA_CONNECTION.MyDataConnection MDC = this.DCS.get_SelectedDataConnection(this.LISTBOX_DATA_CONNECTION.SelectedIndex);
             this.sender_port.Text = MDC.SENDER.ID.ToString();
             this.receiver_port.Text = MDC.RECEIVER.ID.ToString();
         }
     }
     catch (Exception ex)
     {
         while (true)
         {
             myDialog dialog = new myDialog(ex.Message);
             if (dialog.ShowDialog() == true)
             {
                 break;
             }
         }
     }
 }
        public RemoteHostServer()
        {
            try
            {
                client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(myPort);
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }

            try
            {
                this.enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER();
                this.dec = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER();
                this.LstPort = new List<int>();

                mytask = new Task(() => this.MAIN_TASK());
                mytask.Start();
            }
            catch (Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
            try
            {
                #region create remotehost servers list and one remotehost server
                this.List_remotehost = new List<RemoteHost>();
                #endregion
            }
            catch(Exception ex)
            {
                while (true)
                {
                    myDialog dialog = new myDialog(ex.Message);
                    if (dialog.ShowDialog() == true)
                    {
                        break;
                    }
                }
            }
        }
Example #28
0
 void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     try
     {
         this.debugwindow.Close();
         this.minimizedwindow.Close();
         this.rhServer.Dispose();
     }
     catch (Exception ex)
     {
         while (true)
         {
             myDialog dialog = new myDialog(ex.Message);
             if (dialog.ShowDialog() == true)
             {
                 break;
             }
         }
     }
 }