5.6. Communications (comms.rsl)

(*
 * comms.rsl
 * file defines the rsl objects for the communications system of the CSTutor system
 *
 * Author: Kendall Merriman
 * Modified: Nov 19, 2004
 *)

module comms;

from Admin import all;

export all;

object ChatRoom is
	components: users:UserAccount* and name:string and messageLog:Message*;
	description: (* A chatroom is just that, a place where chatting occurs.  This object just tracks who is in it and relays messages to them *);
end ChatRoom;

object Message is
	components: user:UserAccount and message:string;
	description: (* a message in the chat rooms *);
end Message;

operation SendMessage is
	inputs: msg:Message and crm:ChatRoom;
	outputs: crm':ChatRoom;
	description: (* relays Message to all Users in ChatRoom *);
	precondition: (* chatroom is valid; message is non-empty *)
					#(msg.message) > 0;
	postcondition: (* message is added to the message list for the room, no others are removed, no extras are added *)
					(crm'.messageLog = crm.messageLog + msg) and (crm'.name = crm.name) and (crm'.users = crm.users);
end SendMessage;

operation AddUser is
	inputs: nUser:UserAccount and crm:ChatRoom;
	outputs: crm':ChatRoom;
	description: (* adds User to ChatRoom, preventing duplicates *);
	precondition: (* User is valid, chatroom is valid *)
					crm != nil and nUser != nil;
	postcondition: (* chatroom contains all original users and User, and no others *)
					(crm'.users = crm.users + nUser) and (crm'.name = crm.name) and (crm'.messageLog = crm.messageLog);
end AddUser;

operation RemoveUser is
	inputs: user:UserAccount and crm:ChatRoom;
	outputs: crm':ChatRoom;
	description: (* Removes User from ChatRoom *);
	precondition: (* User is valid, chatroom is valid *)
					crm != nil and user != nil;
	postcondition: (* chatroom contains all original users less User, and no others.  other users have been notified of part *)
					(forall(user':UserAccount) (user' in crm'.users) iff ((user' in crm.users) and (user' != user))) and (crm'.messageLog = crm.messageLog) and (crm'.name = crm.name);
end RemoveUser;

object RemoteDesktopConnection
	components: controller:UserAccount and controllee:UserAccount;
	description: (* represents a remote desktop connection between two users *);
end RemoteDesktopConnection;

operation RemoteControlInit is
	inputs: controller:UserAccount and controllee:UserAccount;
	outputs: rdc:RemoteDesktopConnection;
	description: (* creates a duplicate set of windows and a network connection for remote desktop control *);
	precondition: (* users are both valid, users have accepted connection *);
	postcondition: (* Network connection is valid and contains a link between the two users; contolling user has full set of windows representing controlles system *);
end RemoteControlInit;

operation ResolveCSTutorOperation is
	inputs: rdc:RemoteDesktopConnection;
	outputs: (* none *);
	description: (* performs an operation on remote system represented by rdc.controllee - note that operations can not be used as variables in this language, so it is not passes in *);
end ResolveCSTutorOperation;

operation RemoteControlEnd is
	inputs: rdc:RemoteDesktopConnection;
	outputs: rdc':RemoteDesktopConnection;
	description: (* closes the network connection of the remote desktop connection passed in *);
	precondition: (* NetworkConnectionis valid *);
	postcondition: (* Network connection is closed *);
end RemoteControlEnd;

object MessageBoard is
	components: threads:Thread*;
	description: (* a message board *);
end MessageBoard;

object Thread is
	components: posts:Post* and topic:Topic;
	description: (* a collection of posts on a topic contained in a single place in the message boards *);
end Thread;

object Topic is
	components: title:string and user:UserAccount;
	description: (* a topic for a thread, consisting of a title and the starting user *);
end Topic;

object Post is
	components: body:string and user:UserAccount;
	description: (* a collection of posts on a topic contained in a single place in the message boards *);
end Post;

operation NewPost is
	inputs: thrd:Thread and npost:Post;
	outputs: thrd':Thread;
	description: (* adds the post to the thread *);
	precondition: (* Post is non-empty, duplicate posts alowed *)
					#(npost.body) > 0 and thrd != nil;
	postcondition: (* Post is added to Thread, all other posts in thread are still there, and no extra posts are added *)
					(thrd'.posts = thrd.posts + npost) and (thrd'.topic = thrd.topic);
end NewPost;

operation EditPost is
	inputs: old_post:Post and new_post:Post and thrd:Thread;
	outputs: thrd':Thread;
	description: (* modifies the post *);
	precondition: (* Post is non-empty *)
					old_post in thrd.posts;
	postcondition: (* Post is changed as per users request *)
					(forall(p':Post) (p' in thrd'.posts) iff (((p' = new_post) or (p' in thrd.posts)) and (p' != old_post))) and (thrd'.topic = thrd.topic);
end EditPost;

operation RemovePost is
	inputs: thrd:Thread and pst:Post;
	outputs: thrd':Thread;
	description: (* removes a post obviously *);
	precondition: (* Post is non-empty *)
					pst in thrd.posts;
	postcondition: (* Post is removed from Thread, all other posts in thread are still there, and no extra posts are added *)
					(forall(p':Post) (p' in thrd'.posts) iff ((p' != pst) and (p' in thrd.posts))) and (thrd'.topic = thrd.topic);
end RemovePost;

operation NewThread is
	inputs: mb:MessageBoard and tpc:Topic and pst:Post;
	outputs: mb':MessageBoard and thrd:Thread;
	description: (* makes a new Thread and adds it to the MessageBoard *);
	precondition: (* Thread is non-empty, duplicate Threads alowed *)
					#(tpc.title) > 0;
	postcondition: (* Thread is added to MessageBoard, all other threads are still there, and no extra threads are added, Post is made initial post in new Thread *)
					(thrd.topic = tpc) and (thrd.posts = thrd.posts + pst) and (mb'.threads = mb.threads + thrd);
end NewThread;

operation RemoveThread is
	inputs: mb:MessageBoard and thrd:Thread;
	outputs: mb':MessageBoard;
	description: (* removes the Thread from the MessageBoard *);
	precondition: (* Thread is non-empty *)
					thrd in mb;
	postcondition: (* Thread is removed from MessageBoard, all other threads are still there, and no extra Threads are added *)
					(forall(t':Thread) (t' in mb'.threads) iff ((t' != thrd) and (t' in mb.threads)));
end RemoveThread;

end comms;





Prev: tutorial-viewer.rsl | Next: data.rsl | Up: spec | Top: index