Ejemplo n.º 1
0
 public static ClsSingeltonPlc CreateInstance(ClsSingeltonPlcParameter PlcParameter)
 {
     if (m_instance == null)
     {
         m_instance = new ClsSingeltonPlc(PlcParameter);
     }
     return(m_instance);
 }
Ejemplo n.º 2
0
        private ClsSingeltonPlc(ClsSingeltonPlcParameter PlcParameter)
        {
            this.m_errorCounter = 0;
            this.m_WriteValues  = new Queue <ClsSingeltonPlcWriteDatas>();
            this.m_parameter    = ClsSingeltonParameter.CreateInstance();
            this.m_language     = ClsSingeltonLanguage.CreateInstance();

            this.m_sqliteConnection = new SQLiteConnection();
            this.m_sqliteConnection.ConnectionString = this.m_parameter.ConnectionString;
            this.m_sqliteConnection.Open();

            this.m_sqliteCommand = new SQLiteCommand(this.m_sqliteConnection);


            this.m_DatenBytes = new byte[0];

            this.m_FlagGoOn = false;

            this.m_DatabasesInfo   = new Hashtable();
            this.m_DatabasesNr     = new List <int>();
            this.m_SymbolInfo      = new Hashtable();
            this.m_DatabasesValues = new Hashtable();

            this.m_InfoThread = new Hashtable();


            this.m_Daten              = new List <ClsSingeltonPlcDatas>();
            this.m_Value              = new List <string>();
            this.m_TimerRead          = new System.Windows.Forms.Timer();
            this.m_TimerRead.Enabled  = false;
            this.m_TimerRead.Interval = 100;
            this.m_TimerRead.Tick    += TimerRead_Tick;

            this.m_TimerPlc          = new System.Windows.Forms.Timer();
            this.m_TimerPlc.Enabled  = true;
            this.m_TimerPlc.Interval = 1000;
            this.m_TimerPlc.Tick    += TimerPlc_Tick;

            this.m_IP   = PlcParameter.IP;
            this.m_Rack = Convert.ToInt32(PlcParameter.Rack);
            this.m_Slot = Convert.ToInt32(PlcParameter.Slot);

            this.m_ProgressBar = PlcParameter.ProgBar;

            this.m_LblStatus = PlcParameter.LblStatus;
            this.m_BtnStart  = PlcParameter.BtnStart;
            this.m_BtnStopp  = PlcParameter.BtnStopp;
            this.m_LblPlc    = PlcParameter.LblPlc;

            this.m_BackgroundWorkerPlcRead = new BackgroundWorker();
            this.m_BackgroundWorkerPlcRead.WorkerReportsProgress      = true;
            this.m_BackgroundWorkerPlcRead.WorkerSupportsCancellation = true;
            this.m_BackgroundWorkerPlcRead.DoWork             += BackgroundWorkerPlcRead_DoWork;
            this.m_BackgroundWorkerPlcRead.ProgressChanged    += BackgroundWorkerPlcRead_ProgressChanged;
            this.m_BackgroundWorkerPlcRead.RunWorkerCompleted += BackgroundWorkerPlcRead_RunWorkerCompleted;

            m_VarCollect  = ClsSingeltonVariablesCollecter.CreateInstance();
            m_DataBinding = ClsSingeltonDataBinding.CreateInstance();

            this.ButtonVisibleOnOff(this.m_BtnStart, true);
            this.ButtonVisibleOnOff(this.m_BtnStopp, false);
            this.SetInfo(this.m_LblStatus, "Wait..");
            this.m_PlcState = 0;

            this.LoadPlcitems();
        }