aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking
Commit message (Collapse)AuthorAge
* Add "Reset track section" functionorwell962018-10-26
|
* Fix demo signalsorwell962018-10-25
|
* Add doc for supported_aspects, improve other doc and aspect autofillorwell962018-10-25
|
* Display route_rsn when denying routesetting by subroute locked.orwell962018-10-25
|
* Improve ATC-LZB-User control interaction, smoothen LZB control operationsorwell962018-10-17
| | | | (prevent flickering view when atc battles against lzb)
* Actually allow what manual promises (setting IP on non-assigned signals)orwell962018-10-17
|
* Remote Routesetting from Onboard Computerorwell962018-10-10
| | | | + Fix lzb oncoming item deletion/speed restriction
* Properly implement invalidate_all_paths, recheck lzb on aspect changeorwell962018-10-10
|
* Add signal safety control override, restructure control systemorwell962018-10-10
|
* Make signal influence point (~halt point) specifiableorwell962018-10-09
| | | | Also extend signal api necessarily
* Improve route programming:orwell962018-10-07
| | | | | | | - Formspec for TCBs instead of unhandy chatcommands - Ability to advance route over the next secction without punching end - Better visualization - Ability to route into dead-end sections
* Fix route programming lock-placementorwell962018-09-28
|
* Add LuaAutomation interface functions for interlocking routesetting and ↵orwell962018-08-24
| | | | | | aspect requesting. This allows to incorporate interlocking to automated systems
* Move passive API to the advtrains coreorwell962018-08-16
| | | | to remove dependency of interlocking on luaautomation
* Fix various bugs found while testingorwell962018-08-13
|
* Add 'interlocking' privilege and add security checksorwell962018-08-12
|
* Automatic working (re-set certain route on train pass)orwell962018-08-12
|
* fix digging unconfigured tcbsorwell962018-08-12
|
* Signal aspect handling, make default signals compatible, fix signal diggingorwell962018-08-12
|
* Add routesetting callbacks.orwell962018-08-12
| | | | Now, only the signal aspect setting is still missing
* Uncommitted route handling (update_route function)orwell962018-08-03
|
* Implement routesettingorwell962018-07-21
| | | | Missing things: signal aspect updating, waiting routes handling, management /info tool
* Change stuff on route programming, begin routesettingorwell962018-07-17
|
* Basic route management from signalling formspecorwell962018-07-04
|
* Signal assignment and route programming procedureorwell962018-07-04
|
* Implement trains blocking sectionsorwell962018-06-29
|
* get_ts_at_pos(), file for train-related stufforwell962018-06-29
|
* Complete Track Section handling, incl. removing tcb's and marker entitiesorwell962018-06-26
|
* Add track section concept and rework TCB design, implement new linking behaviororwell962018-06-21
|
* Add Track Circuit Breaks (TCBs), Database and Track Circuit Setuporwell962018-06-20
| | | | Does not get saved yet.
* Interlocking: Create demo signals, signal API and model for TCB configurer nodeorwell962018-06-19
|
* Draft of interlocking systemorwell962018-06-14
an> { return m_address; } unsigned short Address::getPort() const { return m_port; } void Address::setAddress(unsigned int address) { m_address = address; } void Address::setPort(unsigned short port) { m_port = port; } void Address::print(std::ostream *s) const { (*s)<<((m_address>>24)&0xff)<<"." <<((m_address>>16)&0xff)<<"." <<((m_address>>8)&0xff)<<"." <<((m_address>>0)&0xff)<<":" <<m_port; } void Address::print() const { print(&dstream); } UDPSocket::UDPSocket() { if(g_sockets_initialized == false) throw SocketException("Sockets not initialized"); m_handle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if(DP) dstream<<DPS<<"UDPSocket("<<(int)m_handle<<")::UDPSocket()"<<std::endl; if(m_handle <= 0) { throw SocketException("Failed to create socket"); } /*#ifdef _WIN32 DWORD nonblocking = 0; if(ioctlsocket(m_handle, FIONBIO, &nonblocking) != 0) { throw SocketException("Failed set non-blocking mode"); } #else int nonblocking = 0; if(fcntl(m_handle, F_SETFL, O_NONBLOCK, nonblocking) == -1) { throw SocketException("Failed set non-blocking mode"); } #endif*/ setTimeoutMs(0); } UDPSocket::~UDPSocket() { if(DP) dstream<<DPS<<"UDPSocket("<<(int)m_handle<<")::~UDPSocket()"<<std::endl; #ifdef _WIN32 closesocket(m_handle); #else close(m_handle); #endif } void UDPSocket::Bind(unsigned short port) { if(DP) dstream<<DPS<<"UDPSocket("<<(int)m_handle <<")::Bind(): port="<<port<<std::endl; sockaddr_in address; address.sin_family = AF_INET; address.sin_addr.s_addr = INADDR_ANY; address.sin_port = htons(port); if(bind(m_handle, (const sockaddr*)&address, sizeof(sockaddr_in)) < 0) { #ifndef DISABLE_ERRNO dstream<<(int)m_handle<<": Bind failed: "<<strerror(errno)<<std::endl; #endif throw SocketException("Failed to bind socket"); } } void UDPSocket::Send(const Address & destination, const void * data, int size) { bool dumping_packet = false; if(INTERNET_SIMULATOR) dumping_packet = (rand()%10==0); //easy //dumping_packet = (rand()%4==0); // hard if(DP){ /*dstream<<DPS<<"UDPSocket("<<(int)m_handle <<")::Send(): destination=";*/ dstream<<DPS; dstream<<(int)m_handle<<" -> "; destination.print(); dstream<<", size="<<size<<", data="; for(int i=0; i<size && i<20; i++){ if(i%2==0) printf(" "); DEBUGPRINT("%.2X", ((int)((const char*)data)[i])&0xff); } if(size>20) dstream<<"..."; if(dumping_packet) dstream<<" (DUMPED BY INTERNET_SIMULATOR)"; dstream<<std::endl; } else if(dumping_packet) { // Lol let's forget it dstream<<"UDPSocket::Send(): " "INTERNET_SIMULATOR: dumping packet." <<std::endl; } if(dumping_packet) return; sockaddr_in address; address.sin_family = AF_INET; address.sin_addr.s_addr = htonl(destination.getAddress()); address.sin_port = htons(destination.getPort()); int sent = sendto(m_handle, (const char*)data, size, 0, (sockaddr*)&address, sizeof(sockaddr_in)); if(sent != size) { throw SendFailedException("Failed to send packet"); } } int UDPSocket::Receive(Address & sender, void * data, int size) { if(WaitData(m_timeout_ms) == false) { return -1; } sockaddr_in address; socklen_t address_len = sizeof(address); int received = recvfrom(m_handle, (char*)data, size, 0, (sockaddr*)&address, &address_len); if(received < 0) return -1; unsigned int address_ip = ntohl(address.sin_addr.s_addr); unsigned int address_port = ntohs(address.sin_port); sender = Address(address_ip, address_port); if(DP){ //dstream<<DPS<<"UDPSocket("<<(int)m_handle<<")::Receive(): sender="; dstream<<DPS<<(int)m_handle<<" <- "; sender.print(); //dstream<<", received="<<received<<std::endl; dstream<<", size="<<received<<", data="; for(int i=0; i<received && i<20; i++){ if(i%2==0) printf(" ");