Changeset 909
- Timestamp:
- 08/15/01 12:39:04 (23 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/.cosyrc
r808 r909 2 2 # -85.0 , +310.0 3 3 # 4 MinAz[Deg]: -30.0 5 MaxAz[Deg]: +375.0 4 Az_MaxTime2ReachHome[s]: 100 5 Az_Min[Deg]: -30.0 6 Az_Max[Deg]: +375.0 6 7 7 8 # 8 9 # 9 10 # 10 MinZd[Deg]: -70.0 11 MaxZd[Deg]: +70.0 11 Zd_MaxTime2ReachHome[s]: 100 12 Zd_Min[Deg]: -70.0 13 Zd_Max[Deg]: +70.0 -
trunk/MagicSoft/Cosy/MCosy.cc
r808 r909 14 14 15 15 #include "macs.h" 16 #include " timer.h"16 #include "base/timer.h" 17 17 #include "shaftencoder.h" 18 18 19 #include <sys/resource.h> // PRIO_PROCESS 19 #include "MGSkyPosition.h" // FIXME!!!!!!!!!!!!!!!!! 20 21 //#include <sys/resource.h> // PRIO_PROCESS 20 22 21 23 typedef struct tm tm_t; … … 121 123 min = dist; 122 124 } 123 cout << "Shortest Zd: " << ret.Zd() << " Az:" << ret.Az() << endl;124 125 return ret*(16384.0/360.0); 125 126 } … … 347 348 { 348 349 lout << "Error 6004 happened" << endl; 349 SkipPendingSdos();350 350 break; 351 351 } … … 393 393 { 394 394 lout << "Error 3006 happened" << endl; 395 SkipPendingSdos();396 395 break; 397 396 } … … 525 524 } 526 525 526 void *MTGui::Thread() 527 { 528 fCosy->GuiThread(this); 529 return NULL; 530 } 531 532 void *MTTalk::Thread() 533 { 534 fCosy->TalkThread(); 535 return NULL; 536 } 537 527 538 void MCosy::TalkThread() 528 539 { … … 530 541 // Start the Network 531 542 // 532 Network::Start(); 543 cout << "Reading configuration file..." << flush; 544 TEnv env(".cosyrc"); 545 cout << "done." << endl; 533 546 534 547 const int res = fMac3->GetVelRes(); … … 538 551 fMac3->SetDeceleration(res); 539 552 540 fMac3->SetSyncMode(); 541 542 fMac1->SetHome(250000); 543 fMac2->SetHome(250000); 553 fMac3->StartPosSync(); 554 555 cout << "Going Home..." << endl; 556 fMac1->SetHome(250000, env.GetValue("Az_MaxTime2ReachHome[s]", 100)); 557 fMac2->SetHome(250000, env.GetValue("Zd_MaxTime2ReachHome[s]", 100)); 544 558 PostMsg(WM_PRESET, 0, 0); 545 559 PostMsg(WM_WAIT, 0, 0); … … 551 565 cout << "APOS: " << repos.Zd() << "re, " << repos.Az() << "re" << endl; 552 566 553 TEnv env(".cosyrc"); 554 555 cout << Deg2AzRE(env.GetValue("MinAz[Deg]", -1.0)) << " < Az < " 556 << Deg2AzRE(env.GetValue("MaxAz[Deg]", +1.0)) << "RE" << endl; 557 cout << env.GetValue("MinAz[Deg]", -1.0) << " < Az < " 558 << env.GetValue("MaxAz[Deg]", +1.0) << kDEG << endl; 559 cout << Deg2ZdRE(env.GetValue("MinZd[Deg]", -1.0)) << "RE < Zd < " 560 << Deg2ZdRE(env.GetValue("MaxZd[Deg]", +1.0)) << "RE" << endl; 561 562 fMac1->SetNegEndswitch(Deg2AzRE(env.GetValue("MinAz[Deg]", -1.0))); 563 fMac1->SetPosEndswitch(Deg2AzRE(env.GetValue("MaxAz[Deg]", +1.0))); 567 /* 568 cout << Deg2AzRE(env.GetValue("MinAz[Deg]", -1.0)) << " < Az < " 569 << Deg2AzRE(env.GetValue("MaxAz[Deg]", +1.0)) << "RE" << endl; 570 cout << env.GetValue("MinAz[Deg]", -1.0) << " < Az < " 571 << env.GetValue("MaxAz[Deg]", +1.0) << kDEG << endl; 572 cout << Deg2ZdRE(env.GetValue("MinZd[Deg]", -1.0)) << "RE < Zd < " 573 << Deg2ZdRE(env.GetValue("MaxZd[Deg]", +1.0)) << "RE" << endl; 574 */ 575 576 cout << "Setting up software endswitch..." << flush; 577 fMac1->SetNegEndswitch(Deg2AzRE(env.GetValue("Az_Min[Deg]", -1.0))); 578 fMac1->SetPosEndswitch(Deg2AzRE(env.GetValue("Az_Max[Deg]", +1.0))); 579 580 fMac2->SetNegEndswitch(Deg2ZdRE(env.GetValue("Zd_Min[Deg]", -1.0))); 581 fMac2->SetPosEndswitch(Deg2ZdRE(env.GetValue("Zd_Max[Deg]", +1.0))); 582 cout << "done." << endl; 564 583 565 584 /* … … 567 586 fMac2->SetPosEndswitch(Deg2ZdRE(env.GetValue("MaxZd[Deg]", +1.0))); 568 587 */ 569 fMac3->SetSyncMode();588 // fMac3->StartVelSync(); 570 589 /* 571 590 cout << "PostMsg(WM_PRESET)" << endl; … … 588 607 // dest = AltAz(-46.0, 210); 589 608 // SetPosition(dest); 590 setpriority(PRIO_PROCESS, 0, 10);591 609 592 610 Slalib sla; … … 675 693 } 676 694 677 void *MCosy::MapTalkThread(void *arg) 678 { 679 pthread_detach(pthread_self()); 680 681 MCosy *cosy = (MCosy*)arg; 682 683 cosy->TalkThread(); 684 685 cosy->lout << "- Sending Thread done." << endl; 686 687 return NULL; 688 } 689 690 int MCosy::StopWaitingForSDO() 691 { 692 return Break() || fMac1->HasError() || fMac2->HasError(); 695 void MCosy::GuiThread(MTGui *t) 696 { 697 MGSkyPosition *disp = fWin->GetSkyDisplay(); 698 while (!t->HasStopFlag()) 699 { 700 usleep(100000); // 0.1s 701 702 fAlt1->DisplayVal(); 703 fAlt2->DisplayVal(); 704 fAz->DisplayVal(); 705 706 // gSystem->ProcessEvents(); 707 708 ZdAz ist = GetSePos()*(360.0/16384.0); // [se] 709 disp->DrawPosition(ist); 710 } 711 cout << "Not running anymore." << endl; 712 } 713 714 int MCosy::StopWaitingForSDO() const 715 { 716 return Break() || HasError(); //fMac1->HasError() || fMac2->HasError(); 693 717 } 694 718 695 719 void MCosy::Start() 696 720 { 697 if (fTxThrd) 698 { 699 cout << "Error: tx thread already started." << endl; 700 return; 701 } 702 703 lout << "- Starting sending Thread." << endl; 704 705 fTxThrd = new pthread_t; 706 pthread_create(fTxThrd, NULL, MapTalkThread, this); 721 // Don't call this function twice! 722 Network::Start(); 723 724 lout << "- Starting TX Thread." << endl; 725 fTTalk = new MTTalk(this); 726 727 lout << "- Starting GUI Thread." << endl; 728 fTGui = new MTGui(this); 707 729 } 708 730 709 731 void MCosy::Stop() 710 732 { 711 if (!fTxThrd) 712 return; 713 714 pthread_cancel(*fTxThrd); 715 716 delete fTxThrd; 717 fTxThrd = NULL; 718 719 lout << "- Sending Thread stopped." << endl; 720 721 SkipPendingSdos(); 733 delete fTGui; 734 lout << "- GUI Thread stopped." << endl; 735 736 delete fTTalk; 737 lout << "- TX Thread stopped." << endl; 722 738 723 739 Network::Stop(); … … 725 741 726 742 MCosy::MCosy(const char *dev, const int baud, ostream &out) 727 : Network(dev, baud, out), fT xThrd(NULL), fTracking(kFALSE)743 : Network(dev, baud, out), fTracking(kFALSE) 728 744 { 729 745 // … … 747 763 SetNode(fAz); 748 764 749 MGCosy *fWin=new MGCosy(this, gClient->GetRoot(), 1, 1);765 fWin=new MGCosy(this, gClient->GetRoot(), 1, 1); 750 766 751 767 fAz->SetDisplay(fWin->GetLabel1()); … … 756 772 void MCosy::TerminateApp() 757 773 { 758 gSystem->ExitLoop(); 774 cout << "MCosy::TerminateApp()" << endl; 775 gApplication->Terminate(0); 759 776 } 760 777 761 778 MCosy::~MCosy() 762 779 { 780 cout << "Deleting Nodes." << endl; 781 763 782 delete fAz; 764 783 delete fAlt2; … … 768 787 delete fMac3; 769 788 789 cout << "Deleting MGCosy." << endl; 790 770 791 delete fWin; 771 } 792 793 cout << "MGCosy deleted." << endl; 794 } -
trunk/MagicSoft/Cosy/MCosy.h
r808 r909 5 5 #include "msgqueue.h" 6 6 #include "network.h" 7 #include "MThread.h" 7 8 8 9 #define kDEG ((char)0xb0) // Linux 'ø' 9 10 11 #define WM_WAIT WM_NULL 10 12 #define WM_PRESET 0x1000 11 13 #define WM_POSITION 0x1001 … … 13 15 #define WM_STOP 0x1003 14 16 #define WM_POLARIS 0x1004 15 #define WM_WAIT 0x100516 17 17 18 class ShaftEncoder; 18 19 class Macs; 19 20 class MGCosy; 21 class MCosy; 22 23 class MTGui : public MThread 24 { 25 private: 26 MCosy *fCosy; 27 28 void *Thread(); 29 30 public: 31 MTGui(MCosy *cosy) : MThread(false), fCosy(cosy) 32 { 33 SetPriority(20); 34 Start(); 35 } 36 }; 37 38 class MTTalk : public MThread 39 { 40 private: 41 MCosy *fCosy; 42 43 void *Thread(); 44 45 public: 46 MTTalk(MCosy *cosy) : MThread(false), fCosy(cosy) 47 { 48 SetPriority(10); 49 Detach(); 50 Start(); 51 } 52 }; 20 53 21 54 class MCosy : public Network, public MsgQueue 22 55 { 56 friend class MTGui; 57 friend class MTTalk; 58 23 59 private: 24 60 ShaftEncoder *fAlt1; … … 32 68 MGCosy *fWin; 33 69 34 pthread_t *fTxThrd; 70 MTGui *fTGui; 71 MTTalk *fTTalk; 35 72 36 73 ZdAz fOffset; // Tracking Offset between SE and calc-pos [re] … … 38 75 int fTracking; // Flag for present tracking action 39 76 40 static void *MapTalkThread(void *arg); 41 77 ZdAz GetRePos(); 42 78 ZdAz GetSePos(); // [se] 43 ZdAz GetRePos();44 79 45 80 void TalkThread(); 81 void GuiThread(MTGui *t); 82 46 83 int SetPosition(const ZdAz &dst); 47 84 … … 50 87 void TrackPosition(const RaDec &dst); // ra, dec [rad] 51 88 52 int StopWaitingForSDO() ;89 int StopWaitingForSDO() const; 53 90 54 91 public: … … 63 100 static ZdAz CorrectTarget(const ZdAz &src, const ZdAz &dst); 64 101 // static ZdAz RaDec2ZdAz(const double mjd, const RaDec &pos, const RaDec &pm=RaDec(0,0)); 102 65 103 }; 66 104 -
trunk/MagicSoft/Cosy/Makefile
r808 r909 11 11 12 12 # 13 # ----->>> settings for compiler 13 # please change all system depend values in the 14 # config.mk.${OSTYPE} file 15 # 16 # 17 include Makefile.conf.$(OSTYPE) 18 include Makefile.conf.general 19 14 20 # 15 21 16 CC = gcc 17 CXX = g++ 18 AR = ar -rc 19 AS = as 20 LD = ld 21 RANLIB = ranlib 22 23 # 24 # ----->>> settings for compilation 25 # 26 27 PROGRAMS = cosy starg 28 29 ROOTFLAGS = `root-config --cflags` 30 ROOTGLIBS = `root-config --glibs` 22 PROGRAMS = cosy starg 23 SOLIB = 24 CINT = M 25 INCLUDES = -I. -Iincl -Ibase -Igui -Idevdrv -Icandrv -Ivideodev -Icatalog 26 LIBS = -lpng -lz -L/usr/X11R6/lib 31 27 32 28 # … … 34 30 # 35 31 # WARNING: the result (whether the linkage works or not) depends on the 36 # order of the libraries 32 # order of the libraries. It seems, that the most base library 33 # must be the last one 37 34 # 38 #39 #LIBS = -L. -L/usr/lib -lstdc++ -lpthread40 INCLUDES = -I. -I/usr/X11R6/include -Icandrv -Idevdrv -Ibase -Igui -Iincl -Islalib -Ivideodev -Icatalog41 LIBS = -L. -L/usr/X11R6/lib -lpthread -lpng -lz42 #INCLUDES = -I. -Ibase -Igui -Islalib43 44 WARNING = -Wall -fno-rtti -fno-exceptions45 OPTIM = -O246 DEBUG = -g47 DEFINES = -DCPU=486 -DBUS_LITTLE_ENDIAN -DDEBUG=0 -DLINUX -DSHOW48 49 CFLAGS = $(OPTIM) $(DEBUG) $(WARNING) $(INCLUDES) $(ROOTFLAGS) $(DEFINES)50 CXXFLAGS = $(CFLAGS)51 52 CINT = M53 35 54 36 # 55 37 # ----->>> mars libraries 56 38 # 39 SUBDIRS = \ 40 candrv \ 41 catalog \ 42 devdrv \ 43 gui \ 44 videodev \ 45 base \ 46 slalib 47 48 LIBRARIES = $(SUBDIRS:=.a) 57 49 58 50 #------------------------------------------------------------------------------ 59 .SILENT:60 51 61 52 .SUFFIXES: .c .cc .h .o 62 53 63 SLASRC = slalib/cldj.c slalib/dranrm.c slalib/mappa.c slalib/aoppa.c \ 64 slalib/mapqk.c slalib/aopqk.c slalib/epj.c slalib/evp.c \ 65 slalib/dvn.c slalib/prenut.c slalib/geoc.c slalib/refco.c \ 66 slalib/eqeqx.c slalib/dcs2c.c slalib/dvdv.c slalib/dmxv.c \ 67 slalib/dcc2s.c slalib/refz.c slalib/refro.c slalib/prec.c \ 68 slalib/nut.c slalib/dmxm.c slalib/nutc.c slalib/range.c \ 69 slalib/aoppat.c slalib/deuler.c slalib/drange.c slalib/daf2r.c \ 70 slalib/dh2e.c slalib/gmst.c slalib/de2h.c slalib/altaz.c \ 71 slalib/gmsta.c slalib/dat.c slalib/dtt.c slalib/oapqk.c \ 72 slalib/ampqk.c slalib/dimxv.c slalib/mapqkz.c slalib/dr2af.c \ 73 slalib/dd2tf.c 74 75 SLAOBJ = $(SLASRC:.c=.o) 76 77 SRCFILES = candrv/vmodican.cc \ 78 candrv/canopen.cc \ 79 candrv/network.cc \ 80 candrv/nodedrv.cc \ 81 candrv/sdolist.cc \ 82 devdrv/shaftencoder.cc \ 83 devdrv/macs.cc \ 84 gui/MGCosy.cc \ 85 gui/MGImage.cc \ 86 gui/MGCoordinate.cc \ 87 gui/MGCoordinates.cc \ 88 base/timer.cc \ 89 base/msgqueue.cc \ 90 base/File.cc \ 91 base/MStopwatch.cc \ 92 catalog/SaoFile.cc \ 93 catalog/StarCatalog.cc \ 94 catalog/Slalib.cc \ 95 videodev/Camera.cc \ 96 videodev/Filter.cc \ 97 videodev/Writer.cc \ 98 MStarguider.cc \ 99 MCosy.cc \ 100 Starguider.cc 54 SRCFILES = MCosy.cc Starguider.cc 101 55 102 56 SRCS = $(SRCFILES) … … 106 60 ############################################################ 107 61 108 all: $(PROGRAMS)62 all: rmlib $(PROGRAMS) $(SOLIB) 109 63 110 $(SLAOBJ): 111 echo 'Compiling $*.c' 112 $(CC) -c $(CFLAGS) -pedantic $*.c -o $*.o 64 # Use $(CXX) -v ... for a more verbose output 65 # 66 # We could link mars.so instead of all libraries. This would need 67 # some MBs less space on the HD. But this means, that the Shared 68 # Library Path in your system must be set properly to be able to start 69 # 'mars' 70 # 71 $(PROGRAMS): $(LIBRARIES) $(OBJS) $(HEADERS) $(PROGRAMS:=.o) 72 @echo " Linking $@ ..." 73 $(CXX) $(CXXFLAGS) $(LIBS) $@.o $(OBJS) $(MARS_LIB) $(ROOTGLIBS) -o $@ 113 74 114 #$(PROGRAMS): $(PROGRAMS:=.o) $(OBJS) $(SLAOBJ) 115 # @echo " Linking $@ ..." 116 # $(CXX) $(CXXFLAGS) $@.o $(LIBS) $(ROOTGLIBS) -o $@ 117 $(PROGRAMS): $(SLAOBJ) $(OBJS) $(PROGRAMS:=.o) 118 @echo " Linking $@ ..." 119 $(CXX) $(CXXFLAGS) $(LIBS) $(SLAOBJ) $(OBJS) $(ROOTGLIBS) -o $@ $@.o 75 $(SOLIB): $(LIBRARIES) $(OBJS) $(HEADERS) MCint.o 76 @echo " Linking $(SOLIB) ..." 77 $(CXX) -shared $(CXXFLAGS) $(SUBDIRS:=/*.o) $(ROOTGLIBS) -o $@ 78 mv cosy.so lib 120 79 121 #dox: 122 # @echo " Creating html documentation:" 123 # root -b -q dohtml.C 80 $(LIBRARIES): 81 @echo " " 82 @echo " Creating lib$@:" 83 (cd $*; make -f Makefile; cd ..; mv $*/$@ lib/lib$@) 124 84 85 dox: 86 @echo " Creating html documentation:" 87 root -b -q dohtml.C 125 88 126 89 include Makefile.rules 127 90 128 clean: rm cint rmobjs rmcore rmbin rmbak91 clean: rmlib rmcint rmobjs rmcore rmbin 129 92 130 tar: clean 93 mrproper: clean rmbak 94 @rm -f macros/*~ 95 @rm -rf htmldoc 96 @echo "cd base" 97 @cd base; make mrproper; cd .. 98 @echo "cd .." 99 @echo "cd candrv" 100 @cd candrv; make mrproper; cd .. 101 @echo "cd .." 102 @echo "cd devdrv" 103 @cd devdrv; make mrproper; cd .. 104 @echo "cd .." 105 @echo "cd gui" 106 @cd gui; make mrproper; cd .. 107 @echo "cd .." 108 @echo "cd videodev" 109 @cd videodev; make mrproper; cd .. 110 @echo "cd .." 111 @echo "cd catalog" 112 @cd videodev; make mrproper; cd .. 113 @echo "cd .." 114 115 tar: mrproper 131 116 @echo "Making tar-file" 132 117 @tar -cvf ../cosy.tar * -
trunk/MagicSoft/Cosy/Makefile.conf.linux-gnu
r738 r909 8 8 # @maintitle 9 9 10 # @code 11 10 12 # compilers 11 13 12 CC = gcc13 CXX = g++14 F77 = f7715 AR = ar -rc14 CC = gcc 15 CXX = g++ 16 F77 = f77 17 AR = ar -rc 16 18 # 17 19 # ----->>> settings for compilation 18 20 # 19 21 20 OPTIM = -O2 -Wall -fno-rtti -fno-exceptions -fPIC 21 DEBUG = -g 22 OPTIM = -O2 -Wall -fno-rtti -fno-exceptions -fPIC -Wtraditional -Wpointer-arith -Wcast-align -Wwrite-strings -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Woverloaded-virtual 23 DEBUG = -g 24 25 MARS_LIB = -Llib $(SUBDIRS:%=-l%) 26 INCLUDES = -I. $(SUBDIRS:%=-I%) 22 27 23 28 # uncomment this for quiet compilation 24 29 25 #.SILENT:30 .SILENT: 26 31 27 32 # @endcode -
trunk/MagicSoft/Cosy/Makefile.rules
r738 r909 4 4 -f Makefile.depend 2> kk.kk ; cat kk.kk 5 5 6 $(LIB): $(OBJS) $( CINT)Cint.o7 @echo " - Building Library $(LIB) ... "6 $(LIB): $(OBJS) $(HEADERS) 7 @echo " - Building Library lib$(LIB) ... " 8 8 $(AR) $(LIB) *.o 9 9 … … 13 13 14 14 $(ROOTSYS)/bin/rootcint -f $(CINT)Cint.cc \ 15 -c $(INCLUDES) $( HEADERS) $(CINT)Incl.h $(CINT)LinkDef.h15 -c $(INCLUDES) $(DEFINES) $(HEADERS) $(CINT)Incl.h $(CINT)LinkDef.h 16 16 17 17 .cxx.o: … … 32 32 rmcint: 33 33 @echo "Removing cint-stuff..." 34 @rm -rf *Cint.* 34 @rm -f *Cint.* 35 36 rmlib: 37 @echo "Removing libraries..." 38 @rm -f lib/lib*.a lib*.a 35 39 36 40 rmobjs: 37 41 @echo "Removing object files..." 38 42 @rm -f *.o 39 @rm -f base/*.o40 @rm -f gui/*.o41 @rm -f candrv/*.o42 @rm -f devdrv/*.o43 @rm -f slalib/*.o44 43 45 44 rmcore: 46 45 @echo "Removing core files..." 47 @rm - rf core*46 @rm -f core* 48 47 49 48 rmbin: 50 49 @echo "Removing binary files..." 51 @rm - rf $(PROGRAMS) so_locations50 @rm -f $(PROGRAMS) so_locations 52 51 53 52 rmbak: 54 53 @echo "Removing backup files..." 55 @rm -f *~ kk.kk *.bak 56 @rm -f base/*~ base/kk.kk base/*.bak 57 @rm -f gui/*~ gui/kk.kk gui/*.bak 58 @rm -f candrv/*~ candrv/kk.kk candrv/*.bak 59 @rm -f devdrv/*~ devdrv/kk.kk devdrv/*.bak 60 @rm -f slalib/*~ slalib/kk.kk slalib/*.bak 54 @rm -f *~ kk.kk *.bak 61 55 62 56 cflags: -
trunk/MagicSoft/Cosy/Starguider.cc
r808 r909 12 12 #include "Filter.h" 13 13 #include "Writer.h" 14 #include " timer.h"14 #include "base/timer.h" 15 15 16 16 enum { … … 293 293 } 294 294 295 void Starguider:: Execute(const unsigned long n, byte *img, struct timeval *tm)295 void Starguider::ProcessFrame(const unsigned long n, byte *img, struct timeval *tm) 296 296 { 297 297 -
trunk/MagicSoft/Cosy/Starguider.h
r808 r909 60 60 // Execution of one frame - this function may be overloaded! 61 61 // 62 void Execute(const unsigned long n, byte *img, struct timeval *tm);62 void ProcessFrame(const unsigned long n, byte *img, struct timeval *tm); 63 63 }; 64 64 -
trunk/MagicSoft/Cosy/base/MGList.h
r732 r909 1 1 #ifndef MGLIST_H 2 2 #define MGLIST_H 3 4 #include <iostream.h> 3 5 4 6 #ifndef ROOT_TOrdCollection … … 11 13 ~MGList() 12 14 { 15 cout << "Deleting:" << flush; 16 13 17 TIter Next(this); 14 18 15 19 TObject *obj; 16 20 while ((obj=Next())) 21 { 22 cout << " <" << ((TGObject*)obj)->GetName() << ">" << flush; 17 23 delete (TGObject*)obj; 24 } 25 cout << endl; 18 26 } 19 27 void Add(TGObject *obj) -
trunk/MagicSoft/Cosy/base/msgqueue.cc
r732 r909 73 73 // 74 74 // Set break state and wait until Proc() returned (break state deleted) 75 // This means, that a new command is invoked and (if forseen) the 76 // running command should stop execution. 77 // 78 // This is some kind of controlled user break without using signals 75 79 // 76 80 fBreak = 1; -
trunk/MagicSoft/Cosy/base/msgqueue.h
r732 r909 32 32 virtual ~MsgQueue(); 33 33 34 int Break() { return fBreak; }34 int Break() const { return fBreak; } 35 35 36 36 virtual void *Proc(int msg, void *mp1); -
trunk/MagicSoft/Cosy/candrv/canopen.cc
r732 r909 223 223 } 224 224 225 WORD_t CanOpen::CobId(BYTE_t node, BYTE_t fcode) 225 WORD_t CanOpen::CobId(BYTE_t node, BYTE_t fcode) const 226 226 { 227 227 return (fcode<<7) | node&0x1f; -
trunk/MagicSoft/Cosy/candrv/network.cc
r808 r909 6 6 void Network::Start() 7 7 { 8 StartReceiver(); 8 lout << "- Starting network." << endl; 9 10 VmodIcan::Start(); 9 11 InitNodes(); 12 13 lout << "- Network started." << endl; 10 14 } 11 15 12 16 void Network::Stop() 13 17 { 18 lout << "- Stopping network." << endl; 19 14 20 StopNodes(); 15 StopReceiver();21 VmodIcan::Stop(); 16 22 17 23 lout << "- Network stopped." << endl; … … 166 172 } 167 173 168 bool Network::HasError() 174 bool Network::HasError() const 169 175 { 170 176 for (int i=0; i<32; i++) -
trunk/MagicSoft/Cosy/candrv/network.h
r808 r909 31 31 virtual void Stop(); 32 32 33 bool HasError() ;33 bool HasError() const; 34 34 }; 35 35 -
trunk/MagicSoft/Cosy/candrv/nodedrv.cc
r808 r909 116 116 } 117 117 118 void NodeDrv::WaitForSdo(WORD_t idx, BYTE_t subidx )118 void NodeDrv::WaitForSdo(WORD_t idx, BYTE_t subidx, WORD_t timeout) 119 119 { 120 while (fNetwork->WaitingForSdo(fId, idx, subidx)) 121 usleep(1); 120 fNetwork->WaitForSdo(fId, idx, subidx, timeout); 122 121 } 123 122 123 /* 124 124 void NodeDrv::WaitForSdos() 125 125 { … … 127 127 usleep(1); 128 128 } 129 */ 129 130 130 131 void NodeDrv::WaitForNextPdo1() -
trunk/MagicSoft/Cosy/candrv/nodedrv.h
r808 r909 29 29 virtual void StopDevice() = 0; 30 30 31 bool HasError() 31 bool HasError() { return fError; } 32 32 33 33 virtual void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, struct timeval *tv); … … 64 64 void WaitForNextPdo4(); 65 65 66 void WaitForSdos();67 void WaitForSdo(WORD_t idx, BYTE_t subidx=0 );66 // void WaitForSdos(); 67 void WaitForSdo(WORD_t idx, BYTE_t subidx=0, WORD_t timeout=500); 68 68 69 69 void EnableCanMsg(BYTE_t fcode); -
trunk/MagicSoft/Cosy/candrv/sdolist.cc
r732 r909 86 86 } 87 87 88 int PendingSDOList::IsPending() 88 int PendingSDOList::IsPending() const 89 89 { 90 90 return (int)fFirst->Next; -
trunk/MagicSoft/Cosy/candrv/sdolist.h
r732 r909 34 34 void DelAll(); 35 35 36 int IsPending() ;36 int IsPending() const; 37 37 int IsPending(BYTE_t node); 38 38 int IsPending(BYTE_t node, WORD_t idx, BYTE_t subidx); -
trunk/MagicSoft/Cosy/candrv/vmodican.cc
r732 r909 52 52 } 53 53 54 void *VmodIcan::ReceiveThread(void *data) 55 { 56 VmodIcan *cal = (VmodIcan*)data; 57 58 cal->lout << "- Starting Receiver Loop." << endl; 59 60 // 61 // set higher priority to make sure that no messages are lost. 62 // 63 setpriority(PRIO_PROCESS, 0, -10); 54 void *VmodIcan::Thread() 55 { 56 lout << "- Starting Receiver Loop." << endl; 64 57 65 58 while (1) … … 70 63 //cout << "waiting..." << endl; 71 64 72 const int n = read( cal->fd, &c, 1); // sleep until message arrive65 const int n = read(fd, &c, 1); // sleep until message arrive 73 66 74 67 gettimeofday(&tv, NULL); … … 89 82 FastMessage fmsg; 90 83 91 if ( cal->ReceiveFast(&fmsg) < 0)84 if (ReceiveFast(&fmsg) < 0) 92 85 return (void *)1; 93 86 … … 105 98 Message msg; 106 99 107 if ( cal->Receive(&msg) < 0)100 if (Receive(&msg) < 0) 108 101 return (void *)1; 109 102 110 103 //cal->PrintMsg(&msg); 111 cal->HandleMessage(&msg, &tv);104 HandleMessage(&msg, &tv); 112 105 113 106 break; 114 107 } 115 116 108 } 109 return NULL; 117 110 } 118 111 … … 765 758 } 766 759 767 VmodIcan::VmodIcan(const char *dev, const int baud, ostream &out) : Log(out), fRxThrd(NULL)//: CanDriver(dev, baud) 768 { 760 VmodIcan::VmodIcan(const char *dev, const int baud, ostream &out) : Log(out), MThread(false)//: CanDriver(dev, baud) 761 { 762 // 763 // Set priority of receiving thread and detach the receiving thread 764 // 765 SetPriority(-10); 766 Detach(); 767 769 768 Open(dev); // open module 770 769 Reset(); … … 782 781 VmodIcan::~VmodIcan() 783 782 { 784 Stop Receiver();783 Stop(); 785 784 DisableCanBusConnection(); 786 785 Close(); … … 794 793 SendCanFrame(cobid, msg); 795 794 } 796 795 /* 797 796 void VmodIcan::StopReceiver() 798 797 { … … 804 803 delete fRxThrd; 805 804 fRxThrd = NULL; 806 807 805 lout << "- Receiver Thread stopped." << endl; 808 806 } 807 */ 808 809 /* 809 810 void VmodIcan::StartReceiver() 810 811 { 811 //**************************************812 //* create thread waiting for messages *813 //**************************************812 ************************************** 813 * create thread waiting for messages * 814 ************************************** 814 815 if (fRxThrd) 815 816 { … … 823 824 pthread_create(fRxThrd, NULL, ReceiveThread, this); 824 825 } 825 826 */ 827 -
trunk/MagicSoft/Cosy/candrv/vmodican.h
r732 r909 9 9 #include "gendef.h" 10 10 11 class VmodIcan : public Log 11 #include "MThread.h" 12 /* 13 class VmodIcanRX : public MThread 12 14 { 13 15 private: 16 VmodIcan *fModule; 17 18 void *Thread(); 19 20 public: 21 MTGui(VmodIcan *mod) : MThread(false), fModule(mod) 22 { 23 SetPriority(-10); 24 Detach(); 25 } 26 }; 27 */ 28 class VmodIcan : public Log, protected MThread 29 { 30 friend class VmodIcanRX; 31 32 private: 14 33 int fd; // file descriptor for can module 15 pthread_t *fRxThrd;34 // pthread_t *fRxThrd; 16 35 17 36 int Ioctl(int msg, void *arg); 18 37 19 static void *ReceiveThread(void *data);38 void *Thread(); 20 39 21 40 void HandleMessage(Message *msg, struct timeval *tv); … … 52 71 virtual void TerminateApp() { exit(-1); } 53 72 54 protected:55 void StartReceiver();56 void StopReceiver();73 //protected: 74 // void StartReceiver(); 75 // void StopReceiver(); 57 76 58 77 public: -
trunk/MagicSoft/Cosy/cosy.cc
r738 r909 8 8 #include <TSystem.h> 9 9 #include <TApplication.h> 10 11 #include "MGCosy.h"12 13 #include "macs.h"14 #include "timer.h"15 #include "slalib.h"16 #include "slamac.h"17 #include "shaftencoder.h"18 19 #include <sys/resource.h> // PRIO_PROCESS20 10 21 11 int main(int argc, char **argv) … … 32 22 lout << "- Initialising Root environment." << endl; 33 23 TROOT root("Cosy", "Magic Control System"); 34 TApplication app 24 TApplication app("App", &argc, argv); 35 25 36 26 // … … 40 30 cosy->Start(); 41 31 42 lout << "- Starting mai loop." << endl;43 app.Run( );32 lout << "- Starting mainloop." << endl; 33 app.Run(kTRUE); 44 34 35 lout << "- Stopping cosy." << endl; 45 36 cosy->Stop(); 37 lout << "- cosy stopped." << endl; 46 38 47 39 delete cosy;
Note:
See TracChangeset
for help on using the changeset viewer.