MC Lab Manual
MC Lab Manual
Semester : VI
Div : A & B
Lab Outcome
1. To develop and demonstrate mobile applications using various tools
2. Students will articulate the knowledge of GSM, CDMA & Bluetooth technologies and
demonstrate it.
3. Students will able to carry out simulation of frequency reuse , hidden terminal problem
4. To develop security algorithms for mobile communication network
5. To demonstrate simulation and compare the performance of Wireless LAN
The software's like Android Studio, J2ME, NS2, NS3 and any other software which is suitable
are recommended for performing the practical.
4 To develop a Simple Android Application that uses Layout Managers and Event CO3
Listeners
5 Write an application that draws basic graphical primitives on the screen CO1
7 Implementation of income tax/loan EMI calculator and deploy the same on real CO1
devices.
8 Develop a native application that makes use of GPS location CO1
VPPCOE&VA-DM-COMP-FF-06
EXPERIMENT NO. 1
Theory: The Bluetooth technology aims at so-called ad-hoc piconets, which are local area networks
with a very limited coverage and without the need for an infrastructure. This is a different type of
network is needed to connect different small devices in close proximity (about 10 m) without expensive
wiring or the need for a wireless infrastructure
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
switch (requestCode) {
case REQUEST_WRITE_STORAGE:
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is ExternalStorageProvider.
*/
public static boolean isExternalStorageDocument(Uri uri) {
return "com.android.externalstorage.documents".equals(uri.getAuthority());
}
/**
* @param uri The Uri to check.
* @return Whether the Uri authority is DownloadsProvider.
*/
public static boolean isDownloadsDocument(Uri uri) {
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
}
/**
* @param uri The Uri to check.
<TextView
android:id="@+id/textView_FileName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:text="Please select file"
android:textSize="18sp" />
<Button
android:id="@+id/button_GetFile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="getFile"
android:text="Get file from device" />
<Button
android:id="@+id/button_SendFile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="sendViaBluetooth"
android:text="Send via Bluetooth" />
</LinearLayout>
Aim: To implement a basic function of Code Division Multiple Access (CDMA) to test the
orthogonality and autocorrelation of a code to be used for CDMA operation. Write an application
based on the above concept.
Theory:
Code-division multiple access (CDMA) is a channel access method used by
various radio communication technologies. CDMA is an example of multiple access, where
several transmitters can send information simultaneously over a single communication channel.
This allows several users to share a band of frequencies (see bandwidth). To permit this without
undue interference between the users, CDMA employs spread spectrum technology and a special
coding scheme (where each transmitter is assigned a code).
CDMA is used as the access method in many mobile phone standards. IS-95, also called
"cdmaOne", and its 3G evolution CDMA2000, are often simply referred to as "CDMA",
but UMTS, the 3G standard used by GSM carriers, also uses "wideband CDMA", or W-CDMA,
as well as TD-CDMA and TD-SCDMA, as its radio technologies.
The intended 4G successor to CDMA2000 was UMB (Ultra Mobile Broadband); however, in
November 2008, Qualcomm announced it was ending development of the technology, favoring
LTE instead
CDMA Orthogonality:
Techniques generally used are direct sequence spread spectrum modulation (DS-CDMA),
frequency hopping or mixed CDMA detection (JDCDMA). Here, a signal is generated which
extends over a wide bandwidth. A code called spreading code is used to perform this action.
Using a group of codes, which are orthogonal to each other, it is possible to select a signal with a
given code in the presence of many other signals with different orthogonal codes.
CDMA Autocorrelation:
Autocorrelation of the sequence, it determines the ability to synchronize and lock the spreading
code for the received signal.
What is CDMA?
2. Each station is allocated a different orthogonal sequence (code) which is N bit long for N stations
3. Each station does a scalar multiplication of its encoded data bit and code sequence.
5. Since the channel is common, amplitudes add up and hence resultant channel sequence is the sum of
sequences from all channels.
6. If station 1 wants to listen to station 2, it multiplies (inner product) the channel sequence with code of
station S2.
7. The inner product is then divided by N to get data bit transmitted from station 2.
mport numpy as np
c1=[1,1,1,1]
c2=[1,-1,1,-1]
c3=[1,1,-1,-1]
c4=[1,-1,-1,1]
rc=[]
d1=int(input("Enter D1 :"))
d2=int(input("Enter D2 :"))
d3=int(input("Enter D3 :"))
d4=int(input("Enter D4 :"))
r1=np.multiply(c1,d1)
r2=np.multiply(c2,d2)
r3=np.multiply(c3,d3)
r4=np.multiply(c4,d4)
resultant_channel=r1+r2+r3+r4;
print("Resultant Channel",resultant_channel)
Channel=int(input("Enter the station to listen for C1=1 ,C2=2, C3=3 C4=4 : "))
data=res1/len(inner_product)
print("Data bit that was sent",data)
output
Conclusion:
Thus, we have studied the CDMA code to test autocorrelation and orthogonality of codes and
executed the same using the java code as above and got proper output for it.
Theory:
GSM offers several security services using confidential information stored in the AuC and in the
individual SIM (which is plugged into an arbitrary MS). Three algorithms have been specified to
provide security services in GSM. Algorithm A3 is used for authentication, A5 for encryption, and A8
for the generation of a cipher key.
Authentication Algorithm :
1. The network sends the AUTHENTICATION REQUEST message containing the RAND.
2. The phone receives the RAND, and passes it to the SIM, in the RUN GSM ALGORITHM
command.
3. The SIM runs the A3 algorithm, and returns the SRES to the phone.
4. The phone transmits the SRES to the network in the AUTHENTICATION RESPONSE
message.
5. The network compares the SRES with its own SRES. If they match, the transaction may
proceed. Otherwise, the network either decides to repeat the authentication procedure with IMSI
if the TMSI was used, or returns an AUTHENTICATION REJECT message.
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
import random
k=random.getrandbits(128)
m=random.getrandbits(128)
kb=bin(k)[2:]
mb=bin(m)[2:]
kbl=kb[0:64]
kbr=kb[64:]
mbl=mb[0:64]
mbr=mb[64:]
a1=int(kbl,2)^int(mbr,2)
a2=int(kbr,2)^int(mbl,2)
a3=a1^a2
a4=bin(a3)[2:].zfill(64)
a5=a4[0:32]
a6=a4[32:]
a7=int(a5,2)^int(a6,2)
print("128 Bit Key = ",kb)
print("128 Random Bits Generated = ",mb)
print("RES/SRES = ",bin(a7)[2:].zfill(len(a5)))
Conclusion: Thus the program for GSM security is implemented and verified.
Aim: To develop a Simple Android Application that uses Layout Managers and Event Listeners.
Procedure:Creating a New project:
Open Android Stdio and then click on File -> New -> New project.
Then select the Minimum SDK as shown below and click Next.
Then delete the code which is there and type the code as given below.
Code for Activity_main.xml:?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:text="Details Form"
<GridLayout
android:id="@+id/gridLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="100dp"
android:layout_marginBottom="200dp"
android:columnCount="2"
android:rowCount="3">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_row="0"
android:layout_column="0"
android:text="Name"
android:textSize="20sp"
android:gravity="center"/>
<EditText
android:id="@+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_row="0"
android:layout_column="1"
android:ems="10"/>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_row="1"
android:layout_column="0"
android:text="Reg.No"
android:textSize="20sp"
android:gravity="center"/>
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_row="2"
android:layout_column="0"
android:text="Dept"
android:textSize="20sp"
android:gravity="center"/>
<Spinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_row="2"
android:layout_column="1"
android:spinnerMode="dropdown"/>
</GridLayout>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_marginBottom="150dp"
android:text="Submit"/>
</RelativeLayout>
Now click on Design and your activity will look as given below.
Then delete the code which is there and type the code as given below.
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:text="New Text"
android:textSize="30sp"/>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:text="New Text"
android:textSize="30sp"/>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:text="New Text"
android:textSize="30sp"/>
</LinearLayout>
Now click on Design and your activity will look as given below.
Then delete the code which is there and type the code as given below.
Code for MainActivity.java:
?
package com.example.exno2;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
String name,reg,dept;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
s= (Spinner) findViewById(R.id.spinner);
//Creating Adapter for Spinner for adapting the data from array to Spinner
ArrayAdapter adapter= new ArrayAdapter(MainActivity.this,android.R.layout.simple_spinner_item,dept_arra
s.setAdapter(adapter);
startActivity(i);
Then delete the code which is there and type the code as given below.
Code for SecondActivity.java:
?
package com.example.exno2;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
TextView t1,t2,t3;
String name,reg,dept;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
}
}
So now the Coding part of Second Activity is also completed.
Now run the application to see the output.
Output:
Result:Thus a Simple Android Application that uses Layout Managers and Event Listeners is
developed and executed successfully.
Aim: Write an application that draws basic graphical primitives on the screen.
1. activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView" />
</RelativeLayout>
2. MainActivity.java:
package com.example.exp11;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.widget.ImageView;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Creating a Bitmap
i.setBackgroundDrawable(new BitmapDrawable(bg));
//Creating the Paint Object and set its color & TextSize
paint.setColor(Color.BLUE);
paint.setTextSize(50);
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:gravity="center"
android:text="Hello World!"
android:textSize="25sp"
android:textStyle="bold" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="center"
android:text="Change font size"
android:textSize="25sp" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="center"
android:text="Change color"
android:textSize="25sp" />
</LinearLayout>
package com.example.exno1;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
Aim: Implementation of income tax/loan EMI calculator and deploy the same on real devices.
where,
E is EMI
P is Principal Loan Amount
r is the rate of interest calculated on monthly basis.
n is loan term/tenure / duration in number of months
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="abu.emicalculator.MainActivity"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="10dp">
<EditText
android:id="@+id/principal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:inputType="number"
android:digits="0123456789."
android:hint="@string/hint_principal" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_interest"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/interest"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:inputType="number"
android:digits="0123456789."
android:hint="@string/hint_interest" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_tenure"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/years"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:digits="0123456789."
android:hint="@string/hint_years" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_emi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp">
<EditText
android:id="@+id/emi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxEms="0"
android:inputType="number"
android:hint="@string/hint_emi" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_total_Interest"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<EditText
android:id="@+id/interest_total"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:hint="@string/hint_interest_total" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
package abu.emicalculator;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
Button emiCalcBtn;
if (TextUtils.isEmpty(st1)) {
P.setError("Enter Prncipal Amount");
P.requestFocus();
return;
}
if (TextUtils.isEmpty(st2)) {
I.setError("Enter Interest Rate");
I.requestFocus();
return;
}
if (TextUtils.isEmpty(st3)) {
Y.setError("Enter Years");
Y.requestFocus();
return;
}
float p = Float.parseFloat(st1);
float i = Float.parseFloat(st2);
float y = Float.parseFloat(st3);
float D = calDivider(Dvdnt);
result.setText(String.valueOf(emi));
TI.setText(String.valueOf(ti));
}
});
}
}
public float calEmi(float FD, Float D) {
}
}
package com.rdc;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Toast;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
pb = (ProgressBar) findViewById(R.id.progressBar1);
pb.setVisibility(View.INVISIBLE);
locationMangaer = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
@Override
public void onClick(View v) {
flag = displayGpsStatus();
if (flag) {
Log.v(TAG, "onClick");
pb.setVisibility(View.VISIBLE);
locationListener = new MyLocationListener();
locationMangaer.requestLocationUpdates(LocationManager
.GPS_PROVIDER, 5000, 10,locationListener);
} else {
return false;
}
}
editLocation.setText("");
pb.setVisibility(View.INVISIBLE);
Toast.makeText(getBaseContext(),"Location changed : Lat: " +
loc.getLatitude()+ " Lng: " + loc.getLongitude(),
Toast.LENGTH_SHORT).show();
String longitude = "Longitude: " +loc.getLongitude();
Log.v(TAG, longitude);
String latitude = "Latitude: " +loc.getLatitude();
Log.v(TAG, latitude);
</intent-filter> </activity>
</application>
</manifest>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="20dp"
android:layout_y="110dp"
android:text="Enter Rollno:"
android:textSize="20sp" />
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Rollno=(EditText)findViewById(R.id.Rollno);
Name=(EditText)findViewById(R.id.Name);
Marks=(EditText)findViewById(R.id.Marks);
Insert=(Button)findViewById(R.id.Insert);
Delete=(Button)findViewById(R.id.Delete);
Update=(Button)findViewById(R.id.Update);
View=(Button)findViewById(R.id.View);
ViewAll=(Button)findViewById(R.id.ViewAll);
Insert.setOnClickListener(this);
Delete.setOnClickListener(this);
coordinates of the network if the input from a GPS receiver is additionally available. 4. Kismet works
with a lot of wireless cards supporting ”monitor” mode. This mode captures packets without being able
to associate in the same time with an access point and require privileges rights. 5. Kismet detects
networks by passively sniffing providing it the advantages to discover the ”hidden” wireless networks
and being itself undetectable. B.
Advantage of kismet
• It results is very good for small area.
• It has a Server – Client architecture
• Drones: distributed kismet servers running on remote devices, reporting back to central server, allow
for the building of distributed reporting and intrusion detection systems.
• Kismet is powerful - especially when combined with other tools like wireshark, nmap. C.
Disadvantage of kismet
• It takes long time to search networks.
• It can only identify the wireless network (WiFi) in a small area, if the range is more it cannot work
properly. D. System requirements (a) Kismet – packet sniffer (b) Spectrum analyzers: airview, wispy
(c) General networking tools : wireshark, ntop, mrtg, rrdtool, nmap etc. (d) WEP/WPA/WPA2
cracking: aircrack etc (e) It will work (at some level) on any operating system which has POSIX
Advantage of NetStumbler
• NetStumbler is a very useful tool that any wireless network administrator should be using periodically
CONCLUSION : We studied the necessity of security tools for wireless networks and also gathered
information about two popular security tools : Kismet and NetStumbler.
EXPERIMENT NO. 11
Procedure:
Open Android Studio and then click on File -> New -> New project.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Message"
android:textSize="30sp" />
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="30sp" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:layout_gravity="center"
android:text="Notify"
android:textSize="30sp"/>
</LinearLayout>
Now click on Design and your application will look as given below.
Then delete the code which is there and type the code as given below.
Code for MainActivity.java:
?
package com.example.exno10;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
notify.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Intent intent = new Intent(MainActivity.this, SecondActivity.class);
PendingIntent pending = PendingIntent.getActivity(MainActivity.this, 0, intent, 0);
Notification noti = new Notification.Builder(MainActivity.this).setContentTitle("New
Message").setContentText(e.getText().toString()).setSmallIcon(R.mipmap.ic_launcher).setContentIntent(pen
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERV
noti.flags |= Notification.FLAG_AUTO_CANCEL;
manager.notify(0, noti);
}
});
}
}
So now the Coding part is also completed.
Now run the application to see the output.
Output:
Thus Android Application that creates an alert upon receiving a message is developed and
executed successfully.
Aim :-
To understand the cellular frequency reuse concept to find the co-channel cells for a
particular cell. Design a game based application on the above concept.
THEORY:
Each cellular base station is allocated a group of radio channels to be used within a small
geographic area called a cell. Base stations in adjacent cells are assigned channel groups which
contain completely different channels than neighboring cells. Base station antennas are designed to
achieve the desired coverage within a particular cell. By limiting the coverage area within the
boundaries of a cell, the same group of channels may be used to cover different cells that are
separated from one another by geographic distances large enough to keep interference levels within
tolerable limits. The design process of selecting and allocating channel groups for all cellular base
stations within a system is called frequency reuse or frequency planning.
ALGORITHM:
1. start
2. Accept value of number of cells per cluster i.e. N from the user.
6. stop.
self.cluster_size = cluster_size
self.reuse_list = []
self.all_selected = False
self.curr_count = 0
self.hexagons = []
self.co_cell_endp = []
self.reuse_xy = []
self.canvas = Canvas(self,
width=self.CANVAS_WIDTH,
height=self.CANVAS_HEIGHT,
bg="#4dd0e1")
self.canvas.bind("<Button-1>", self.call_back)
self.canvas.focus_set()
self.canvas.bind('<Shift-R>', self.resets)
self.canvas.pack()
self.title("Frequency reuse and co-channel selection")
self.create_grid(16, 10)
self.create_textbox()
self.cluster_reuse_calc()
end_xx = (self.co_cell_endp[k])[0]
end_yy = (self.co_cell_endp[k])[1]
def create_textbox(self):
txt = Text(self.canvas,
width=80,
height=1,
font=("Helvatica", 12),
padx=10,
pady=10)
txt.tag_configure("center", justify="center")
txt.insert("1.0", "Select a Hexagon")
txt.tag_add("center", "1.0", "end")
self.canvas.create_window((0, 600), anchor='w', window=txt)
txt.config(state=DISABLED)
self.textbox = txt
try:
self.line_ids
except AttributeError:
pass
if button_reset:
self.write_text("Select a Hexagon")
return True
return False
if self.first_click:
self.first_click = False
self.write_text(
"""Now, select another hexagon such
that it should be a co-cell of
the original hexagon."""
)
self.co_cell_endp.append(approx_center)
self.canvas.itemconfigure(hexagon.tags, fill="green")
for _ in range(6):
if j == 0:
self.reuse_list.append(
self.canvas.find_closest(end_xx,
end_yy)[0])
elif i >= j and j != 0:
self.reuse_list.append(
self.canvas.find_closest(reuse_x,
reuse_y)[0])
else:
curr = self.canvas.find_closest(s_x, s_y)[0]
if curr in self.reuse_list:
,
fill="green")
self.write_text("Correct! Cell {} is a co
cell.".format(
hexagon.tags))
if self.curr_count == len(self.reuse_list) - 1:
self.write_text("Great! Press Shift-R to
restart")
self.show_lines()
self.curr_count += 1
else:
self.write_text("Incorrect! Cell {} is not a co
cell.".format(
hexagon.tags))
self.canvas.itemconfigure(hexagon.tags, fill="red")
if __name__ == '__main__':
print(
"""Enter i & j values. common (i,j) values are:
(1,0), (1,1), (2,0), (2,1), (3,0), (2,2)"""
)
i = int(input("Enter i: "))
j = int(input("Enter j: "))
if i == 0 and j == 0:
raise ValueError("i & j both cannot be zero")
elif j > i:
raise ValueError("value of j cannot be greater than i")
else:
N = (i**2 + i * j + j**2)
print("N is {}".format(N))
freqreuse = FrequencyReuse(cluster_size=N)
freqreuse.mainloop()
OUTPUT:
VPPCOE&VA-DM-COMP-FF-06