示例#1
0
    public frmViewer()
    {
        InitializeComponent();
		settingsForm = null;
        getSerialPorts();
        mViewer = this.MG_Viewer1;
        mProcessor.OnAddBlock += new clsProcessor.OnAddBlockEventHandler(mProcessor_OnAddBlock);
        MG_CS_BasicViewer.OnSelection += new MG_CS_BasicViewer.OnSelectionEventHandler(mViewer_OnSelection);
        MG_CS_BasicViewer.MouseLocation += new MG_CS_BasicViewer.MouseLocationEventHandler(mViewer_MouseLocation);
        mSetup.MachineActivated+=new clsSettings.MachineActivatedEventHandler(mSetup_MachineActivated);

        mSetup.LoadAllMachines(System.IO.Directory.GetCurrentDirectory() + "\\Data");
        mProcessor.Init(mSetup.Machine);
        cancelled = false;
        workThread = null;
        sw = new Stopwatch();

        // create delegate functions for use in threads
        TX_LED = new TransmitLEDDelegate(TransmitLED);
        RX_LED = new ReceiveLEDDelegate(ReceiveLED);
        FinishActions = new ThreadFinishActionsDelegate(ThreadFinishActions);
        UpdateGUIAction = new UpdateGUIThreadDelegate(UpdateGUI);
        UpdatePositionLEDSAction = new UpdatePositionLEDSDelegate(UpdatePositionLEDS);
        
        setMode(eMode.DISCONNECTED);
        UpdateInterval = 200; // 5 updates sec
        statusUpdates = false; // when enabled
        feedHold = false;
        PreprocessorMode = true;
        GrblReportsInches = false;
        
        TXLEDoff = new System.Timers.Timer(10);
        TXLEDoff.Elapsed += TXLEDoffElapsed;
        RXLEDoff = new System.Timers.Timer(10);
       	RXLEDoff.Elapsed += RXLEDoffElapsed; 
		
       	Reportrgx = new Regex(
	      "MPos:\\[([-+]?[0-9]*[\\\\.,]?[0-9]*),([-+]?[0-9]*[\\\\.,]?[0"+
	      "-9]*),([-+]?[0-9]*[\\\\.,]?[0-9]*)\\],WPos:\\[([-+]?[0-9]*[\\\\."+
	      ",]?[0-9]*),([-+]?[0-9]*[\\\\.,]?[0-9]*),([-+]?[0-9]*[\\\\.,]"+
	      "?[0-9]*)\\].*",  
	      RegexOptions.CultureInvariant | RegexOptions.Compiled
	    );       	
    }