Skip to content

Commit

Permalink
ENH: Add option to toggle viewport conversion method through socket
Browse files Browse the repository at this point in the history
  • Loading branch information
NicerNewerCar committed Oct 19, 2023
1 parent 0cbbad2 commit 52e05e5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
17 changes: 17 additions & 0 deletions autoscoper/src/net/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,26 @@ void Socket::handleMessage(QTcpSocket * connection, char* data, qint64 length)
}
break;

case 17:
// Toggle between the viewport 2 pixel calculation methods
{
size_t offset = preamble_offset;

SocketReadValuePointerMacro(method, qint32); // 0 for old method, 1 for new method
this->m_mainwindow->on_actionUse_New_Viewport_Logic_triggered((bool)(*method));
std::cout << "Toggled viewport logic to " << *method << std::endl;
connection->write(QByteArray(1, 17));

}
break;

default:
std::cerr << "Cannot handle message" << std::endl;
for (int i = 0; i < length; ++i)
std::cout << data[i];
std::cout << std::endl;
connection->write(QByteArray(1,0));

break;
}
}
Expand Down
15 changes: 15 additions & 0 deletions scripts/matlab/AutoscoperConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,20 @@ function trackingDialog(obj, volNum, startframe, endframe, repeats, max_itr, min
ncc_out = [ncc(1), ncc(2), ncc(1) * ncc(2)];
end

function toggleViewportConversionMethod(obj, method)
% Toggles the viewport conversion method to either
% 0 for the default method
% 1 for the new method

if nargin < 2
error('Not enough input arguments');
end
fwrite(obj.socket_descriptor, [ ...
17 ...
typecast(int32(method), 'uint8') ...
]);

end

end
end
10 changes: 10 additions & 0 deletions scripts/python/PyAutoscoper/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,3 +594,13 @@ def getNumFrames(self) -> int:
response = self._send_command(0x0F) # 15
num_frames = struct.unpack("i", response[1:])[0]
return num_frames

def toggleViewportConversionMethod(self, method: bool) -> None:
"""
Toggle the viewport conversion method.
False for the default method, True for the new method.
:param method: The viewport conversion method to use.
"""
self._send_command(0x11, int(method)) # 17

0 comments on commit 52e05e5

Please sign in to comment.